diff options
395 files changed, 28891 insertions, 21952 deletions
@@ -122,8 +122,7 @@ conformance/succeeding_tests.txt # php test output composer.lock -php/tests/test.pb.php -php/tests/test_include.pb.php +php/tests/generated/ php/ext/google/protobuf/.libs/ php/ext/google/protobuf/Makefile.fragments php/ext/google/protobuf/Makefile.global @@ -304,6 +304,7 @@ cc_library( "src/google/protobuf/compiler/javanano/javanano_message_field.cc", "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", "src/google/protobuf/compiler/js/js_generator.cc", + "src/google/protobuf/compiler/js/well_known_types_embed.cc", "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", @@ -749,3 +750,10 @@ internal_protobuf_py_tests( ], deps = [":python_tests"], ) + +proto_lang_toolchain( + name = "cc_toolchain", + runtime = ":protobuf", + command_line = "--cpp_out=$(OUT)", + visibility = ["//visibility:public"], +) diff --git a/Makefile.am b/Makefile.am index 4763d949..4ece5217 100644 --- a/Makefile.am +++ b/Makefile.am @@ -100,6 +100,7 @@ csharp_EXTRA_DIST= \ csharp/src/Google.Protobuf.Test/TestCornerCases.cs \ csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs \ csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \ + csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \ csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \ @@ -557,6 +558,8 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/text_format_map_unittest_data.txt \ objectivec/Tests/text_format_unittest_data.txt \ objectivec/Tests/unittest_cycle.proto \ + objectivec/Tests/unittest_deprecated.proto \ + objectivec/Tests/unittest_deprecated_file.proto \ objectivec/Tests/unittest_extension_chain_a.proto \ objectivec/Tests/unittest_extension_chain_b.proto \ objectivec/Tests/unittest_extension_chain_c.proto \ @@ -572,56 +575,88 @@ objectivec_EXTRA_DIST= \ objectivec/Tests/UnitTests-Info.plist \ Protobuf.podspec -php_EXTRA_DIST= \ - php/src/phpdoc.dist.xml \ - php/src/Google/Protobuf/Internal/DescriptorPool.php \ - php/src/Google/Protobuf/Internal/OneofField.php \ - php/src/Google/Protobuf/Internal/MapEntry.php \ - php/src/Google/Protobuf/Internal/InputStream.php \ - php/src/Google/Protobuf/Internal/OutputStream.php \ - php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ - php/src/Google/Protobuf/Internal/MapField.php \ - php/src/Google/Protobuf/Internal/RepeatedField.php \ - php/src/Google/Protobuf/Internal/Message.php \ - php/src/Google/Protobuf/Internal/GPBWire.php \ - php/src/Google/Protobuf/Internal/GPBType.php \ - php/src/Google/Protobuf/Internal/GPBLabel.php \ - php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ - php/src/Google/Protobuf/Internal/GPBUtil.php \ - php/src/Google/Protobuf/descriptor_internal.pb.php \ - php/src/Google/Protobuf/descriptor.php \ - php/tests/encode_decode_test.php \ - php/tests/test.sh \ - php/tests/generated_class_test.php \ - php/tests/array_test.php \ - php/tests/php_implementation_test.php \ - php/tests/test_include.proto \ - php/tests/test_include.pb.php \ - php/tests/map_field_test.php \ - php/tests/test_base.php \ - php/tests/test_no_namespace.proto \ - php/tests/test_no_namespace.pb.php \ - php/tests/test_util.php \ - php/tests/test.proto \ - php/tests/test.pb.php \ - php/tests/memory_leak_test.php \ - php/README.md \ - php/ext/google/protobuf/utf8.h \ - php/ext/google/protobuf/message.c \ - php/ext/google/protobuf/utf8.c \ - php/ext/google/protobuf/package.xml \ - php/ext/google/protobuf/upb.h \ - php/ext/google/protobuf/array.c \ - php/ext/google/protobuf/encode_decode.c \ - php/ext/google/protobuf/protobuf.h \ - php/ext/google/protobuf/type_check.c \ - php/ext/google/protobuf/def.c \ - php/ext/google/protobuf/storage.c \ - php/ext/google/protobuf/map.c \ - php/ext/google/protobuf/config.m4 \ - php/ext/google/protobuf/upb.c \ - php/ext/google/protobuf/protobuf.c \ - phpunit.xml \ +php_EXTRA_DIST= \ + php/src/phpdoc.dist.xml \ + php/src/Google/Protobuf/Internal/DescriptorPool.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \ + php/src/Google/Protobuf/Internal/OneofField.php \ + php/src/Google/Protobuf/Internal/MessageOptions.php \ + php/src/Google/Protobuf/Internal/FileDescriptorProto.php \ + php/src/Google/Protobuf/Internal/MapEntry.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \ + php/src/Google/Protobuf/Internal/InputStream.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption.php \ + php/src/Google/Protobuf/Internal/ServiceOptions.php \ + php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \ + php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \ + php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \ + php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \ + php/src/Google/Protobuf/Internal/OutputStream.php \ + php/src/Google/Protobuf/Internal/MessageBuilderContext.php \ + php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \ + php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \ + php/src/Google/Protobuf/Internal/DescriptorProto.php \ + php/src/Google/Protobuf/Internal/MapField.php \ + php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \ + php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \ + php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \ + php/src/Google/Protobuf/Internal/RepeatedField.php \ + php/src/Google/Protobuf/Internal/EnumValueOptions.php \ + php/src/Google/Protobuf/Internal/MethodOptions.php \ + php/src/Google/Protobuf/Internal/OneofOptions.php \ + php/src/Google/Protobuf/Internal/Message.php \ + php/src/Google/Protobuf/Internal/FileOptions.php \ + php/src/Google/Protobuf/Internal/FileDescriptorSet.php \ + php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \ + php/src/Google/Protobuf/Internal/GPBWire.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \ + php/src/Google/Protobuf/Internal/FieldOptions.php \ + php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \ + php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \ + php/src/Google/Protobuf/Internal/GPBType.php \ + php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \ + php/src/Google/Protobuf/Internal/SourceCodeInfo.php \ + php/src/Google/Protobuf/Internal/EnumOptions.php \ + php/src/Google/Protobuf/Internal/GPBLabel.php \ + php/src/Google/Protobuf/Internal/EnumBuilderContext.php \ + php/src/Google/Protobuf/Internal/GPBUtil.php \ + php/src/Google/Protobuf/Internal/FieldOptions_CType.php \ + php/src/Google/Protobuf/descriptor.php \ + php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \ + php/tests/autoload.php \ + php/tests/encode_decode_test.php \ + php/tests/test.sh \ + php/tests/gdb_test.sh \ + php/tests/generated_class_test.php \ + php/tests/array_test.php \ + php/tests/php_implementation_test.php \ + php/tests/proto/test_include.proto \ + php/tests/map_field_test.php \ + php/tests/test_base.php \ + php/tests/proto/test_no_namespace.proto \ + php/tests/test_util.php \ + php/tests/proto/test.proto \ + php/tests/memory_leak_test.php \ + php/tests/well_known_test.php \ + php/README.md \ + php/ext/google/protobuf/utf8.h \ + php/ext/google/protobuf/message.c \ + php/ext/google/protobuf/utf8.c \ + php/ext/google/protobuf/package.xml \ + php/ext/google/protobuf/upb.h \ + php/ext/google/protobuf/array.c \ + php/ext/google/protobuf/encode_decode.c \ + php/ext/google/protobuf/protobuf.h \ + php/ext/google/protobuf/type_check.c \ + php/ext/google/protobuf/def.c \ + php/ext/google/protobuf/storage.c \ + php/ext/google/protobuf/map.c \ + php/ext/google/protobuf/config.m4 \ + php/ext/google/protobuf/upb.c \ + php/ext/google/protobuf/protobuf.c \ + php/phpunit.xml \ + php/composer.json \ composer.json python_EXTRA_DIST= \ @@ -712,6 +747,7 @@ python_EXTRA_DIST= \ python/google/protobuf/pyext/repeated_composite_container.h \ python/google/protobuf/pyext/repeated_scalar_container.cc \ python/google/protobuf/pyext/repeated_scalar_container.h \ + python/google/protobuf/pyext/safe_numerics.h \ python/google/protobuf/pyext/scoped_pyobject_ptr.h \ python/google/protobuf/reflection.py \ python/google/protobuf/service.py \ diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 4b572bb6..085071db 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -29,6 +29,7 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_gen copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h include\google\protobuf\compiler\js\js_generator.h +copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h include\google\protobuf\compiler\js\well_known_types_embed.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 71c3494c..2d238449 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -72,6 +72,7 @@ set(libprotoc_files ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc + ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc diff --git a/composer.json b/composer.json index 6afe71ce..2833f0a2 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,11 @@ }, "autoload": { "psr-4": { - "Google\\": "php/src/Google" + "Google\\Protobuf\\Internal\\": "src/Google/Protobuf/Internal", + "GPBMetadata\\Google\\Protobuf\\Internal\\": "src/GPBMetadata/Google/Protobuf/Internal" }, "files": [ - "php/src/Google/Protobuf/descriptor.php", - "php/src/Google/Protobuf/descriptor_internal.pb.php" + "src/Google/Protobuf/descriptor.php" ] } } diff --git a/configure.ac b/configure.ac index 896f3471..d1e913c6 100644 --- a/configure.ac +++ b/configure.ac @@ -178,6 +178,8 @@ case "$target_os" in esac AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1]) +AX_CXX_COMPILE_STDCXX([11], [noext], [optional]) + # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS, # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock # too. diff --git a/conformance/ConformanceJava.java b/conformance/ConformanceJava.java index 43787ffc..7badf2a5 100644 --- a/conformance/ConformanceJava.java +++ b/conformance/ConformanceJava.java @@ -1,8 +1,12 @@ - +import com.google.protobuf.ByteString; +import com.google.protobuf.CodedInputStream; import com.google.protobuf.conformance.Conformance; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf_test_messages.proto3.TestMessagesProto3; import com.google.protobuf.util.JsonFormat; import com.google.protobuf.util.JsonFormat.TypeRegistry; -import com.google.protobuf.InvalidProtocolBufferException; +import java.io.IOException; +import java.nio.ByteBuffer; class ConformanceJava { private int testCount = 0; @@ -47,13 +51,182 @@ class ConformanceJava { writeToStdout(buf); } + private enum BinaryDecoder { + BYTE_STRING_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + return TestMessagesProto3.TestAllTypes.parseFrom(bytes); + } + }, + BYTE_ARRAY_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + return TestMessagesProto3.TestAllTypes.parseFrom(bytes.toByteArray()); + } + }, + ARRAY_BYTE_BUFFER_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocate(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer)); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } + }, + READONLY_ARRAY_BYTE_BUFFER_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + try { + return TestMessagesProto3.TestAllTypes.parseFrom( + CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer())); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } + }, + DIRECT_BYTE_BUFFER_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer)); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } + }, + READONLY_DIRECT_BYTE_BUFFER_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size()); + bytes.copyTo(buffer); + buffer.flip(); + try { + return TestMessagesProto3.TestAllTypes.parseFrom( + CodedInputStream.newInstance(buffer.asReadOnlyBuffer())); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based ByteBuffer should not throw IOException.", e); + } + } + }, + INPUT_STREAM_DECODER() { + @Override + public TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException { + try { + return TestMessagesProto3.TestAllTypes.parseFrom(bytes.newInput()); + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException( + "ByteString based InputStream should not throw IOException.", e); + } + } + }; + + public abstract TestMessagesProto3.TestAllTypes parse(ByteString bytes) + throws InvalidProtocolBufferException; + } + + private TestMessagesProto3.TestAllTypes parseBinary(ByteString bytes) + throws InvalidProtocolBufferException { + TestMessagesProto3.TestAllTypes[] messages = + new TestMessagesProto3.TestAllTypes[BinaryDecoder.values().length]; + InvalidProtocolBufferException[] exceptions = + new InvalidProtocolBufferException[BinaryDecoder.values().length]; + + boolean hasMessage = false; + boolean hasException = false; + for (int i = 0; i < BinaryDecoder.values().length; ++i) { + try { + messages[i] = BinaryDecoder.values()[i].parse(bytes); + hasMessage = true; + } catch (InvalidProtocolBufferException e) { + exceptions[i] = e; + hasException = true; + } + } + + if (hasMessage && hasException) { + StringBuilder sb = + new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n"); + for (int i = 0; i < BinaryDecoder.values().length; ++i) { + sb.append(BinaryDecoder.values()[i].name()); + if (messages[i] != null) { + sb.append(" accepted the payload.\n"); + } else { + sb.append(" rejected the payload.\n"); + } + } + throw new RuntimeException(sb.toString()); + } + + if (hasException) { + // We do not check if exceptions are equal. Different implementations may return different + // exception messages. Throw an arbitrary one out instead. + throw exceptions[0]; + } + + // Fast path comparing all the messages with the first message, assuming equality being + // symmetric and transitive. + boolean allEqual = true; + for (int i = 1; i < messages.length; ++i) { + if (!messages[0].equals(messages[i])) { + allEqual = false; + break; + } + } + + // Slow path: compare and find out all unequal pairs. + if (!allEqual) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < messages.length - 1; ++i) { + for (int j = i + 1; j < messages.length; ++j) { + if (!messages[i].equals(messages[j])) { + sb.append(BinaryDecoder.values()[i].name()) + .append(" and ") + .append(BinaryDecoder.values()[j].name()) + .append(" parsed the payload differently.\n"); + } + } + } + throw new RuntimeException(sb.toString()); + } + + return messages[0]; + } + private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) { - Conformance.TestAllTypes testMessage; + TestMessagesProto3.TestAllTypes testMessage; switch (request.getPayloadCase()) { case PROTOBUF_PAYLOAD: { try { - testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload()); + testMessage = parseBinary(request.getProtobufPayload()); } catch (InvalidProtocolBufferException e) { return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build(); } @@ -61,7 +234,7 @@ class ConformanceJava { } case JSON_PAYLOAD: { try { - Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder(); + TestMessagesProto3.TestAllTypes.Builder builder = TestMessagesProto3.TestAllTypes.newBuilder(); JsonFormat.parser().usingTypeRegistry(typeRegistry) .merge(request.getJsonPayload(), builder); testMessage = builder.build(); @@ -127,7 +300,7 @@ class ConformanceJava { public void run() throws Exception { typeRegistry = TypeRegistry.newBuilder().add( - Conformance.TestAllTypes.getDescriptor()).build(); + TestMessagesProto3.TestAllTypes.getDescriptor()).build(); while (doTestIo()) { this.testCount++; } diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 5985e1d9..c2b58900 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -1,7 +1,8 @@ ## Process this file with automake to produce Makefile.in conformance_protoc_inputs = \ - conformance.proto + conformance.proto \ + $(top_srcdir)/src/google/protobuf/test_messages_proto3.proto well_known_type_protoc_inputs = \ $(top_srcdir)/src/google/protobuf/any.proto \ @@ -61,6 +62,7 @@ other_language_protoc_outputs = \ com/google/protobuf/Value.java \ com/google/protobuf/ValueOrBuilder.java \ com/google/protobuf/WrappersProto.java \ + com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \ google/protobuf/any.pb.cc \ google/protobuf/any.pb.h \ google/protobuf/any.rb \ @@ -77,6 +79,12 @@ other_language_protoc_outputs = \ google/protobuf/struct.pb.h \ google/protobuf/struct.rb \ google/protobuf/struct_pb2.py \ + google/protobuf/TestMessagesProto3.pbobjc.h \ + google/protobuf/TestMessagesProto3.pbobjc.m \ + google/protobuf/test_messages_proto3.pb.cc \ + google/protobuf/test_messages_proto3.pb.h \ + google/protobuf/test_messages_proto3_pb.rb \ + google/protobuf/test_messages_proto3_pb2.py \ google/protobuf/timestamp.pb.cc \ google/protobuf/timestamp.pb.h \ google/protobuf/timestamp.rb \ @@ -152,7 +160,7 @@ conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \ conformance_test_runner.cc \ third_party/jsoncpp/json.h \ third_party/jsoncpp/jsoncpp.cpp -nodist_conformance_test_runner_SOURCES = conformance.pb.cc +nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) conformance_test_runner_CXXFLAGS = -std=c++11 # Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check" @@ -162,7 +170,7 @@ conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la conformance_cpp_SOURCES = conformance_cpp.cc -nodist_conformance_cpp_SOURCES = conformance.pb.cc +nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src # Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check" # so a direct "make test_cpp" could fail if parallel enough. @@ -173,7 +181,7 @@ if OBJC_CONFORMANCE_TEST bin_PROGRAMS += conformance-objc conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m -nodist_conformance_objc_SOURCES = Conformance.pbobjc.m +nodist_conformance_objc_SOURCES = Conformance.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m # On travis, the build fails without the isysroot because whatever system # headers are being found don't include generics support for # NSArray/NSDictionary, the only guess is their image at one time had an odd @@ -182,7 +190,7 @@ conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk ma conformance_objc_LDFLAGS = -framework Foundation # Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check" # so a direct "make test_objc" could fail if parallel enough. -conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h +conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h endif @@ -221,7 +229,7 @@ MAINTAINERCLEANFILES = \ Makefile.in javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs) - jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java + jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java @touch javac_middleman conformance-java: javac_middleman diff --git a/conformance/conformance.proto b/conformance/conformance.proto index 95a8fd13..18e4b7bc 100644 --- a/conformance/conformance.proto +++ b/conformance/conformance.proto @@ -32,13 +32,6 @@ syntax = "proto3"; package conformance; option java_package = "com.google.protobuf.conformance"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - // This defines the conformance testing protocol. This protocol exists between // the conformance test suite itself and the code being tested. For each test, // the suite will send a ConformanceRequest message and expect a @@ -70,8 +63,13 @@ enum WireFormat { // 2. parse the protobuf or JSON payload in "payload" (which may fail) // 3. if the parse succeeded, serialize the message in the requested format. message ConformanceRequest { - // The payload (whether protobuf of JSON) is always for a TestAllTypes proto - // (see below). + // The payload (whether protobuf of JSON) is always for a + // protobuf_test_messages.proto3.TestAllTypes proto (as defined in + // src/google/protobuf/proto3_test_messages.proto). + // + // TODO(haberman): if/when we expand the conformance tests to support proto2, + // we will want to include a field that lets the payload/response be a + // protobuf_test_messages.proto2.TestAllTypes message instead. oneof payload { bytes protobuf_payload = 1; string json_payload = 2; @@ -114,172 +112,3 @@ message ConformanceResponse { string skipped = 5; } } - -// This proto includes every type of field in both singular and repeated -// forms. -message TestAllTypes { - message NestedMessage { - int32 a = 1; - TestAllTypes corecursive = 2; - } - - enum NestedEnum { - FOO = 0; - BAR = 1; - BAZ = 2; - NEG = -1; // Intentionally negative. - } - - // Singular - int32 optional_int32 = 1; - int64 optional_int64 = 2; - uint32 optional_uint32 = 3; - uint64 optional_uint64 = 4; - sint32 optional_sint32 = 5; - sint64 optional_sint64 = 6; - fixed32 optional_fixed32 = 7; - fixed64 optional_fixed64 = 8; - sfixed32 optional_sfixed32 = 9; - sfixed64 optional_sfixed64 = 10; - float optional_float = 11; - double optional_double = 12; - bool optional_bool = 13; - string optional_string = 14; - bytes optional_bytes = 15; - - NestedMessage optional_nested_message = 18; - ForeignMessage optional_foreign_message = 19; - - NestedEnum optional_nested_enum = 21; - ForeignEnum optional_foreign_enum = 22; - - string optional_string_piece = 24 [ctype=STRING_PIECE]; - string optional_cord = 25 [ctype=CORD]; - - TestAllTypes recursive_message = 27; - - // Repeated - repeated int32 repeated_int32 = 31; - repeated int64 repeated_int64 = 32; - repeated uint32 repeated_uint32 = 33; - repeated uint64 repeated_uint64 = 34; - repeated sint32 repeated_sint32 = 35; - repeated sint64 repeated_sint64 = 36; - repeated fixed32 repeated_fixed32 = 37; - repeated fixed64 repeated_fixed64 = 38; - repeated sfixed32 repeated_sfixed32 = 39; - repeated sfixed64 repeated_sfixed64 = 40; - repeated float repeated_float = 41; - repeated double repeated_double = 42; - repeated bool repeated_bool = 43; - repeated string repeated_string = 44; - repeated bytes repeated_bytes = 45; - - repeated NestedMessage repeated_nested_message = 48; - repeated ForeignMessage repeated_foreign_message = 49; - - repeated NestedEnum repeated_nested_enum = 51; - repeated ForeignEnum repeated_foreign_enum = 52; - - repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; - repeated string repeated_cord = 55 [ctype=CORD]; - - // Map - map < int32, int32> map_int32_int32 = 56; - map < int64, int64> map_int64_int64 = 57; - map < uint32, uint32> map_uint32_uint32 = 58; - map < uint64, uint64> map_uint64_uint64 = 59; - map < sint32, sint32> map_sint32_sint32 = 60; - map < sint64, sint64> map_sint64_sint64 = 61; - map < fixed32, fixed32> map_fixed32_fixed32 = 62; - map < fixed64, fixed64> map_fixed64_fixed64 = 63; - map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; - map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; - map < int32, float> map_int32_float = 66; - map < int32, double> map_int32_double = 67; - map < bool, bool> map_bool_bool = 68; - map < string, string> map_string_string = 69; - map < string, bytes> map_string_bytes = 70; - map < string, NestedMessage> map_string_nested_message = 71; - map < string, ForeignMessage> map_string_foreign_message = 72; - map < string, NestedEnum> map_string_nested_enum = 73; - map < string, ForeignEnum> map_string_foreign_enum = 74; - - oneof oneof_field { - uint32 oneof_uint32 = 111; - NestedMessage oneof_nested_message = 112; - string oneof_string = 113; - bytes oneof_bytes = 114; - bool oneof_bool = 115; - uint64 oneof_uint64 = 116; - float oneof_float = 117; - double oneof_double = 118; - NestedEnum oneof_enum = 119; - } - - // Well-known types - google.protobuf.BoolValue optional_bool_wrapper = 201; - google.protobuf.Int32Value optional_int32_wrapper = 202; - google.protobuf.Int64Value optional_int64_wrapper = 203; - google.protobuf.UInt32Value optional_uint32_wrapper = 204; - google.protobuf.UInt64Value optional_uint64_wrapper = 205; - google.protobuf.FloatValue optional_float_wrapper = 206; - google.protobuf.DoubleValue optional_double_wrapper = 207; - google.protobuf.StringValue optional_string_wrapper = 208; - google.protobuf.BytesValue optional_bytes_wrapper = 209; - - repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; - repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; - repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; - repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; - repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; - repeated google.protobuf.FloatValue repeated_float_wrapper = 216; - repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; - repeated google.protobuf.StringValue repeated_string_wrapper = 218; - repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; - - google.protobuf.Duration optional_duration = 301; - google.protobuf.Timestamp optional_timestamp = 302; - google.protobuf.FieldMask optional_field_mask = 303; - google.protobuf.Struct optional_struct = 304; - google.protobuf.Any optional_any = 305; - google.protobuf.Value optional_value = 306; - - repeated google.protobuf.Duration repeated_duration = 311; - repeated google.protobuf.Timestamp repeated_timestamp = 312; - repeated google.protobuf.FieldMask repeated_fieldmask = 313; - repeated google.protobuf.Struct repeated_struct = 324; - repeated google.protobuf.Any repeated_any = 315; - repeated google.protobuf.Value repeated_value = 316; - - // Test field-name-to-JSON-name convention. - // (protobuf says names can be any valid C/C++ identifier.) - int32 fieldname1 = 401; - int32 field_name2 = 402; - int32 _field_name3 = 403; - int32 field__name4_ = 404; - int32 field0name5 = 405; - int32 field_0_name6 = 406; - int32 fieldName7 = 407; - int32 FieldName8 = 408; - int32 field_Name9 = 409; - int32 Field_Name10 = 410; - int32 FIELD_NAME11 = 411; - int32 FIELD_name12 = 412; - int32 __field_name13 = 413; - int32 __Field_name14 = 414; - int32 field__name15 = 415; - int32 field__Name16 = 416; - int32 field_name17__ = 417; - int32 Field_name18__ = 418; -} - -message ForeignMessage { - int32 c = 1; -} - -enum ForeignEnum { - FOREIGN_FOO = 0; - FOREIGN_BAR = 1; - FOREIGN_BAZ = 2; -} diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc index 1a265493..df3f2acd 100644 --- a/conformance/conformance_cpp.cc +++ b/conformance/conformance_cpp.cc @@ -33,12 +33,12 @@ #include <unistd.h> #include "conformance.pb.h" +#include "google/protobuf/test_messages_proto3.pb.h" #include <google/protobuf/util/json_util.h> #include <google/protobuf/util/type_resolver_util.h> using conformance::ConformanceRequest; using conformance::ConformanceResponse; -using conformance::TestAllTypes; using google::protobuf::Descriptor; using google::protobuf::DescriptorPool; using google::protobuf::internal::scoped_ptr; @@ -47,6 +47,7 @@ using google::protobuf::util::JsonToBinaryString; using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::Status; using google::protobuf::util::TypeResolver; +using protobuf_test_messages::proto3::TestAllTypes; using std::string; static const char kTypeUrlPrefix[] = "type.googleapis.com"; diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m index 1124bfeb..ef037f84 100644 --- a/conformance/conformance_objc.m +++ b/conformance/conformance_objc.m @@ -31,6 +31,7 @@ #import <Foundation/Foundation.h> #import "Conformance.pbobjc.h" +#import "google/protobuf/TestMessagesProto3.pbobjc.h" static void Die(NSString *format, ...) __dead2; diff --git a/conformance/conformance_python.py b/conformance/conformance_python.py index 2f4a7812..7ace9b16 100755 --- a/conformance/conformance_python.py +++ b/conformance/conformance_python.py @@ -38,8 +38,9 @@ See conformance.proto for more information. import struct import sys import os -from google.protobuf import message from google.protobuf import json_format +from google.protobuf import message +from google.protobuf import test_messages_proto3_pb2 import conformance_pb2 sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) @@ -52,9 +53,9 @@ class ProtocolError(Exception): pass def do_test(request): - test_message = conformance_pb2.TestAllTypes() + test_message = test_messages_proto3_pb2.TestAllTypes() response = conformance_pb2.ConformanceResponse() - test_message = conformance_pb2.TestAllTypes() + test_message = test_messages_proto3_pb2.TestAllTypes() try: if request.WhichOneof('payload') == 'protobuf_payload': diff --git a/conformance/conformance_ruby.rb b/conformance/conformance_ruby.rb index aa572144..b7b7cf1c 100755 --- a/conformance/conformance_ruby.rb +++ b/conformance/conformance_ruby.rb @@ -31,20 +31,21 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require 'conformance_pb' +require 'google/protobuf/test_messages_proto3_pb' $test_count = 0 $verbose = false def do_test(request) - test_message = Conformance::TestAllTypes.new + test_message = ProtobufTestMessages::Proto3::TestAllTypes.new response = Conformance::ConformanceResponse.new begin case request.payload when :protobuf_payload begin - test_message = - Conformance::TestAllTypes.decode(request.protobuf_payload) + test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode( + request.protobuf_payload) rescue Google::Protobuf::ParseError => err response.parse_error = err.message.encode('utf-8') return response @@ -52,7 +53,8 @@ def do_test(request) when :json_payload begin - test_message = Conformance::TestAllTypes.decode_json(request.json_payload) + test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json( + request.json_payload) rescue Google::Protobuf::ParseError => err response.parse_error = err.message.encode('utf-8') return response diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index b74122c6..d162f4ea 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -34,11 +34,13 @@ #include "conformance.pb.h" #include "conformance_test.h" +#include "google/protobuf/test_messages_proto3.pb.h" + #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/text_format.h> -#include <google/protobuf/util/json_util.h> #include <google/protobuf/util/field_comparator.h> +#include <google/protobuf/util/json_util.h> #include <google/protobuf/util/message_differencer.h> #include <google/protobuf/util/type_resolver_util.h> #include <google/protobuf/wire_format_lite.h> @@ -47,7 +49,6 @@ using conformance::ConformanceRequest; using conformance::ConformanceResponse; -using conformance::TestAllTypes; using conformance::WireFormat; using google::protobuf::Descriptor; using google::protobuf::FieldDescriptor; @@ -58,6 +59,7 @@ using google::protobuf::util::JsonToBinaryString; using google::protobuf::util::MessageDifferencer; using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::Status; +using protobuf_test_messages::proto3::TestAllTypes; using std::string; namespace { @@ -685,7 +687,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, R"({ "fieldname1": 1, "fieldName2": 2, - "fieldName3": 3, + "FieldName3": 3, "fieldName4": 4 })", R"( @@ -725,12 +727,12 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, RunValidJsonTest( "FieldNameWithDoubleUnderscores", RECOMMENDED, R"({ - "fieldName13": 13, - "fieldName14": 14, + "FieldName13": 13, + "FieldName14": 14, "fieldName15": 15, "fieldName16": 16, "fieldName17": 17, - "fieldName18": 18 + "FieldName18": 18 })", R"( __field_name13: 13 @@ -873,21 +875,19 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "optionalNestedMessage": {a: 1}, "optional_nested_message": {} })"); - // NOTE: The spec for JSON support is still being sorted out, these may not - // all be correct. // Serializers should use lowerCamelCase by default. RunValidJsonTestWithValidator( "FieldNameInLowerCamelCase", REQUIRED, R"({ "fieldname1": 1, "fieldName2": 2, - "fieldName3": 3, + "FieldName3": 3, "fieldName4": 4 })", [](const Json::Value& value) { return value.isMember("fieldname1") && value.isMember("fieldName2") && - value.isMember("fieldName3") && + value.isMember("FieldName3") && value.isMember("fieldName4"); }); RunValidJsonTestWithValidator( @@ -921,20 +921,20 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, RunValidJsonTestWithValidator( "FieldNameWithDoubleUnderscores", RECOMMENDED, R"({ - "fieldName13": 13, - "fieldName14": 14, + "FieldName13": 13, + "FieldName14": 14, "fieldName15": 15, "fieldName16": 16, "fieldName17": 17, - "fieldName18": 18 + "FieldName18": 18 })", [](const Json::Value& value) { - return value.isMember("fieldName13") && - value.isMember("fieldName14") && + return value.isMember("FieldName13") && + value.isMember("FieldName14") && value.isMember("fieldName15") && value.isMember("fieldName16") && value.isMember("fieldName17") && - value.isMember("fieldName18"); + value.isMember("FieldName18"); }); // Integer fields. @@ -2042,13 +2042,13 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "Any", REQUIRED, R"({ "optionalAny": { - "@type": "type.googleapis.com/conformance.TestAllTypes", + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes", "optionalInt32": 12345 } })", R"( optional_any: { - [type.googleapis.com/conformance.TestAllTypes] { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] { optional_int32: 12345 } } @@ -2059,7 +2059,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "optionalAny": { "@type": "type.googleapis.com/google.protobuf.Any", "value": { - "@type": "type.googleapis.com/conformance.TestAllTypes", + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes", "optionalInt32": 12345 } } @@ -2067,7 +2067,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, R"( optional_any: { [type.googleapis.com/google.protobuf.Any] { - [type.googleapis.com/conformance.TestAllTypes] { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] { optional_int32: 12345 } } @@ -2079,12 +2079,12 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, R"({ "optionalAny": { "optionalInt32": 12345, - "@type": "type.googleapis.com/conformance.TestAllTypes" + "@type": "type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes" } })", R"( optional_any: { - [type.googleapis.com/conformance.TestAllTypes] { + [type.googleapis.com/protobuf_test_messages.proto3.TestAllTypes] { optional_int32: 12345 } } diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h index 08f16b8f..2c5994b0 100644 --- a/conformance/conformance_test.h +++ b/conformance/conformance_test.h @@ -49,9 +49,14 @@ namespace conformance { class ConformanceRequest; class ConformanceResponse; -class TestAllTypes; } // namespace conformance +namespace protobuf_test_messages { +namespace proto3 { +class TestAllTypes; +} // namespace proto3 +} // namespace protobuf_test_messages + namespace google { namespace protobuf { @@ -165,14 +170,16 @@ class ConformanceTestSuite { ConformanceLevel level, const string& input_json, const string& equivalent_text_format); - void RunValidJsonTestWithProtobufInput(const string& test_name, - ConformanceLevel level, - const conformance::TestAllTypes& input, - const string& equivalent_text_format); - void RunValidProtobufTest(const string& test_name, - ConformanceLevel level, - const conformance::TestAllTypes& input, - const string& equivalent_text_format); + void RunValidJsonTestWithProtobufInput( + const string& test_name, + ConformanceLevel level, + const protobuf_test_messages::proto3::TestAllTypes& input, + const string& equivalent_text_format); + void RunValidProtobufTest( + const string& test_name, + ConformanceLevel level, + const protobuf_test_messages::proto3::TestAllTypes& input, + const string& equivalent_text_format); typedef std::function<bool(const Json::Value&)> Validator; void RunValidJsonTestWithValidator(const string& test_name, diff --git a/conformance/failure_list_cpp.txt b/conformance/failure_list_cpp.txt index 508be506..8cfd74da 100644 --- a/conformance/failure_list_cpp.txt +++ b/conformance/failure_list_cpp.txt @@ -17,9 +17,6 @@ Recommended.JsonInput.FieldNameDuplicate Recommended.JsonInput.FieldNameDuplicateDifferentCasing1 Recommended.JsonInput.FieldNameDuplicateDifferentCasing2 Recommended.JsonInput.FieldNameNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator Recommended.JsonInput.MapFieldValueIsNull Recommended.JsonInput.RepeatedFieldMessageElementIsNull Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull @@ -35,10 +32,6 @@ Recommended.JsonInput.TrailingCommaInAnObject Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines Recommended.JsonInput.TrailingCommaInAnObjectWithSpace Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace -Required.JsonInput.DoubleFieldTooSmall -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE diff --git a/conformance/failure_list_csharp.txt b/conformance/failure_list_csharp.txt index a43519cd..e69de29b 100644 --- a/conformance/failure_list_csharp.txt +++ b/conformance/failure_list_csharp.txt @@ -1,6 +0,0 @@ -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput diff --git a/conformance/failure_list_java.txt b/conformance/failure_list_java.txt index c9007d68..632940ef 100644 --- a/conformance/failure_list_java.txt +++ b/conformance/failure_list_java.txt @@ -20,9 +20,6 @@ Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.JsonInput.FieldMaskInvalidCharacter Recommended.JsonInput.FieldNameDuplicate Recommended.JsonInput.FieldNameNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted @@ -38,12 +35,11 @@ Recommended.JsonInput.StringFieldUnpairedLowSurrogate Recommended.JsonInput.Uint32MapFieldKeyNotQuoted Recommended.JsonInput.Uint64MapFieldKeyNotQuoted Required.JsonInput.EnumFieldNotQuoted -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.JsonInput.Int32FieldLeadingZero Required.JsonInput.Int32FieldNegativeWithLeadingZero Required.JsonInput.Int32FieldPlusSign Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt Required.JsonInput.StringFieldNotAString +Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE +Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt index 04985199..9d556a03 100644 --- a/conformance/failure_list_python.txt +++ b/conformance/failure_list_python.txt @@ -1,18 +1,12 @@ Recommended.JsonInput.DoubleFieldInfinityNotQuoted Recommended.JsonInput.DoubleFieldNanNotQuoted Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted Required.JsonInput.BytesFieldInvalidBase64Characters Required.JsonInput.DoubleFieldTooSmall Required.JsonInput.EnumFieldUnknownValue.Validator -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.JsonInput.FloatFieldTooLarge Required.JsonInput.FloatFieldTooSmall Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt index f3958f5f..92404d2f 100644 --- a/conformance/failure_list_python_cpp.txt +++ b/conformance/failure_list_python_cpp.txt @@ -10,18 +10,12 @@ Recommended.JsonInput.DoubleFieldInfinityNotQuoted Recommended.JsonInput.DoubleFieldNanNotQuoted Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted Required.JsonInput.BytesFieldInvalidBase64Characters Required.JsonInput.DoubleFieldTooSmall Required.JsonInput.EnumFieldUnknownValue.Validator -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.JsonInput.FloatFieldTooLarge Required.JsonInput.FloatFieldTooSmall Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt index dbd55697..1de6c439 100644 --- a/conformance/failure_list_ruby.txt +++ b/conformance/failure_list_ruby.txt @@ -7,9 +7,6 @@ Recommended.JsonInput.DurationHas3FractionalDigits.Validator Recommended.JsonInput.DurationHas6FractionalDigits.Validator Recommended.JsonInput.DurationHas9FractionalDigits.Validator Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator -Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput -Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator Recommended.JsonInput.Int64FieldBeString.Validator Recommended.JsonInput.OneofZeroDouble.JsonOutput Recommended.JsonInput.OneofZeroDouble.ProtobufOutput @@ -80,9 +77,6 @@ Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput Required.JsonInput.EnumFieldUnknownValue.Validator Required.JsonInput.FieldMask.JsonOutput Required.JsonInput.FieldMask.ProtobufOutput -Required.JsonInput.FieldNameInLowerCamelCase.Validator -Required.JsonInput.FieldNameInSnakeCase.JsonOutput -Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput Required.JsonInput.FloatFieldInfinity.JsonOutput Required.JsonInput.FloatFieldInfinity.ProtobufOutput Required.JsonInput.FloatFieldNan.JsonOutput diff --git a/csharp/generate_protos.sh b/csharp/generate_protos.sh index d979aa52..7cbcf436 100755 --- a/csharp/generate_protos.sh +++ b/csharp/generate_protos.sh @@ -54,6 +54,11 @@ $PROTOC -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \ --csharp_opt=base_namespace=UnitTest.Issues \ csharp/protos/unittest_issues.proto +# Don't specify a base namespace at all; we just want to make sure the +# results end up in TestProtos. +$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \ + src/google/protobuf/test_messages_proto3.proto + # AddressBook sample protos $PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \ examples/addressbook.proto diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs index 431ac4fb..a19f15e4 100644 --- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs +++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs @@ -22,182 +22,22 @@ namespace Conformance { static ConformanceReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UaGWdvb2dsZS9wcm90", - "b2J1Zi9hbnkucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi9kdXJhdGlvbi5wcm90", - "bxogZ29vZ2xlL3Byb3RvYnVmL2ZpZWxkX21hc2sucHJvdG8aHGdvb2dsZS9w", - "cm90b2J1Zi9zdHJ1Y3QucHJvdG8aH2dvb2dsZS9wcm90b2J1Zi90aW1lc3Rh", - "bXAucHJvdG8aHmdvb2dsZS9wcm90b2J1Zi93cmFwcGVycy5wcm90byKNAQoS", - "Q29uZm9ybWFuY2VSZXF1ZXN0EhoKEHByb3RvYnVmX3BheWxvYWQYASABKAxI", - "ABIWCgxqc29uX3BheWxvYWQYAiABKAlIABI4ChdyZXF1ZXN0ZWRfb3V0cHV0", - "X2Zvcm1hdBgDIAEoDjIXLmNvbmZvcm1hbmNlLldpcmVGb3JtYXRCCQoHcGF5", - "bG9hZCKxAQoTQ29uZm9ybWFuY2VSZXNwb25zZRIVCgtwYXJzZV9lcnJvchgB", - "IAEoCUgAEhkKD3NlcmlhbGl6ZV9lcnJvchgGIAEoCUgAEhcKDXJ1bnRpbWVf", - "ZXJyb3IYAiABKAlIABIaChBwcm90b2J1Zl9wYXlsb2FkGAMgASgMSAASFgoM", - "anNvbl9wYXlsb2FkGAQgASgJSAASEQoHc2tpcHBlZBgFIAEoCUgAQggKBnJl", - "c3VsdCKCNQoMVGVzdEFsbFR5cGVzEhYKDm9wdGlvbmFsX2ludDMyGAEgASgF", - "EhYKDm9wdGlvbmFsX2ludDY0GAIgASgDEhcKD29wdGlvbmFsX3VpbnQzMhgD", - "IAEoDRIXCg9vcHRpb25hbF91aW50NjQYBCABKAQSFwoPb3B0aW9uYWxfc2lu", - "dDMyGAUgASgREhcKD29wdGlvbmFsX3NpbnQ2NBgGIAEoEhIYChBvcHRpb25h", - "bF9maXhlZDMyGAcgASgHEhgKEG9wdGlvbmFsX2ZpeGVkNjQYCCABKAYSGQoR", - "b3B0aW9uYWxfc2ZpeGVkMzIYCSABKA8SGQoRb3B0aW9uYWxfc2ZpeGVkNjQY", - "CiABKBASFgoOb3B0aW9uYWxfZmxvYXQYCyABKAISFwoPb3B0aW9uYWxfZG91", - "YmxlGAwgASgBEhUKDW9wdGlvbmFsX2Jvb2wYDSABKAgSFwoPb3B0aW9uYWxf", - "c3RyaW5nGA4gASgJEhYKDm9wdGlvbmFsX2J5dGVzGA8gASgMEkgKF29wdGlv", - "bmFsX25lc3RlZF9tZXNzYWdlGBIgASgLMicuY29uZm9ybWFuY2UuVGVzdEFs", - "bFR5cGVzLk5lc3RlZE1lc3NhZ2USPQoYb3B0aW9uYWxfZm9yZWlnbl9tZXNz", - "YWdlGBMgASgLMhsuY29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUb3B0", - "aW9uYWxfbmVzdGVkX2VudW0YFSABKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxs", - "VHlwZXMuTmVzdGVkRW51bRI3ChVvcHRpb25hbF9mb3JlaWduX2VudW0YFiAB", - "KA4yGC5jb25mb3JtYW5jZS5Gb3JlaWduRW51bRIhChVvcHRpb25hbF9zdHJp", - "bmdfcGllY2UYGCABKAlCAggCEhkKDW9wdGlvbmFsX2NvcmQYGSABKAlCAggB", - "EjQKEXJlY3Vyc2l2ZV9tZXNzYWdlGBsgASgLMhkuY29uZm9ybWFuY2UuVGVz", - "dEFsbFR5cGVzEhYKDnJlcGVhdGVkX2ludDMyGB8gAygFEhYKDnJlcGVhdGVk", - "X2ludDY0GCAgAygDEhcKD3JlcGVhdGVkX3VpbnQzMhghIAMoDRIXCg9yZXBl", - "YXRlZF91aW50NjQYIiADKAQSFwoPcmVwZWF0ZWRfc2ludDMyGCMgAygREhcK", - "D3JlcGVhdGVkX3NpbnQ2NBgkIAMoEhIYChByZXBlYXRlZF9maXhlZDMyGCUg", - "AygHEhgKEHJlcGVhdGVkX2ZpeGVkNjQYJiADKAYSGQoRcmVwZWF0ZWRfc2Zp", - "eGVkMzIYJyADKA8SGQoRcmVwZWF0ZWRfc2ZpeGVkNjQYKCADKBASFgoOcmVw", - "ZWF0ZWRfZmxvYXQYKSADKAISFwoPcmVwZWF0ZWRfZG91YmxlGCogAygBEhUK", - "DXJlcGVhdGVkX2Jvb2wYKyADKAgSFwoPcmVwZWF0ZWRfc3RyaW5nGCwgAygJ", - "EhYKDnJlcGVhdGVkX2J5dGVzGC0gAygMEkgKF3JlcGVhdGVkX25lc3RlZF9t", - "ZXNzYWdlGDAgAygLMicuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3Rl", - "ZE1lc3NhZ2USPQoYcmVwZWF0ZWRfZm9yZWlnbl9tZXNzYWdlGDEgAygLMhsu", - "Y29uZm9ybWFuY2UuRm9yZWlnbk1lc3NhZ2USQgoUcmVwZWF0ZWRfbmVzdGVk", - "X2VudW0YMyADKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTmVzdGVk", - "RW51bRI3ChVyZXBlYXRlZF9mb3JlaWduX2VudW0YNCADKA4yGC5jb25mb3Jt", - "YW5jZS5Gb3JlaWduRW51bRIhChVyZXBlYXRlZF9zdHJpbmdfcGllY2UYNiAD", - "KAlCAggCEhkKDXJlcGVhdGVkX2NvcmQYNyADKAlCAggBEkUKD21hcF9pbnQz", - "Ml9pbnQzMhg4IAMoCzIsLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBJ", - "bnQzMkludDMyRW50cnkSRQoPbWFwX2ludDY0X2ludDY0GDkgAygLMiwuY29u", - "Zm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEludDY0SW50NjRFbnRyeRJJChFt", - "YXBfdWludDMyX3VpbnQzMhg6IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBVaW50MzJVaW50MzJFbnRyeRJJChFtYXBfdWludDY0X3VpbnQ2", - "NBg7IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBVaW50NjRV", - "aW50NjRFbnRyeRJJChFtYXBfc2ludDMyX3NpbnQzMhg8IAMoCzIuLmNvbmZv", - "cm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBTaW50MzJTaW50MzJFbnRyeRJJChFt", - "YXBfc2ludDY0X3NpbnQ2NBg9IAMoCzIuLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBTaW50NjRTaW50NjRFbnRyeRJNChNtYXBfZml4ZWQzMl9maXhl", - "ZDMyGD4gAygLMjAuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk1hcEZpeGVk", - "MzJGaXhlZDMyRW50cnkSTQoTbWFwX2ZpeGVkNjRfZml4ZWQ2NBg/IAMoCzIw", - "LmNvbmZvcm1hbmNlLlRlc3RBbGxUeXBlcy5NYXBGaXhlZDY0Rml4ZWQ2NEVu", - "dHJ5ElEKFW1hcF9zZml4ZWQzMl9zZml4ZWQzMhhAIAMoCzIyLmNvbmZvcm1h", - "bmNlLlRlc3RBbGxUeXBlcy5NYXBTZml4ZWQzMlNmaXhlZDMyRW50cnkSUQoV", - "bWFwX3NmaXhlZDY0X3NmaXhlZDY0GEEgAygLMjIuY29uZm9ybWFuY2UuVGVz", - "dEFsbFR5cGVzLk1hcFNmaXhlZDY0U2ZpeGVkNjRFbnRyeRJFCg9tYXBfaW50", - "MzJfZmxvYXQYQiADKAsyLC5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFw", - "SW50MzJGbG9hdEVudHJ5EkcKEG1hcF9pbnQzMl9kb3VibGUYQyADKAsyLS5j", - "b25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwSW50MzJEb3VibGVFbnRyeRJB", - "Cg1tYXBfYm9vbF9ib29sGEQgAygLMiouY29uZm9ybWFuY2UuVGVzdEFsbFR5", - "cGVzLk1hcEJvb2xCb29sRW50cnkSSQoRbWFwX3N0cmluZ19zdHJpbmcYRSAD", - "KAsyLi5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nU3RyaW5n", - "RW50cnkSRwoQbWFwX3N0cmluZ19ieXRlcxhGIAMoCzItLmNvbmZvcm1hbmNl", - "LlRlc3RBbGxUeXBlcy5NYXBTdHJpbmdCeXRlc0VudHJ5ElgKGW1hcF9zdHJp", - "bmdfbmVzdGVkX21lc3NhZ2UYRyADKAsyNS5jb25mb3JtYW5jZS5UZXN0QWxs", - "VHlwZXMuTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EloKGm1hcF9zdHJp", - "bmdfZm9yZWlnbl9tZXNzYWdlGEggAygLMjYuY29uZm9ybWFuY2UuVGVzdEFs", - "bFR5cGVzLk1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSUgoWbWFwX3N0", - "cmluZ19uZXN0ZWRfZW51bRhJIAMoCzIyLmNvbmZvcm1hbmNlLlRlc3RBbGxU", - "eXBlcy5NYXBTdHJpbmdOZXN0ZWRFbnVtRW50cnkSVAoXbWFwX3N0cmluZ19m", - "b3JlaWduX2VudW0YSiADKAsyMy5jb25mb3JtYW5jZS5UZXN0QWxsVHlwZXMu", - "TWFwU3RyaW5nRm9yZWlnbkVudW1FbnRyeRIWCgxvbmVvZl91aW50MzIYbyAB", - "KA1IABJHChRvbmVvZl9uZXN0ZWRfbWVzc2FnZRhwIAEoCzInLmNvbmZvcm1h", - "bmNlLlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlSAASFgoMb25lb2Zfc3Ry", - "aW5nGHEgASgJSAASFQoLb25lb2ZfYnl0ZXMYciABKAxIABIUCgpvbmVvZl9i", - "b29sGHMgASgISAASFgoMb25lb2ZfdWludDY0GHQgASgESAASFQoLb25lb2Zf", - "ZmxvYXQYdSABKAJIABIWCgxvbmVvZl9kb3VibGUYdiABKAFIABI6CgpvbmVv", - "Zl9lbnVtGHcgASgOMiQuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3Rl", - "ZEVudW1IABI6ChVvcHRpb25hbF9ib29sX3dyYXBwZXIYyQEgASgLMhouZ29v", - "Z2xlLnByb3RvYnVmLkJvb2xWYWx1ZRI8ChZvcHRpb25hbF9pbnQzMl93cmFw", - "cGVyGMoBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQzMlZhbHVlEjwKFm9w", - "dGlvbmFsX2ludDY0X3dyYXBwZXIYywEgASgLMhsuZ29vZ2xlLnByb3RvYnVm", - "LkludDY0VmFsdWUSPgoXb3B0aW9uYWxfdWludDMyX3dyYXBwZXIYzAEgASgL", - "MhwuZ29vZ2xlLnByb3RvYnVmLlVJbnQzMlZhbHVlEj4KF29wdGlvbmFsX3Vp", - "bnQ2NF93cmFwcGVyGM0BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50NjRW", - "YWx1ZRI8ChZvcHRpb25hbF9mbG9hdF93cmFwcGVyGM4BIAEoCzIbLmdvb2ds", - "ZS5wcm90b2J1Zi5GbG9hdFZhbHVlEj4KF29wdGlvbmFsX2RvdWJsZV93cmFw", - "cGVyGM8BIAEoCzIcLmdvb2dsZS5wcm90b2J1Zi5Eb3VibGVWYWx1ZRI+Chdv", - "cHRpb25hbF9zdHJpbmdfd3JhcHBlchjQASABKAsyHC5nb29nbGUucHJvdG9i", - "dWYuU3RyaW5nVmFsdWUSPAoWb3B0aW9uYWxfYnl0ZXNfd3JhcHBlchjRASAB", - "KAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRI6ChVyZXBlYXRlZF9i", - "b29sX3dyYXBwZXIY0wEgAygLMhouZ29vZ2xlLnByb3RvYnVmLkJvb2xWYWx1", - "ZRI8ChZyZXBlYXRlZF9pbnQzMl93cmFwcGVyGNQBIAMoCzIbLmdvb2dsZS5w", - "cm90b2J1Zi5JbnQzMlZhbHVlEjwKFnJlcGVhdGVkX2ludDY0X3dyYXBwZXIY", - "1QEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkludDY0VmFsdWUSPgoXcmVwZWF0", - "ZWRfdWludDMyX3dyYXBwZXIY1gEgAygLMhwuZ29vZ2xlLnByb3RvYnVmLlVJ", - "bnQzMlZhbHVlEj4KF3JlcGVhdGVkX3VpbnQ2NF93cmFwcGVyGNcBIAMoCzIc", - "Lmdvb2dsZS5wcm90b2J1Zi5VSW50NjRWYWx1ZRI8ChZyZXBlYXRlZF9mbG9h", - "dF93cmFwcGVyGNgBIAMoCzIbLmdvb2dsZS5wcm90b2J1Zi5GbG9hdFZhbHVl", - "Ej4KF3JlcGVhdGVkX2RvdWJsZV93cmFwcGVyGNkBIAMoCzIcLmdvb2dsZS5w", - "cm90b2J1Zi5Eb3VibGVWYWx1ZRI+ChdyZXBlYXRlZF9zdHJpbmdfd3JhcHBl", - "chjaASADKAsyHC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUSPAoWcmVw", - "ZWF0ZWRfYnl0ZXNfd3JhcHBlchjbASADKAsyGy5nb29nbGUucHJvdG9idWYu", - "Qnl0ZXNWYWx1ZRI1ChFvcHRpb25hbF9kdXJhdGlvbhitAiABKAsyGS5nb29n", - "bGUucHJvdG9idWYuRHVyYXRpb24SNwoSb3B0aW9uYWxfdGltZXN0YW1wGK4C", - "IAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASOAoTb3B0aW9uYWxf", - "ZmllbGRfbWFzaxivAiABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNr", - "EjEKD29wdGlvbmFsX3N0cnVjdBiwAiABKAsyFy5nb29nbGUucHJvdG9idWYu", - "U3RydWN0EisKDG9wdGlvbmFsX2FueRixAiABKAsyFC5nb29nbGUucHJvdG9i", - "dWYuQW55Ei8KDm9wdGlvbmFsX3ZhbHVlGLICIAEoCzIWLmdvb2dsZS5wcm90", - "b2J1Zi5WYWx1ZRI1ChFyZXBlYXRlZF9kdXJhdGlvbhi3AiADKAsyGS5nb29n", - "bGUucHJvdG9idWYuRHVyYXRpb24SNwoScmVwZWF0ZWRfdGltZXN0YW1wGLgC", - "IAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASNwoScmVwZWF0ZWRf", - "ZmllbGRtYXNrGLkCIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2sS", - "MQoPcmVwZWF0ZWRfc3RydWN0GMQCIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5T", - "dHJ1Y3QSKwoMcmVwZWF0ZWRfYW55GLsCIAMoCzIULmdvb2dsZS5wcm90b2J1", - "Zi5BbnkSLwoOcmVwZWF0ZWRfdmFsdWUYvAIgAygLMhYuZ29vZ2xlLnByb3Rv", - "YnVmLlZhbHVlEhMKCmZpZWxkbmFtZTEYkQMgASgFEhQKC2ZpZWxkX25hbWUy", - "GJIDIAEoBRIVCgxfZmllbGRfbmFtZTMYkwMgASgFEhYKDWZpZWxkX19uYW1l", - "NF8YlAMgASgFEhQKC2ZpZWxkMG5hbWU1GJUDIAEoBRIWCg1maWVsZF8wX25h", - "bWU2GJYDIAEoBRITCgpmaWVsZE5hbWU3GJcDIAEoBRITCgpGaWVsZE5hbWU4", - "GJgDIAEoBRIUCgtmaWVsZF9OYW1lORiZAyABKAUSFQoMRmllbGRfTmFtZTEw", - "GJoDIAEoBRIVCgxGSUVMRF9OQU1FMTEYmwMgASgFEhUKDEZJRUxEX25hbWUx", - "MhicAyABKAUSFwoOX19maWVsZF9uYW1lMTMYnQMgASgFEhcKDl9fRmllbGRf", - "bmFtZTE0GJ4DIAEoBRIWCg1maWVsZF9fbmFtZTE1GJ8DIAEoBRIWCg1maWVs", - "ZF9fTmFtZTE2GKADIAEoBRIXCg5maWVsZF9uYW1lMTdfXxihAyABKAUSFwoO", - "RmllbGRfbmFtZTE4X18YogMgASgFGkoKDU5lc3RlZE1lc3NhZ2USCQoBYRgB", - "IAEoBRIuCgtjb3JlY3Vyc2l2ZRgCIAEoCzIZLmNvbmZvcm1hbmNlLlRlc3RB", - "bGxUeXBlcxo0ChJNYXBJbnQzMkludDMyRW50cnkSCwoDa2V5GAEgASgFEg0K", - "BXZhbHVlGAIgASgFOgI4ARo0ChJNYXBJbnQ2NEludDY0RW50cnkSCwoDa2V5", - "GAEgASgDEg0KBXZhbHVlGAIgASgDOgI4ARo2ChRNYXBVaW50MzJVaW50MzJF", - "bnRyeRILCgNrZXkYASABKA0SDQoFdmFsdWUYAiABKA06AjgBGjYKFE1hcFVp", - "bnQ2NFVpbnQ2NEVudHJ5EgsKA2tleRgBIAEoBBINCgV2YWx1ZRgCIAEoBDoC", - "OAEaNgoUTWFwU2ludDMyU2ludDMyRW50cnkSCwoDa2V5GAEgASgREg0KBXZh", - "bHVlGAIgASgROgI4ARo2ChRNYXBTaW50NjRTaW50NjRFbnRyeRILCgNrZXkY", - "ASABKBISDQoFdmFsdWUYAiABKBI6AjgBGjgKFk1hcEZpeGVkMzJGaXhlZDMy", - "RW50cnkSCwoDa2V5GAEgASgHEg0KBXZhbHVlGAIgASgHOgI4ARo4ChZNYXBG", - "aXhlZDY0Rml4ZWQ2NEVudHJ5EgsKA2tleRgBIAEoBhINCgV2YWx1ZRgCIAEo", - "BjoCOAEaOgoYTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5EgsKA2tleRgBIAEo", - "DxINCgV2YWx1ZRgCIAEoDzoCOAEaOgoYTWFwU2ZpeGVkNjRTZml4ZWQ2NEVu", - "dHJ5EgsKA2tleRgBIAEoEBINCgV2YWx1ZRgCIAEoEDoCOAEaNAoSTWFwSW50", - "MzJGbG9hdEVudHJ5EgsKA2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAjoCOAEa", - "NQoTTWFwSW50MzJEb3VibGVFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUY", - "AiABKAE6AjgBGjIKEE1hcEJvb2xCb29sRW50cnkSCwoDa2V5GAEgASgIEg0K", - "BXZhbHVlGAIgASgIOgI4ARo2ChRNYXBTdHJpbmdTdHJpbmdFbnRyeRILCgNr", - "ZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBGjUKE01hcFN0cmluZ0J5dGVz", - "RW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgMOgI4ARpmChtNYXBT", - "dHJpbmdOZXN0ZWRNZXNzYWdlRW50cnkSCwoDa2V5GAEgASgJEjYKBXZhbHVl", - "GAIgASgLMicuY29uZm9ybWFuY2UuVGVzdEFsbFR5cGVzLk5lc3RlZE1lc3Nh", - "Z2U6AjgBGlsKHE1hcFN0cmluZ0ZvcmVpZ25NZXNzYWdlRW50cnkSCwoDa2V5", - "GAEgASgJEioKBXZhbHVlGAIgASgLMhsuY29uZm9ybWFuY2UuRm9yZWlnbk1l", - "c3NhZ2U6AjgBGmAKGE1hcFN0cmluZ05lc3RlZEVudW1FbnRyeRILCgNrZXkY", - "ASABKAkSMwoFdmFsdWUYAiABKA4yJC5jb25mb3JtYW5jZS5UZXN0QWxsVHlw", - "ZXMuTmVzdGVkRW51bToCOAEaVQoZTWFwU3RyaW5nRm9yZWlnbkVudW1FbnRy", - "eRILCgNrZXkYASABKAkSJwoFdmFsdWUYAiABKA4yGC5jb25mb3JtYW5jZS5G", - "b3JlaWduRW51bToCOAEiOQoKTmVzdGVkRW51bRIHCgNGT08QABIHCgNCQVIQ", - "ARIHCgNCQVoQAhIQCgNORUcQ////////////AUINCgtvbmVvZl9maWVsZCIb", - "Cg5Gb3JlaWduTWVzc2FnZRIJCgFjGAEgASgFKjUKCldpcmVGb3JtYXQSDwoL", - "VU5TUEVDSUZJRUQQABIMCghQUk9UT0JVRhABEggKBEpTT04QAipACgtGb3Jl", - "aWduRW51bRIPCgtGT1JFSUdOX0ZPTxAAEg8KC0ZPUkVJR05fQkFSEAESDwoL", - "Rk9SRUlHTl9CQVoQAkIhCh9jb20uZ29vZ2xlLnByb3RvYnVmLmNvbmZvcm1h", - "bmNlYgZwcm90bzM=")); + "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UijQEKEkNvbmZvcm1h", + "bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv", + "bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY", + "AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0QgkKB3BheWxvYWQisQEK", + "E0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZ", + "Cg9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIg", + "ASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5", + "bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoK", + "V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE", + "SlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFuY2ViBnBy", + "b3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), typeof(global::Conformance.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat" }, new[]{ "Payload" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes), global::Conformance.TestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::Conformance.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.TestAllTypes.Types.NestedMessage), global::Conformance.TestAllTypes.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null), - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), - new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ForeignMessage), global::Conformance.ForeignMessage.Parser, new[]{ "C" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null) })); } #endregion @@ -210,12 +50,6 @@ namespace Conformance { [pbr::OriginalName("JSON")] Json = 2, } - public enum ForeignEnum { - [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0, - [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1, - [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2, - } - #endregion #region Messages @@ -765,3464 +599,6 @@ namespace Conformance { } - /// <summary> - /// This proto includes every type of field in both singular and repeated - /// forms. - /// </summary> - public sealed partial class TestAllTypes : pb::IMessage<TestAllTypes> { - private static readonly pb::MessageParser<TestAllTypes> _parser = new pb::MessageParser<TestAllTypes>(() => new TestAllTypes()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser<TestAllTypes> Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public TestAllTypes() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public TestAllTypes(TestAllTypes other) : this() { - optionalInt32_ = other.optionalInt32_; - optionalInt64_ = other.optionalInt64_; - optionalUint32_ = other.optionalUint32_; - optionalUint64_ = other.optionalUint64_; - optionalSint32_ = other.optionalSint32_; - optionalSint64_ = other.optionalSint64_; - optionalFixed32_ = other.optionalFixed32_; - optionalFixed64_ = other.optionalFixed64_; - optionalSfixed32_ = other.optionalSfixed32_; - optionalSfixed64_ = other.optionalSfixed64_; - optionalFloat_ = other.optionalFloat_; - optionalDouble_ = other.optionalDouble_; - optionalBool_ = other.optionalBool_; - optionalString_ = other.optionalString_; - optionalBytes_ = other.optionalBytes_; - OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null; - OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null; - optionalNestedEnum_ = other.optionalNestedEnum_; - optionalForeignEnum_ = other.optionalForeignEnum_; - optionalStringPiece_ = other.optionalStringPiece_; - optionalCord_ = other.optionalCord_; - RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null; - repeatedInt32_ = other.repeatedInt32_.Clone(); - repeatedInt64_ = other.repeatedInt64_.Clone(); - repeatedUint32_ = other.repeatedUint32_.Clone(); - repeatedUint64_ = other.repeatedUint64_.Clone(); - repeatedSint32_ = other.repeatedSint32_.Clone(); - repeatedSint64_ = other.repeatedSint64_.Clone(); - repeatedFixed32_ = other.repeatedFixed32_.Clone(); - repeatedFixed64_ = other.repeatedFixed64_.Clone(); - repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); - repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); - repeatedFloat_ = other.repeatedFloat_.Clone(); - repeatedDouble_ = other.repeatedDouble_.Clone(); - repeatedBool_ = other.repeatedBool_.Clone(); - repeatedString_ = other.repeatedString_.Clone(); - repeatedBytes_ = other.repeatedBytes_.Clone(); - repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); - repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); - repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); - repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); - repeatedStringPiece_ = other.repeatedStringPiece_.Clone(); - repeatedCord_ = other.repeatedCord_.Clone(); - mapInt32Int32_ = other.mapInt32Int32_.Clone(); - mapInt64Int64_ = other.mapInt64Int64_.Clone(); - mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); - mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); - mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); - mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); - mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); - mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); - mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); - mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); - mapInt32Float_ = other.mapInt32Float_.Clone(); - mapInt32Double_ = other.mapInt32Double_.Clone(); - mapBoolBool_ = other.mapBoolBool_.Clone(); - mapStringString_ = other.mapStringString_.Clone(); - mapStringBytes_ = other.mapStringBytes_.Clone(); - mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone(); - mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone(); - mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone(); - mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone(); - OptionalBoolWrapper = other.OptionalBoolWrapper; - OptionalInt32Wrapper = other.OptionalInt32Wrapper; - OptionalInt64Wrapper = other.OptionalInt64Wrapper; - OptionalUint32Wrapper = other.OptionalUint32Wrapper; - OptionalUint64Wrapper = other.OptionalUint64Wrapper; - OptionalFloatWrapper = other.OptionalFloatWrapper; - OptionalDoubleWrapper = other.OptionalDoubleWrapper; - OptionalStringWrapper = other.OptionalStringWrapper; - OptionalBytesWrapper = other.OptionalBytesWrapper; - repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone(); - repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone(); - repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone(); - repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone(); - repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone(); - repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone(); - repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); - repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); - repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); - OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null; - OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null; - OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null; - OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null; - OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null; - OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null; - repeatedDuration_ = other.repeatedDuration_.Clone(); - repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); - repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); - repeatedStruct_ = other.repeatedStruct_.Clone(); - repeatedAny_ = other.repeatedAny_.Clone(); - repeatedValue_ = other.repeatedValue_.Clone(); - fieldname1_ = other.fieldname1_; - fieldName2_ = other.fieldName2_; - FieldName3_ = other.FieldName3_; - fieldName4_ = other.fieldName4_; - field0Name5_ = other.field0Name5_; - field0Name6_ = other.field0Name6_; - fieldName7_ = other.fieldName7_; - fieldName8_ = other.fieldName8_; - fieldName9_ = other.fieldName9_; - fieldName10_ = other.fieldName10_; - fIELDNAME11_ = other.fIELDNAME11_; - fIELDName12_ = other.fIELDName12_; - FieldName13_ = other.FieldName13_; - FieldName14_ = other.FieldName14_; - fieldName15_ = other.fieldName15_; - fieldName16_ = other.fieldName16_; - fieldName17_ = other.fieldName17_; - fieldName18_ = other.fieldName18_; - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: - OneofUint32 = other.OneofUint32; - break; - case OneofFieldOneofCase.OneofNestedMessage: - OneofNestedMessage = other.OneofNestedMessage.Clone(); - break; - case OneofFieldOneofCase.OneofString: - OneofString = other.OneofString; - break; - case OneofFieldOneofCase.OneofBytes: - OneofBytes = other.OneofBytes; - break; - case OneofFieldOneofCase.OneofBool: - OneofBool = other.OneofBool; - break; - case OneofFieldOneofCase.OneofUint64: - OneofUint64 = other.OneofUint64; - break; - case OneofFieldOneofCase.OneofFloat: - OneofFloat = other.OneofFloat; - break; - case OneofFieldOneofCase.OneofDouble: - OneofDouble = other.OneofDouble; - break; - case OneofFieldOneofCase.OneofEnum: - OneofEnum = other.OneofEnum; - break; - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public TestAllTypes Clone() { - return new TestAllTypes(this); - } - - /// <summary>Field number for the "optional_int32" field.</summary> - public const int OptionalInt32FieldNumber = 1; - private int optionalInt32_; - /// <summary> - /// Singular - /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int OptionalInt32 { - get { return optionalInt32_; } - set { - optionalInt32_ = value; - } - } - - /// <summary>Field number for the "optional_int64" field.</summary> - public const int OptionalInt64FieldNumber = 2; - private long optionalInt64_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long OptionalInt64 { - get { return optionalInt64_; } - set { - optionalInt64_ = value; - } - } - - /// <summary>Field number for the "optional_uint32" field.</summary> - public const int OptionalUint32FieldNumber = 3; - private uint optionalUint32_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public uint OptionalUint32 { - get { return optionalUint32_; } - set { - optionalUint32_ = value; - } - } - - /// <summary>Field number for the "optional_uint64" field.</summary> - public const int OptionalUint64FieldNumber = 4; - private ulong optionalUint64_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ulong OptionalUint64 { - get { return optionalUint64_; } - set { - optionalUint64_ = value; - } - } - - /// <summary>Field number for the "optional_sint32" field.</summary> - public const int OptionalSint32FieldNumber = 5; - private int optionalSint32_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int OptionalSint32 { - get { return optionalSint32_; } - set { - optionalSint32_ = value; - } - } - - /// <summary>Field number for the "optional_sint64" field.</summary> - public const int OptionalSint64FieldNumber = 6; - private long optionalSint64_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long OptionalSint64 { - get { return optionalSint64_; } - set { - optionalSint64_ = value; - } - } - - /// <summary>Field number for the "optional_fixed32" field.</summary> - public const int OptionalFixed32FieldNumber = 7; - private uint optionalFixed32_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public uint OptionalFixed32 { - get { return optionalFixed32_; } - set { - optionalFixed32_ = value; - } - } - - /// <summary>Field number for the "optional_fixed64" field.</summary> - public const int OptionalFixed64FieldNumber = 8; - private ulong optionalFixed64_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ulong OptionalFixed64 { - get { return optionalFixed64_; } - set { - optionalFixed64_ = value; - } - } - - /// <summary>Field number for the "optional_sfixed32" field.</summary> - public const int OptionalSfixed32FieldNumber = 9; - private int optionalSfixed32_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int OptionalSfixed32 { - get { return optionalSfixed32_; } - set { - optionalSfixed32_ = value; - } - } - - /// <summary>Field number for the "optional_sfixed64" field.</summary> - public const int OptionalSfixed64FieldNumber = 10; - private long optionalSfixed64_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long OptionalSfixed64 { - get { return optionalSfixed64_; } - set { - optionalSfixed64_ = value; - } - } - - /// <summary>Field number for the "optional_float" field.</summary> - public const int OptionalFloatFieldNumber = 11; - private float optionalFloat_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public float OptionalFloat { - get { return optionalFloat_; } - set { - optionalFloat_ = value; - } - } - - /// <summary>Field number for the "optional_double" field.</summary> - public const int OptionalDoubleFieldNumber = 12; - private double optionalDouble_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double OptionalDouble { - get { return optionalDouble_; } - set { - optionalDouble_ = value; - } - } - - /// <summary>Field number for the "optional_bool" field.</summary> - public const int OptionalBoolFieldNumber = 13; - private bool optionalBool_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool OptionalBool { - get { return optionalBool_; } - set { - optionalBool_ = value; - } - } - - /// <summary>Field number for the "optional_string" field.</summary> - public const int OptionalStringFieldNumber = 14; - private string optionalString_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OptionalString { - get { return optionalString_; } - set { - optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// <summary>Field number for the "optional_bytes" field.</summary> - public const int OptionalBytesFieldNumber = 15; - private pb::ByteString optionalBytes_ = pb::ByteString.Empty; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pb::ByteString OptionalBytes { - get { return optionalBytes_; } - set { - optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// <summary>Field number for the "optional_nested_message" field.</summary> - public const int OptionalNestedMessageFieldNumber = 18; - private global::Conformance.TestAllTypes.Types.NestedMessage optionalNestedMessage_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes.Types.NestedMessage OptionalNestedMessage { - get { return optionalNestedMessage_; } - set { - optionalNestedMessage_ = value; - } - } - - /// <summary>Field number for the "optional_foreign_message" field.</summary> - public const int OptionalForeignMessageFieldNumber = 19; - private global::Conformance.ForeignMessage optionalForeignMessage_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.ForeignMessage OptionalForeignMessage { - get { return optionalForeignMessage_; } - set { - optionalForeignMessage_ = value; - } - } - - /// <summary>Field number for the "optional_nested_enum" field.</summary> - public const int OptionalNestedEnumFieldNumber = 21; - private global::Conformance.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes.Types.NestedEnum OptionalNestedEnum { - get { return optionalNestedEnum_; } - set { - optionalNestedEnum_ = value; - } - } - - /// <summary>Field number for the "optional_foreign_enum" field.</summary> - public const int OptionalForeignEnumFieldNumber = 22; - private global::Conformance.ForeignEnum optionalForeignEnum_ = 0; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.ForeignEnum OptionalForeignEnum { - get { return optionalForeignEnum_; } - set { - optionalForeignEnum_ = value; - } - } - - /// <summary>Field number for the "optional_string_piece" field.</summary> - public const int OptionalStringPieceFieldNumber = 24; - private string optionalStringPiece_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OptionalStringPiece { - get { return optionalStringPiece_; } - set { - optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// <summary>Field number for the "optional_cord" field.</summary> - public const int OptionalCordFieldNumber = 25; - private string optionalCord_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OptionalCord { - get { return optionalCord_; } - set { - optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// <summary>Field number for the "recursive_message" field.</summary> - public const int RecursiveMessageFieldNumber = 27; - private global::Conformance.TestAllTypes recursiveMessage_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes RecursiveMessage { - get { return recursiveMessage_; } - set { - recursiveMessage_ = value; - } - } - - /// <summary>Field number for the "repeated_int32" field.</summary> - public const int RepeatedInt32FieldNumber = 31; - private static readonly pb::FieldCodec<int> _repeated_repeatedInt32_codec - = pb::FieldCodec.ForInt32(250); - private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>(); - /// <summary> - /// Repeated - /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<int> RepeatedInt32 { - get { return repeatedInt32_; } - } - - /// <summary>Field number for the "repeated_int64" field.</summary> - public const int RepeatedInt64FieldNumber = 32; - private static readonly pb::FieldCodec<long> _repeated_repeatedInt64_codec - = pb::FieldCodec.ForInt64(258); - private readonly pbc::RepeatedField<long> repeatedInt64_ = new pbc::RepeatedField<long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<long> RepeatedInt64 { - get { return repeatedInt64_; } - } - - /// <summary>Field number for the "repeated_uint32" field.</summary> - public const int RepeatedUint32FieldNumber = 33; - private static readonly pb::FieldCodec<uint> _repeated_repeatedUint32_codec - = pb::FieldCodec.ForUInt32(266); - private readonly pbc::RepeatedField<uint> repeatedUint32_ = new pbc::RepeatedField<uint>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<uint> RepeatedUint32 { - get { return repeatedUint32_; } - } - - /// <summary>Field number for the "repeated_uint64" field.</summary> - public const int RepeatedUint64FieldNumber = 34; - private static readonly pb::FieldCodec<ulong> _repeated_repeatedUint64_codec - = pb::FieldCodec.ForUInt64(274); - private readonly pbc::RepeatedField<ulong> repeatedUint64_ = new pbc::RepeatedField<ulong>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<ulong> RepeatedUint64 { - get { return repeatedUint64_; } - } - - /// <summary>Field number for the "repeated_sint32" field.</summary> - public const int RepeatedSint32FieldNumber = 35; - private static readonly pb::FieldCodec<int> _repeated_repeatedSint32_codec - = pb::FieldCodec.ForSInt32(282); - private readonly pbc::RepeatedField<int> repeatedSint32_ = new pbc::RepeatedField<int>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<int> RepeatedSint32 { - get { return repeatedSint32_; } - } - - /// <summary>Field number for the "repeated_sint64" field.</summary> - public const int RepeatedSint64FieldNumber = 36; - private static readonly pb::FieldCodec<long> _repeated_repeatedSint64_codec - = pb::FieldCodec.ForSInt64(290); - private readonly pbc::RepeatedField<long> repeatedSint64_ = new pbc::RepeatedField<long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<long> RepeatedSint64 { - get { return repeatedSint64_; } - } - - /// <summary>Field number for the "repeated_fixed32" field.</summary> - public const int RepeatedFixed32FieldNumber = 37; - private static readonly pb::FieldCodec<uint> _repeated_repeatedFixed32_codec - = pb::FieldCodec.ForFixed32(298); - private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<uint> RepeatedFixed32 { - get { return repeatedFixed32_; } - } - - /// <summary>Field number for the "repeated_fixed64" field.</summary> - public const int RepeatedFixed64FieldNumber = 38; - private static readonly pb::FieldCodec<ulong> _repeated_repeatedFixed64_codec - = pb::FieldCodec.ForFixed64(306); - private readonly pbc::RepeatedField<ulong> repeatedFixed64_ = new pbc::RepeatedField<ulong>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<ulong> RepeatedFixed64 { - get { return repeatedFixed64_; } - } - - /// <summary>Field number for the "repeated_sfixed32" field.</summary> - public const int RepeatedSfixed32FieldNumber = 39; - private static readonly pb::FieldCodec<int> _repeated_repeatedSfixed32_codec - = pb::FieldCodec.ForSFixed32(314); - private readonly pbc::RepeatedField<int> repeatedSfixed32_ = new pbc::RepeatedField<int>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<int> RepeatedSfixed32 { - get { return repeatedSfixed32_; } - } - - /// <summary>Field number for the "repeated_sfixed64" field.</summary> - public const int RepeatedSfixed64FieldNumber = 40; - private static readonly pb::FieldCodec<long> _repeated_repeatedSfixed64_codec - = pb::FieldCodec.ForSFixed64(322); - private readonly pbc::RepeatedField<long> repeatedSfixed64_ = new pbc::RepeatedField<long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<long> RepeatedSfixed64 { - get { return repeatedSfixed64_; } - } - - /// <summary>Field number for the "repeated_float" field.</summary> - public const int RepeatedFloatFieldNumber = 41; - private static readonly pb::FieldCodec<float> _repeated_repeatedFloat_codec - = pb::FieldCodec.ForFloat(330); - private readonly pbc::RepeatedField<float> repeatedFloat_ = new pbc::RepeatedField<float>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<float> RepeatedFloat { - get { return repeatedFloat_; } - } - - /// <summary>Field number for the "repeated_double" field.</summary> - public const int RepeatedDoubleFieldNumber = 42; - private static readonly pb::FieldCodec<double> _repeated_repeatedDouble_codec - = pb::FieldCodec.ForDouble(338); - private readonly pbc::RepeatedField<double> repeatedDouble_ = new pbc::RepeatedField<double>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<double> RepeatedDouble { - get { return repeatedDouble_; } - } - - /// <summary>Field number for the "repeated_bool" field.</summary> - public const int RepeatedBoolFieldNumber = 43; - private static readonly pb::FieldCodec<bool> _repeated_repeatedBool_codec - = pb::FieldCodec.ForBool(346); - private readonly pbc::RepeatedField<bool> repeatedBool_ = new pbc::RepeatedField<bool>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<bool> RepeatedBool { - get { return repeatedBool_; } - } - - /// <summary>Field number for the "repeated_string" field.</summary> - public const int RepeatedStringFieldNumber = 44; - private static readonly pb::FieldCodec<string> _repeated_repeatedString_codec - = pb::FieldCodec.ForString(354); - private readonly pbc::RepeatedField<string> repeatedString_ = new pbc::RepeatedField<string>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<string> RepeatedString { - get { return repeatedString_; } - } - - /// <summary>Field number for the "repeated_bytes" field.</summary> - public const int RepeatedBytesFieldNumber = 45; - private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytes_codec - = pb::FieldCodec.ForBytes(362); - private readonly pbc::RepeatedField<pb::ByteString> repeatedBytes_ = new pbc::RepeatedField<pb::ByteString>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<pb::ByteString> RepeatedBytes { - get { return repeatedBytes_; } - } - - /// <summary>Field number for the "repeated_nested_message" field.</summary> - public const int RepeatedNestedMessageFieldNumber = 48; - private static readonly pb::FieldCodec<global::Conformance.TestAllTypes.Types.NestedMessage> _repeated_repeatedNestedMessage_codec - = pb::FieldCodec.ForMessage(386, global::Conformance.TestAllTypes.Types.NestedMessage.Parser); - private readonly pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = new pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedMessage> RepeatedNestedMessage { - get { return repeatedNestedMessage_; } - } - - /// <summary>Field number for the "repeated_foreign_message" field.</summary> - public const int RepeatedForeignMessageFieldNumber = 49; - private static readonly pb::FieldCodec<global::Conformance.ForeignMessage> _repeated_repeatedForeignMessage_codec - = pb::FieldCodec.ForMessage(394, global::Conformance.ForeignMessage.Parser); - private readonly pbc::RepeatedField<global::Conformance.ForeignMessage> repeatedForeignMessage_ = new pbc::RepeatedField<global::Conformance.ForeignMessage>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Conformance.ForeignMessage> RepeatedForeignMessage { - get { return repeatedForeignMessage_; } - } - - /// <summary>Field number for the "repeated_nested_enum" field.</summary> - public const int RepeatedNestedEnumFieldNumber = 51; - private static readonly pb::FieldCodec<global::Conformance.TestAllTypes.Types.NestedEnum> _repeated_repeatedNestedEnum_codec - = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x); - private readonly pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum> repeatedNestedEnum_ = new pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Conformance.TestAllTypes.Types.NestedEnum> RepeatedNestedEnum { - get { return repeatedNestedEnum_; } - } - - /// <summary>Field number for the "repeated_foreign_enum" field.</summary> - public const int RepeatedForeignEnumFieldNumber = 52; - private static readonly pb::FieldCodec<global::Conformance.ForeignEnum> _repeated_repeatedForeignEnum_codec - = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::Conformance.ForeignEnum) x); - private readonly pbc::RepeatedField<global::Conformance.ForeignEnum> repeatedForeignEnum_ = new pbc::RepeatedField<global::Conformance.ForeignEnum>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Conformance.ForeignEnum> RepeatedForeignEnum { - get { return repeatedForeignEnum_; } - } - - /// <summary>Field number for the "repeated_string_piece" field.</summary> - public const int RepeatedStringPieceFieldNumber = 54; - private static readonly pb::FieldCodec<string> _repeated_repeatedStringPiece_codec - = pb::FieldCodec.ForString(434); - private readonly pbc::RepeatedField<string> repeatedStringPiece_ = new pbc::RepeatedField<string>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<string> RepeatedStringPiece { - get { return repeatedStringPiece_; } - } - - /// <summary>Field number for the "repeated_cord" field.</summary> - public const int RepeatedCordFieldNumber = 55; - private static readonly pb::FieldCodec<string> _repeated_repeatedCord_codec - = pb::FieldCodec.ForString(442); - private readonly pbc::RepeatedField<string> repeatedCord_ = new pbc::RepeatedField<string>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<string> RepeatedCord { - get { return repeatedCord_; } - } - - /// <summary>Field number for the "map_int32_int32" field.</summary> - public const int MapInt32Int32FieldNumber = 56; - private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec - = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 450); - private readonly pbc::MapField<int, int> mapInt32Int32_ = new pbc::MapField<int, int>(); - /// <summary> - /// Map - /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<int, int> MapInt32Int32 { - get { return mapInt32Int32_; } - } - - /// <summary>Field number for the "map_int64_int64" field.</summary> - public const int MapInt64Int64FieldNumber = 57; - private static readonly pbc::MapField<long, long>.Codec _map_mapInt64Int64_codec - = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 458); - private readonly pbc::MapField<long, long> mapInt64Int64_ = new pbc::MapField<long, long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<long, long> MapInt64Int64 { - get { return mapInt64Int64_; } - } - - /// <summary>Field number for the "map_uint32_uint32" field.</summary> - public const int MapUint32Uint32FieldNumber = 58; - private static readonly pbc::MapField<uint, uint>.Codec _map_mapUint32Uint32_codec - = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 466); - private readonly pbc::MapField<uint, uint> mapUint32Uint32_ = new pbc::MapField<uint, uint>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<uint, uint> MapUint32Uint32 { - get { return mapUint32Uint32_; } - } - - /// <summary>Field number for the "map_uint64_uint64" field.</summary> - public const int MapUint64Uint64FieldNumber = 59; - private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapUint64Uint64_codec - = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 474); - private readonly pbc::MapField<ulong, ulong> mapUint64Uint64_ = new pbc::MapField<ulong, ulong>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<ulong, ulong> MapUint64Uint64 { - get { return mapUint64Uint64_; } - } - - /// <summary>Field number for the "map_sint32_sint32" field.</summary> - public const int MapSint32Sint32FieldNumber = 60; - private static readonly pbc::MapField<int, int>.Codec _map_mapSint32Sint32_codec - = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 482); - private readonly pbc::MapField<int, int> mapSint32Sint32_ = new pbc::MapField<int, int>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<int, int> MapSint32Sint32 { - get { return mapSint32Sint32_; } - } - - /// <summary>Field number for the "map_sint64_sint64" field.</summary> - public const int MapSint64Sint64FieldNumber = 61; - private static readonly pbc::MapField<long, long>.Codec _map_mapSint64Sint64_codec - = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 490); - private readonly pbc::MapField<long, long> mapSint64Sint64_ = new pbc::MapField<long, long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<long, long> MapSint64Sint64 { - get { return mapSint64Sint64_; } - } - - /// <summary>Field number for the "map_fixed32_fixed32" field.</summary> - public const int MapFixed32Fixed32FieldNumber = 62; - private static readonly pbc::MapField<uint, uint>.Codec _map_mapFixed32Fixed32_codec - = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 498); - private readonly pbc::MapField<uint, uint> mapFixed32Fixed32_ = new pbc::MapField<uint, uint>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<uint, uint> MapFixed32Fixed32 { - get { return mapFixed32Fixed32_; } - } - - /// <summary>Field number for the "map_fixed64_fixed64" field.</summary> - public const int MapFixed64Fixed64FieldNumber = 63; - private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapFixed64Fixed64_codec - = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 506); - private readonly pbc::MapField<ulong, ulong> mapFixed64Fixed64_ = new pbc::MapField<ulong, ulong>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<ulong, ulong> MapFixed64Fixed64 { - get { return mapFixed64Fixed64_; } - } - - /// <summary>Field number for the "map_sfixed32_sfixed32" field.</summary> - public const int MapSfixed32Sfixed32FieldNumber = 64; - private static readonly pbc::MapField<int, int>.Codec _map_mapSfixed32Sfixed32_codec - = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 514); - private readonly pbc::MapField<int, int> mapSfixed32Sfixed32_ = new pbc::MapField<int, int>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<int, int> MapSfixed32Sfixed32 { - get { return mapSfixed32Sfixed32_; } - } - - /// <summary>Field number for the "map_sfixed64_sfixed64" field.</summary> - public const int MapSfixed64Sfixed64FieldNumber = 65; - private static readonly pbc::MapField<long, long>.Codec _map_mapSfixed64Sfixed64_codec - = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 522); - private readonly pbc::MapField<long, long> mapSfixed64Sfixed64_ = new pbc::MapField<long, long>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<long, long> MapSfixed64Sfixed64 { - get { return mapSfixed64Sfixed64_; } - } - - /// <summary>Field number for the "map_int32_float" field.</summary> - public const int MapInt32FloatFieldNumber = 66; - private static readonly pbc::MapField<int, float>.Codec _map_mapInt32Float_codec - = new pbc::MapField<int, float>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 530); - private readonly pbc::MapField<int, float> mapInt32Float_ = new pbc::MapField<int, float>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<int, float> MapInt32Float { - get { return mapInt32Float_; } - } - - /// <summary>Field number for the "map_int32_double" field.</summary> - public const int MapInt32DoubleFieldNumber = 67; - private static readonly pbc::MapField<int, double>.Codec _map_mapInt32Double_codec - = new pbc::MapField<int, double>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 538); - private readonly pbc::MapField<int, double> mapInt32Double_ = new pbc::MapField<int, double>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<int, double> MapInt32Double { - get { return mapInt32Double_; } - } - - /// <summary>Field number for the "map_bool_bool" field.</summary> - public const int MapBoolBoolFieldNumber = 68; - private static readonly pbc::MapField<bool, bool>.Codec _map_mapBoolBool_codec - = new pbc::MapField<bool, bool>.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 546); - private readonly pbc::MapField<bool, bool> mapBoolBool_ = new pbc::MapField<bool, bool>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<bool, bool> MapBoolBool { - get { return mapBoolBool_; } - } - - /// <summary>Field number for the "map_string_string" field.</summary> - public const int MapStringStringFieldNumber = 69; - private static readonly pbc::MapField<string, string>.Codec _map_mapStringString_codec - = new pbc::MapField<string, string>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 554); - private readonly pbc::MapField<string, string> mapStringString_ = new pbc::MapField<string, string>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, string> MapStringString { - get { return mapStringString_; } - } - - /// <summary>Field number for the "map_string_bytes" field.</summary> - public const int MapStringBytesFieldNumber = 70; - private static readonly pbc::MapField<string, pb::ByteString>.Codec _map_mapStringBytes_codec - = new pbc::MapField<string, pb::ByteString>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForBytes(18), 562); - private readonly pbc::MapField<string, pb::ByteString> mapStringBytes_ = new pbc::MapField<string, pb::ByteString>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, pb::ByteString> MapStringBytes { - get { return mapStringBytes_; } - } - - /// <summary>Field number for the "map_string_nested_message" field.</summary> - public const int MapStringNestedMessageFieldNumber = 71; - private static readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>.Codec _map_mapStringNestedMessage_codec - = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.TestAllTypes.Types.NestedMessage.Parser), 570); - private readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage> mapStringNestedMessage_ = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedMessage> MapStringNestedMessage { - get { return mapStringNestedMessage_; } - } - - /// <summary>Field number for the "map_string_foreign_message" field.</summary> - public const int MapStringForeignMessageFieldNumber = 72; - private static readonly pbc::MapField<string, global::Conformance.ForeignMessage>.Codec _map_mapStringForeignMessage_codec - = new pbc::MapField<string, global::Conformance.ForeignMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Conformance.ForeignMessage.Parser), 578); - private readonly pbc::MapField<string, global::Conformance.ForeignMessage> mapStringForeignMessage_ = new pbc::MapField<string, global::Conformance.ForeignMessage>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, global::Conformance.ForeignMessage> MapStringForeignMessage { - get { return mapStringForeignMessage_; } - } - - /// <summary>Field number for the "map_string_nested_enum" field.</summary> - public const int MapStringNestedEnumFieldNumber = 73; - private static readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>.Codec _map_mapStringNestedEnum_codec - = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.TestAllTypes.Types.NestedEnum) x), 586); - private readonly pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum> mapStringNestedEnum_ = new pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, global::Conformance.TestAllTypes.Types.NestedEnum> MapStringNestedEnum { - get { return mapStringNestedEnum_; } - } - - /// <summary>Field number for the "map_string_foreign_enum" field.</summary> - public const int MapStringForeignEnumFieldNumber = 74; - private static readonly pbc::MapField<string, global::Conformance.ForeignEnum>.Codec _map_mapStringForeignEnum_codec - = new pbc::MapField<string, global::Conformance.ForeignEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::Conformance.ForeignEnum) x), 594); - private readonly pbc::MapField<string, global::Conformance.ForeignEnum> mapStringForeignEnum_ = new pbc::MapField<string, global::Conformance.ForeignEnum>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::MapField<string, global::Conformance.ForeignEnum> MapStringForeignEnum { - get { return mapStringForeignEnum_; } - } - - /// <summary>Field number for the "oneof_uint32" field.</summary> - public const int OneofUint32FieldNumber = 111; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public uint OneofUint32 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; - } - } - - /// <summary>Field number for the "oneof_nested_message" field.</summary> - public const int OneofNestedMessageFieldNumber = 112; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes.Types.NestedMessage OneofNestedMessage { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::Conformance.TestAllTypes.Types.NestedMessage) oneofField_ : null; } - set { - oneofField_ = value; - oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; - } - } - - /// <summary>Field number for the "oneof_string" field.</summary> - public const int OneofStringFieldNumber = 113; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OneofString { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } - set { - oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - oneofFieldCase_ = OneofFieldOneofCase.OneofString; - } - } - - /// <summary>Field number for the "oneof_bytes" field.</summary> - public const int OneofBytesFieldNumber = 114; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pb::ByteString OneofBytes { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } - set { - oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; - } - } - - /// <summary>Field number for the "oneof_bool" field.</summary> - public const int OneofBoolFieldNumber = 115; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool OneofBool { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBool ? (bool) oneofField_ : false; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofBool; - } - } - - /// <summary>Field number for the "oneof_uint64" field.</summary> - public const int OneofUint64FieldNumber = 116; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ulong OneofUint64 { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint64 ? (ulong) oneofField_ : 0UL; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofUint64; - } - } - - /// <summary>Field number for the "oneof_float" field.</summary> - public const int OneofFloatFieldNumber = 117; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public float OneofFloat { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofFloat ? (float) oneofField_ : 0F; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofFloat; - } - } - - /// <summary>Field number for the "oneof_double" field.</summary> - public const int OneofDoubleFieldNumber = 118; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double OneofDouble { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofDouble ? (double) oneofField_ : 0D; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofDouble; - } - } - - /// <summary>Field number for the "oneof_enum" field.</summary> - public const int OneofEnumFieldNumber = 119; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes.Types.NestedEnum OneofEnum { - get { return oneofFieldCase_ == OneofFieldOneofCase.OneofEnum ? (global::Conformance.TestAllTypes.Types.NestedEnum) oneofField_ : 0; } - set { - oneofField_ = value; - oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; - } - } - - /// <summary>Field number for the "optional_bool_wrapper" field.</summary> - public const int OptionalBoolWrapperFieldNumber = 201; - private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610); - private bool? optionalBoolWrapper_; - /// <summary> - /// Well-known types - /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool? OptionalBoolWrapper { - get { return optionalBoolWrapper_; } - set { - optionalBoolWrapper_ = value; - } - } - - /// <summary>Field number for the "optional_int32_wrapper" field.</summary> - public const int OptionalInt32WrapperFieldNumber = 202; - private static readonly pb::FieldCodec<int?> _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper<int>(1618); - private int? optionalInt32Wrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int? OptionalInt32Wrapper { - get { return optionalInt32Wrapper_; } - set { - optionalInt32Wrapper_ = value; - } - } - - /// <summary>Field number for the "optional_int64_wrapper" field.</summary> - public const int OptionalInt64WrapperFieldNumber = 203; - private static readonly pb::FieldCodec<long?> _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper<long>(1626); - private long? optionalInt64Wrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public long? OptionalInt64Wrapper { - get { return optionalInt64Wrapper_; } - set { - optionalInt64Wrapper_ = value; - } - } - - /// <summary>Field number for the "optional_uint32_wrapper" field.</summary> - public const int OptionalUint32WrapperFieldNumber = 204; - private static readonly pb::FieldCodec<uint?> _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper<uint>(1634); - private uint? optionalUint32Wrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public uint? OptionalUint32Wrapper { - get { return optionalUint32Wrapper_; } - set { - optionalUint32Wrapper_ = value; - } - } - - /// <summary>Field number for the "optional_uint64_wrapper" field.</summary> - public const int OptionalUint64WrapperFieldNumber = 205; - private static readonly pb::FieldCodec<ulong?> _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper<ulong>(1642); - private ulong? optionalUint64Wrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ulong? OptionalUint64Wrapper { - get { return optionalUint64Wrapper_; } - set { - optionalUint64Wrapper_ = value; - } - } - - /// <summary>Field number for the "optional_float_wrapper" field.</summary> - public const int OptionalFloatWrapperFieldNumber = 206; - private static readonly pb::FieldCodec<float?> _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper<float>(1650); - private float? optionalFloatWrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public float? OptionalFloatWrapper { - get { return optionalFloatWrapper_; } - set { - optionalFloatWrapper_ = value; - } - } - - /// <summary>Field number for the "optional_double_wrapper" field.</summary> - public const int OptionalDoubleWrapperFieldNumber = 207; - private static readonly pb::FieldCodec<double?> _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper<double>(1658); - private double? optionalDoubleWrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double? OptionalDoubleWrapper { - get { return optionalDoubleWrapper_; } - set { - optionalDoubleWrapper_ = value; - } - } - - /// <summary>Field number for the "optional_string_wrapper" field.</summary> - public const int OptionalStringWrapperFieldNumber = 208; - private static readonly pb::FieldCodec<string> _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper<string>(1666); - private string optionalStringWrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OptionalStringWrapper { - get { return optionalStringWrapper_; } - set { - optionalStringWrapper_ = value; - } - } - - /// <summary>Field number for the "optional_bytes_wrapper" field.</summary> - public const int OptionalBytesWrapperFieldNumber = 209; - private static readonly pb::FieldCodec<pb::ByteString> _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1674); - private pb::ByteString optionalBytesWrapper_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pb::ByteString OptionalBytesWrapper { - get { return optionalBytesWrapper_; } - set { - optionalBytesWrapper_ = value; - } - } - - /// <summary>Field number for the "repeated_bool_wrapper" field.</summary> - public const int RepeatedBoolWrapperFieldNumber = 211; - private static readonly pb::FieldCodec<bool?> _repeated_repeatedBoolWrapper_codec - = pb::FieldCodec.ForStructWrapper<bool>(1690); - private readonly pbc::RepeatedField<bool?> repeatedBoolWrapper_ = new pbc::RepeatedField<bool?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<bool?> RepeatedBoolWrapper { - get { return repeatedBoolWrapper_; } - } - - /// <summary>Field number for the "repeated_int32_wrapper" field.</summary> - public const int RepeatedInt32WrapperFieldNumber = 212; - private static readonly pb::FieldCodec<int?> _repeated_repeatedInt32Wrapper_codec - = pb::FieldCodec.ForStructWrapper<int>(1698); - private readonly pbc::RepeatedField<int?> repeatedInt32Wrapper_ = new pbc::RepeatedField<int?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<int?> RepeatedInt32Wrapper { - get { return repeatedInt32Wrapper_; } - } - - /// <summary>Field number for the "repeated_int64_wrapper" field.</summary> - public const int RepeatedInt64WrapperFieldNumber = 213; - private static readonly pb::FieldCodec<long?> _repeated_repeatedInt64Wrapper_codec - = pb::FieldCodec.ForStructWrapper<long>(1706); - private readonly pbc::RepeatedField<long?> repeatedInt64Wrapper_ = new pbc::RepeatedField<long?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<long?> RepeatedInt64Wrapper { - get { return repeatedInt64Wrapper_; } - } - - /// <summary>Field number for the "repeated_uint32_wrapper" field.</summary> - public const int RepeatedUint32WrapperFieldNumber = 214; - private static readonly pb::FieldCodec<uint?> _repeated_repeatedUint32Wrapper_codec - = pb::FieldCodec.ForStructWrapper<uint>(1714); - private readonly pbc::RepeatedField<uint?> repeatedUint32Wrapper_ = new pbc::RepeatedField<uint?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<uint?> RepeatedUint32Wrapper { - get { return repeatedUint32Wrapper_; } - } - - /// <summary>Field number for the "repeated_uint64_wrapper" field.</summary> - public const int RepeatedUint64WrapperFieldNumber = 215; - private static readonly pb::FieldCodec<ulong?> _repeated_repeatedUint64Wrapper_codec - = pb::FieldCodec.ForStructWrapper<ulong>(1722); - private readonly pbc::RepeatedField<ulong?> repeatedUint64Wrapper_ = new pbc::RepeatedField<ulong?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<ulong?> RepeatedUint64Wrapper { - get { return repeatedUint64Wrapper_; } - } - - /// <summary>Field number for the "repeated_float_wrapper" field.</summary> - public const int RepeatedFloatWrapperFieldNumber = 216; - private static readonly pb::FieldCodec<float?> _repeated_repeatedFloatWrapper_codec - = pb::FieldCodec.ForStructWrapper<float>(1730); - private readonly pbc::RepeatedField<float?> repeatedFloatWrapper_ = new pbc::RepeatedField<float?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<float?> RepeatedFloatWrapper { - get { return repeatedFloatWrapper_; } - } - - /// <summary>Field number for the "repeated_double_wrapper" field.</summary> - public const int RepeatedDoubleWrapperFieldNumber = 217; - private static readonly pb::FieldCodec<double?> _repeated_repeatedDoubleWrapper_codec - = pb::FieldCodec.ForStructWrapper<double>(1738); - private readonly pbc::RepeatedField<double?> repeatedDoubleWrapper_ = new pbc::RepeatedField<double?>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<double?> RepeatedDoubleWrapper { - get { return repeatedDoubleWrapper_; } - } - - /// <summary>Field number for the "repeated_string_wrapper" field.</summary> - public const int RepeatedStringWrapperFieldNumber = 218; - private static readonly pb::FieldCodec<string> _repeated_repeatedStringWrapper_codec - = pb::FieldCodec.ForClassWrapper<string>(1746); - private readonly pbc::RepeatedField<string> repeatedStringWrapper_ = new pbc::RepeatedField<string>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<string> RepeatedStringWrapper { - get { return repeatedStringWrapper_; } - } - - /// <summary>Field number for the "repeated_bytes_wrapper" field.</summary> - public const int RepeatedBytesWrapperFieldNumber = 219; - private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytesWrapper_codec - = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1754); - private readonly pbc::RepeatedField<pb::ByteString> repeatedBytesWrapper_ = new pbc::RepeatedField<pb::ByteString>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<pb::ByteString> RepeatedBytesWrapper { - get { return repeatedBytesWrapper_; } - } - - /// <summary>Field number for the "optional_duration" field.</summary> - public const int OptionalDurationFieldNumber = 301; - private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration { - get { return optionalDuration_; } - set { - optionalDuration_ = value; - } - } - - /// <summary>Field number for the "optional_timestamp" field.</summary> - public const int OptionalTimestampFieldNumber = 302; - private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp { - get { return optionalTimestamp_; } - set { - optionalTimestamp_ = value; - } - } - - /// <summary>Field number for the "optional_field_mask" field.</summary> - public const int OptionalFieldMaskFieldNumber = 303; - private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask { - get { return optionalFieldMask_; } - set { - optionalFieldMask_ = value; - } - } - - /// <summary>Field number for the "optional_struct" field.</summary> - public const int OptionalStructFieldNumber = 304; - private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct { - get { return optionalStruct_; } - set { - optionalStruct_ = value; - } - } - - /// <summary>Field number for the "optional_any" field.</summary> - public const int OptionalAnyFieldNumber = 305; - private global::Google.Protobuf.WellKnownTypes.Any optionalAny_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.Any OptionalAny { - get { return optionalAny_; } - set { - optionalAny_ = value; - } - } - - /// <summary>Field number for the "optional_value" field.</summary> - public const int OptionalValueFieldNumber = 306; - private global::Google.Protobuf.WellKnownTypes.Value optionalValue_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Google.Protobuf.WellKnownTypes.Value OptionalValue { - get { return optionalValue_; } - set { - optionalValue_ = value; - } - } - - /// <summary>Field number for the "repeated_duration" field.</summary> - public const int RepeatedDurationFieldNumber = 311; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec - = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> repeatedDuration_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> RepeatedDuration { - get { return repeatedDuration_; } - } - - /// <summary>Field number for the "repeated_timestamp" field.</summary> - public const int RepeatedTimestampFieldNumber = 312; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Timestamp> _repeated_repeatedTimestamp_codec - = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> repeatedTimestamp_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> RepeatedTimestamp { - get { return repeatedTimestamp_; } - } - - /// <summary>Field number for the "repeated_fieldmask" field.</summary> - public const int RepeatedFieldmaskFieldNumber = 313; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.FieldMask> _repeated_repeatedFieldmask_codec - = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> repeatedFieldmask_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> RepeatedFieldmask { - get { return repeatedFieldmask_; } - } - - /// <summary>Field number for the "repeated_struct" field.</summary> - public const int RepeatedStructFieldNumber = 324; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Struct> _repeated_repeatedStruct_codec - = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> repeatedStruct_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> RepeatedStruct { - get { return repeatedStruct_; } - } - - /// <summary>Field number for the "repeated_any" field.</summary> - public const int RepeatedAnyFieldNumber = 315; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Any> _repeated_repeatedAny_codec - = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> repeatedAny_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> RepeatedAny { - get { return repeatedAny_; } - } - - /// <summary>Field number for the "repeated_value" field.</summary> - public const int RepeatedValueFieldNumber = 316; - private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Value> _repeated_repeatedValue_codec - = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser); - private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> repeatedValue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> RepeatedValue { - get { return repeatedValue_; } - } - - /// <summary>Field number for the "fieldname1" field.</summary> - public const int Fieldname1FieldNumber = 401; - private int fieldname1_; - /// <summary> - /// Test field-name-to-JSON-name convention. - /// (protobuf says names can be any valid C/C++ identifier.) - /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int Fieldname1 { - get { return fieldname1_; } - set { - fieldname1_ = value; - } - } - - /// <summary>Field number for the "field_name2" field.</summary> - public const int FieldName2FieldNumber = 402; - private int fieldName2_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName2 { - get { return fieldName2_; } - set { - fieldName2_ = value; - } - } - - /// <summary>Field number for the "_field_name3" field.</summary> - public const int FieldName3FieldNumber = 403; - private int FieldName3_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName3 { - get { return FieldName3_; } - set { - FieldName3_ = value; - } - } - - /// <summary>Field number for the "field__name4_" field.</summary> - public const int FieldName4FieldNumber = 404; - private int fieldName4_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName4 { - get { return fieldName4_; } - set { - fieldName4_ = value; - } - } - - /// <summary>Field number for the "field0name5" field.</summary> - public const int Field0Name5FieldNumber = 405; - private int field0Name5_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int Field0Name5 { - get { return field0Name5_; } - set { - field0Name5_ = value; - } - } - - /// <summary>Field number for the "field_0_name6" field.</summary> - public const int Field0Name6FieldNumber = 406; - private int field0Name6_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int Field0Name6 { - get { return field0Name6_; } - set { - field0Name6_ = value; - } - } - - /// <summary>Field number for the "fieldName7" field.</summary> - public const int FieldName7FieldNumber = 407; - private int fieldName7_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName7 { - get { return fieldName7_; } - set { - fieldName7_ = value; - } - } - - /// <summary>Field number for the "FieldName8" field.</summary> - public const int FieldName8FieldNumber = 408; - private int fieldName8_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName8 { - get { return fieldName8_; } - set { - fieldName8_ = value; - } - } - - /// <summary>Field number for the "field_Name9" field.</summary> - public const int FieldName9FieldNumber = 409; - private int fieldName9_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName9 { - get { return fieldName9_; } - set { - fieldName9_ = value; - } - } - - /// <summary>Field number for the "Field_Name10" field.</summary> - public const int FieldName10FieldNumber = 410; - private int fieldName10_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName10 { - get { return fieldName10_; } - set { - fieldName10_ = value; - } - } - - /// <summary>Field number for the "FIELD_NAME11" field.</summary> - public const int FIELDNAME11FieldNumber = 411; - private int fIELDNAME11_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FIELDNAME11 { - get { return fIELDNAME11_; } - set { - fIELDNAME11_ = value; - } - } - - /// <summary>Field number for the "FIELD_name12" field.</summary> - public const int FIELDName12FieldNumber = 412; - private int fIELDName12_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FIELDName12 { - get { return fIELDName12_; } - set { - fIELDName12_ = value; - } - } - - /// <summary>Field number for the "__field_name13" field.</summary> - public const int FieldName13FieldNumber = 413; - private int FieldName13_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName13 { - get { return FieldName13_; } - set { - FieldName13_ = value; - } - } - - /// <summary>Field number for the "__Field_name14" field.</summary> - public const int FieldName14FieldNumber = 414; - private int FieldName14_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName14 { - get { return FieldName14_; } - set { - FieldName14_ = value; - } - } - - /// <summary>Field number for the "field__name15" field.</summary> - public const int FieldName15FieldNumber = 415; - private int fieldName15_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName15 { - get { return fieldName15_; } - set { - fieldName15_ = value; - } - } - - /// <summary>Field number for the "field__Name16" field.</summary> - public const int FieldName16FieldNumber = 416; - private int fieldName16_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName16 { - get { return fieldName16_; } - set { - fieldName16_ = value; - } - } - - /// <summary>Field number for the "field_name17__" field.</summary> - public const int FieldName17FieldNumber = 417; - private int fieldName17_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName17 { - get { return fieldName17_; } - set { - fieldName17_ = value; - } - } - - /// <summary>Field number for the "Field_name18__" field.</summary> - public const int FieldName18FieldNumber = 418; - private int fieldName18_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int FieldName18 { - get { return fieldName18_; } - set { - fieldName18_ = value; - } - } - - private object oneofField_; - /// <summary>Enum of possible cases for the "oneof_field" oneof.</summary> - public enum OneofFieldOneofCase { - None = 0, - OneofUint32 = 111, - OneofNestedMessage = 112, - OneofString = 113, - OneofBytes = 114, - OneofBool = 115, - OneofUint64 = 116, - OneofFloat = 117, - OneofDouble = 118, - OneofEnum = 119, - } - private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public OneofFieldOneofCase OneofFieldCase { - get { return oneofFieldCase_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void ClearOneofField() { - oneofFieldCase_ = OneofFieldOneofCase.None; - oneofField_ = null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as TestAllTypes); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(TestAllTypes other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (OptionalInt32 != other.OptionalInt32) return false; - if (OptionalInt64 != other.OptionalInt64) return false; - if (OptionalUint32 != other.OptionalUint32) return false; - if (OptionalUint64 != other.OptionalUint64) return false; - if (OptionalSint32 != other.OptionalSint32) return false; - if (OptionalSint64 != other.OptionalSint64) return false; - if (OptionalFixed32 != other.OptionalFixed32) return false; - if (OptionalFixed64 != other.OptionalFixed64) return false; - if (OptionalSfixed32 != other.OptionalSfixed32) return false; - if (OptionalSfixed64 != other.OptionalSfixed64) return false; - if (OptionalFloat != other.OptionalFloat) return false; - if (OptionalDouble != other.OptionalDouble) return false; - if (OptionalBool != other.OptionalBool) return false; - if (OptionalString != other.OptionalString) return false; - if (OptionalBytes != other.OptionalBytes) return false; - if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false; - if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false; - if (OptionalNestedEnum != other.OptionalNestedEnum) return false; - if (OptionalForeignEnum != other.OptionalForeignEnum) return false; - if (OptionalStringPiece != other.OptionalStringPiece) return false; - if (OptionalCord != other.OptionalCord) return false; - if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false; - if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; - if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; - if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; - if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; - if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false; - if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false; - if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; - if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; - if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false; - if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false; - if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; - if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false; - if(!repeatedBool_.Equals(other.repeatedBool_)) return false; - if(!repeatedString_.Equals(other.repeatedString_)) return false; - if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false; - if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false; - if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false; - if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false; - if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false; - if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false; - if(!repeatedCord_.Equals(other.repeatedCord_)) return false; - if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; - if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; - if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; - if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; - if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; - if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; - if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; - if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; - if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; - if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; - if (!MapInt32Float.Equals(other.MapInt32Float)) return false; - if (!MapInt32Double.Equals(other.MapInt32Double)) return false; - if (!MapBoolBool.Equals(other.MapBoolBool)) return false; - if (!MapStringString.Equals(other.MapStringString)) return false; - if (!MapStringBytes.Equals(other.MapStringBytes)) return false; - if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false; - if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false; - if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false; - if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false; - if (OneofUint32 != other.OneofUint32) return false; - if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; - if (OneofString != other.OneofString) return false; - if (OneofBytes != other.OneofBytes) return false; - if (OneofBool != other.OneofBool) return false; - if (OneofUint64 != other.OneofUint64) return false; - if (OneofFloat != other.OneofFloat) return false; - if (OneofDouble != other.OneofDouble) return false; - if (OneofEnum != other.OneofEnum) return false; - if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; - if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; - if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; - if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false; - if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false; - if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false; - if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false; - if (OptionalStringWrapper != other.OptionalStringWrapper) return false; - if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false; - if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false; - if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false; - if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false; - if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false; - if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false; - if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false; - if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false; - if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false; - if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false; - if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false; - if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false; - if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false; - if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; - if (!object.Equals(OptionalAny, other.OptionalAny)) return false; - if (!object.Equals(OptionalValue, other.OptionalValue)) return false; - if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; - if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; - if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; - if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false; - if(!repeatedAny_.Equals(other.repeatedAny_)) return false; - if(!repeatedValue_.Equals(other.repeatedValue_)) return false; - if (Fieldname1 != other.Fieldname1) return false; - if (FieldName2 != other.FieldName2) return false; - if (FieldName3 != other.FieldName3) return false; - if (FieldName4 != other.FieldName4) return false; - if (Field0Name5 != other.Field0Name5) return false; - if (Field0Name6 != other.Field0Name6) return false; - if (FieldName7 != other.FieldName7) return false; - if (FieldName8 != other.FieldName8) return false; - if (FieldName9 != other.FieldName9) return false; - if (FieldName10 != other.FieldName10) return false; - if (FIELDNAME11 != other.FIELDNAME11) return false; - if (FIELDName12 != other.FIELDName12) return false; - if (FieldName13 != other.FieldName13) return false; - if (FieldName14 != other.FieldName14) return false; - if (FieldName15 != other.FieldName15) return false; - if (FieldName16 != other.FieldName16) return false; - if (FieldName17 != other.FieldName17) return false; - if (FieldName18 != other.FieldName18) return false; - if (OneofFieldCase != other.OneofFieldCase) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); - if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode(); - if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode(); - if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode(); - if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode(); - if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode(); - if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode(); - if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode(); - if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode(); - if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode(); - if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode(); - if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode(); - if (OptionalBool != false) hash ^= OptionalBool.GetHashCode(); - if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode(); - if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode(); - if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode(); - if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode(); - if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode(); - if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode(); - if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode(); - if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode(); - if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode(); - hash ^= repeatedInt32_.GetHashCode(); - hash ^= repeatedInt64_.GetHashCode(); - hash ^= repeatedUint32_.GetHashCode(); - hash ^= repeatedUint64_.GetHashCode(); - hash ^= repeatedSint32_.GetHashCode(); - hash ^= repeatedSint64_.GetHashCode(); - hash ^= repeatedFixed32_.GetHashCode(); - hash ^= repeatedFixed64_.GetHashCode(); - hash ^= repeatedSfixed32_.GetHashCode(); - hash ^= repeatedSfixed64_.GetHashCode(); - hash ^= repeatedFloat_.GetHashCode(); - hash ^= repeatedDouble_.GetHashCode(); - hash ^= repeatedBool_.GetHashCode(); - hash ^= repeatedString_.GetHashCode(); - hash ^= repeatedBytes_.GetHashCode(); - hash ^= repeatedNestedMessage_.GetHashCode(); - hash ^= repeatedForeignMessage_.GetHashCode(); - hash ^= repeatedNestedEnum_.GetHashCode(); - hash ^= repeatedForeignEnum_.GetHashCode(); - hash ^= repeatedStringPiece_.GetHashCode(); - hash ^= repeatedCord_.GetHashCode(); - hash ^= MapInt32Int32.GetHashCode(); - hash ^= MapInt64Int64.GetHashCode(); - hash ^= MapUint32Uint32.GetHashCode(); - hash ^= MapUint64Uint64.GetHashCode(); - hash ^= MapSint32Sint32.GetHashCode(); - hash ^= MapSint64Sint64.GetHashCode(); - hash ^= MapFixed32Fixed32.GetHashCode(); - hash ^= MapFixed64Fixed64.GetHashCode(); - hash ^= MapSfixed32Sfixed32.GetHashCode(); - hash ^= MapSfixed64Sfixed64.GetHashCode(); - hash ^= MapInt32Float.GetHashCode(); - hash ^= MapInt32Double.GetHashCode(); - hash ^= MapBoolBool.GetHashCode(); - hash ^= MapStringString.GetHashCode(); - hash ^= MapStringBytes.GetHashCode(); - hash ^= MapStringNestedMessage.GetHashCode(); - hash ^= MapStringForeignMessage.GetHashCode(); - hash ^= MapStringNestedEnum.GetHashCode(); - hash ^= MapStringForeignEnum.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= OneofFloat.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= OneofDouble.GetHashCode(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode(); - if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); - if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); - if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); - if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode(); - if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode(); - if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode(); - if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode(); - if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode(); - if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode(); - hash ^= repeatedBoolWrapper_.GetHashCode(); - hash ^= repeatedInt32Wrapper_.GetHashCode(); - hash ^= repeatedInt64Wrapper_.GetHashCode(); - hash ^= repeatedUint32Wrapper_.GetHashCode(); - hash ^= repeatedUint64Wrapper_.GetHashCode(); - hash ^= repeatedFloatWrapper_.GetHashCode(); - hash ^= repeatedDoubleWrapper_.GetHashCode(); - hash ^= repeatedStringWrapper_.GetHashCode(); - hash ^= repeatedBytesWrapper_.GetHashCode(); - if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode(); - if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode(); - if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode(); - if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); - if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); - if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); - hash ^= repeatedDuration_.GetHashCode(); - hash ^= repeatedTimestamp_.GetHashCode(); - hash ^= repeatedFieldmask_.GetHashCode(); - hash ^= repeatedStruct_.GetHashCode(); - hash ^= repeatedAny_.GetHashCode(); - hash ^= repeatedValue_.GetHashCode(); - if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode(); - if (FieldName2 != 0) hash ^= FieldName2.GetHashCode(); - if (FieldName3 != 0) hash ^= FieldName3.GetHashCode(); - if (FieldName4 != 0) hash ^= FieldName4.GetHashCode(); - if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode(); - if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode(); - if (FieldName7 != 0) hash ^= FieldName7.GetHashCode(); - if (FieldName8 != 0) hash ^= FieldName8.GetHashCode(); - if (FieldName9 != 0) hash ^= FieldName9.GetHashCode(); - if (FieldName10 != 0) hash ^= FieldName10.GetHashCode(); - if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode(); - if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode(); - if (FieldName13 != 0) hash ^= FieldName13.GetHashCode(); - if (FieldName14 != 0) hash ^= FieldName14.GetHashCode(); - if (FieldName15 != 0) hash ^= FieldName15.GetHashCode(); - if (FieldName16 != 0) hash ^= FieldName16.GetHashCode(); - if (FieldName17 != 0) hash ^= FieldName17.GetHashCode(); - if (FieldName18 != 0) hash ^= FieldName18.GetHashCode(); - hash ^= (int) oneofFieldCase_; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (OptionalInt32 != 0) { - output.WriteRawTag(8); - output.WriteInt32(OptionalInt32); - } - if (OptionalInt64 != 0L) { - output.WriteRawTag(16); - output.WriteInt64(OptionalInt64); - } - if (OptionalUint32 != 0) { - output.WriteRawTag(24); - output.WriteUInt32(OptionalUint32); - } - if (OptionalUint64 != 0UL) { - output.WriteRawTag(32); - output.WriteUInt64(OptionalUint64); - } - if (OptionalSint32 != 0) { - output.WriteRawTag(40); - output.WriteSInt32(OptionalSint32); - } - if (OptionalSint64 != 0L) { - output.WriteRawTag(48); - output.WriteSInt64(OptionalSint64); - } - if (OptionalFixed32 != 0) { - output.WriteRawTag(61); - output.WriteFixed32(OptionalFixed32); - } - if (OptionalFixed64 != 0UL) { - output.WriteRawTag(65); - output.WriteFixed64(OptionalFixed64); - } - if (OptionalSfixed32 != 0) { - output.WriteRawTag(77); - output.WriteSFixed32(OptionalSfixed32); - } - if (OptionalSfixed64 != 0L) { - output.WriteRawTag(81); - output.WriteSFixed64(OptionalSfixed64); - } - if (OptionalFloat != 0F) { - output.WriteRawTag(93); - output.WriteFloat(OptionalFloat); - } - if (OptionalDouble != 0D) { - output.WriteRawTag(97); - output.WriteDouble(OptionalDouble); - } - if (OptionalBool != false) { - output.WriteRawTag(104); - output.WriteBool(OptionalBool); - } - if (OptionalString.Length != 0) { - output.WriteRawTag(114); - output.WriteString(OptionalString); - } - if (OptionalBytes.Length != 0) { - output.WriteRawTag(122); - output.WriteBytes(OptionalBytes); - } - if (optionalNestedMessage_ != null) { - output.WriteRawTag(146, 1); - output.WriteMessage(OptionalNestedMessage); - } - if (optionalForeignMessage_ != null) { - output.WriteRawTag(154, 1); - output.WriteMessage(OptionalForeignMessage); - } - if (OptionalNestedEnum != 0) { - output.WriteRawTag(168, 1); - output.WriteEnum((int) OptionalNestedEnum); - } - if (OptionalForeignEnum != 0) { - output.WriteRawTag(176, 1); - output.WriteEnum((int) OptionalForeignEnum); - } - if (OptionalStringPiece.Length != 0) { - output.WriteRawTag(194, 1); - output.WriteString(OptionalStringPiece); - } - if (OptionalCord.Length != 0) { - output.WriteRawTag(202, 1); - output.WriteString(OptionalCord); - } - if (recursiveMessage_ != null) { - output.WriteRawTag(218, 1); - output.WriteMessage(RecursiveMessage); - } - repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); - repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); - repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); - repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); - repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); - repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); - repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); - repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); - repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); - repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); - repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); - repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); - repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); - repeatedString_.WriteTo(output, _repeated_repeatedString_codec); - repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); - repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); - repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); - repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); - repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); - repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec); - repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec); - mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); - mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); - mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); - mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); - mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); - mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); - mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); - mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); - mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); - mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); - mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); - mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); - mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); - mapStringString_.WriteTo(output, _map_mapStringString_codec); - mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec); - mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec); - mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec); - mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec); - mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - output.WriteRawTag(248, 6); - output.WriteUInt32(OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - output.WriteRawTag(130, 7); - output.WriteMessage(OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - output.WriteRawTag(138, 7); - output.WriteString(OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - output.WriteRawTag(146, 7); - output.WriteBytes(OneofBytes); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { - output.WriteRawTag(152, 7); - output.WriteBool(OneofBool); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { - output.WriteRawTag(160, 7); - output.WriteUInt64(OneofUint64); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { - output.WriteRawTag(173, 7); - output.WriteFloat(OneofFloat); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { - output.WriteRawTag(177, 7); - output.WriteDouble(OneofDouble); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { - output.WriteRawTag(184, 7); - output.WriteEnum((int) OneofEnum); - } - if (optionalBoolWrapper_ != null) { - _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); - } - if (optionalInt32Wrapper_ != null) { - _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper); - } - if (optionalInt64Wrapper_ != null) { - _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper); - } - if (optionalUint32Wrapper_ != null) { - _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper); - } - if (optionalUint64Wrapper_ != null) { - _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper); - } - if (optionalFloatWrapper_ != null) { - _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper); - } - if (optionalDoubleWrapper_ != null) { - _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper); - } - if (optionalStringWrapper_ != null) { - _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper); - } - if (optionalBytesWrapper_ != null) { - _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper); - } - repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec); - repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec); - repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec); - repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec); - repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec); - repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec); - repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec); - repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec); - repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec); - if (optionalDuration_ != null) { - output.WriteRawTag(234, 18); - output.WriteMessage(OptionalDuration); - } - if (optionalTimestamp_ != null) { - output.WriteRawTag(242, 18); - output.WriteMessage(OptionalTimestamp); - } - if (optionalFieldMask_ != null) { - output.WriteRawTag(250, 18); - output.WriteMessage(OptionalFieldMask); - } - if (optionalStruct_ != null) { - output.WriteRawTag(130, 19); - output.WriteMessage(OptionalStruct); - } - if (optionalAny_ != null) { - output.WriteRawTag(138, 19); - output.WriteMessage(OptionalAny); - } - if (optionalValue_ != null) { - output.WriteRawTag(146, 19); - output.WriteMessage(OptionalValue); - } - repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec); - repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); - repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); - repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec); - repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec); - repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec); - if (Fieldname1 != 0) { - output.WriteRawTag(136, 25); - output.WriteInt32(Fieldname1); - } - if (FieldName2 != 0) { - output.WriteRawTag(144, 25); - output.WriteInt32(FieldName2); - } - if (FieldName3 != 0) { - output.WriteRawTag(152, 25); - output.WriteInt32(FieldName3); - } - if (FieldName4 != 0) { - output.WriteRawTag(160, 25); - output.WriteInt32(FieldName4); - } - if (Field0Name5 != 0) { - output.WriteRawTag(168, 25); - output.WriteInt32(Field0Name5); - } - if (Field0Name6 != 0) { - output.WriteRawTag(176, 25); - output.WriteInt32(Field0Name6); - } - if (FieldName7 != 0) { - output.WriteRawTag(184, 25); - output.WriteInt32(FieldName7); - } - if (FieldName8 != 0) { - output.WriteRawTag(192, 25); - output.WriteInt32(FieldName8); - } - if (FieldName9 != 0) { - output.WriteRawTag(200, 25); - output.WriteInt32(FieldName9); - } - if (FieldName10 != 0) { - output.WriteRawTag(208, 25); - output.WriteInt32(FieldName10); - } - if (FIELDNAME11 != 0) { - output.WriteRawTag(216, 25); - output.WriteInt32(FIELDNAME11); - } - if (FIELDName12 != 0) { - output.WriteRawTag(224, 25); - output.WriteInt32(FIELDName12); - } - if (FieldName13 != 0) { - output.WriteRawTag(232, 25); - output.WriteInt32(FieldName13); - } - if (FieldName14 != 0) { - output.WriteRawTag(240, 25); - output.WriteInt32(FieldName14); - } - if (FieldName15 != 0) { - output.WriteRawTag(248, 25); - output.WriteInt32(FieldName15); - } - if (FieldName16 != 0) { - output.WriteRawTag(128, 26); - output.WriteInt32(FieldName16); - } - if (FieldName17 != 0) { - output.WriteRawTag(136, 26); - output.WriteInt32(FieldName17); - } - if (FieldName18 != 0) { - output.WriteRawTag(144, 26); - output.WriteInt32(FieldName18); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (OptionalInt32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); - } - if (OptionalInt64 != 0L) { - size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64); - } - if (OptionalUint32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32); - } - if (OptionalUint64 != 0UL) { - size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64); - } - if (OptionalSint32 != 0) { - size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32); - } - if (OptionalSint64 != 0L) { - size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64); - } - if (OptionalFixed32 != 0) { - size += 1 + 4; - } - if (OptionalFixed64 != 0UL) { - size += 1 + 8; - } - if (OptionalSfixed32 != 0) { - size += 1 + 4; - } - if (OptionalSfixed64 != 0L) { - size += 1 + 8; - } - if (OptionalFloat != 0F) { - size += 1 + 4; - } - if (OptionalDouble != 0D) { - size += 1 + 8; - } - if (OptionalBool != false) { - size += 1 + 1; - } - if (OptionalString.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString); - } - if (OptionalBytes.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes); - } - if (optionalNestedMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage); - } - if (optionalForeignMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage); - } - if (OptionalNestedEnum != 0) { - size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum); - } - if (OptionalForeignEnum != 0) { - size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum); - } - if (OptionalStringPiece.Length != 0) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece); - } - if (OptionalCord.Length != 0) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord); - } - if (recursiveMessage_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage); - } - size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); - size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); - size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); - size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); - size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); - size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); - size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); - size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); - size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); - size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); - size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); - size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); - size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); - size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); - size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); - size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); - size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); - size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); - size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); - size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec); - size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec); - size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); - size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); - size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); - size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); - size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); - size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); - size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); - size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); - size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); - size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); - size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); - size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); - size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); - size += mapStringString_.CalculateSize(_map_mapStringString_codec); - size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec); - size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec); - size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec); - size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec); - size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { - size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { - size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { - size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { - size += 2 + 1; - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { - size += 2 + pb::CodedOutputStream.ComputeUInt64Size(OneofUint64); - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { - size += 2 + 4; - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { - size += 2 + 8; - } - if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { - size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum); - } - if (optionalBoolWrapper_ != null) { - size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); - } - if (optionalInt32Wrapper_ != null) { - size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper); - } - if (optionalInt64Wrapper_ != null) { - size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper); - } - if (optionalUint32Wrapper_ != null) { - size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper); - } - if (optionalUint64Wrapper_ != null) { - size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper); - } - if (optionalFloatWrapper_ != null) { - size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper); - } - if (optionalDoubleWrapper_ != null) { - size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper); - } - if (optionalStringWrapper_ != null) { - size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper); - } - if (optionalBytesWrapper_ != null) { - size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper); - } - size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec); - size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec); - size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec); - size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec); - size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec); - size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec); - size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec); - size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec); - size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec); - if (optionalDuration_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration); - } - if (optionalTimestamp_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp); - } - if (optionalFieldMask_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask); - } - if (optionalStruct_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct); - } - if (optionalAny_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny); - } - if (optionalValue_ != null) { - size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); - } - size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec); - size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); - size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); - size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec); - size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec); - size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec); - if (Fieldname1 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1); - } - if (FieldName2 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2); - } - if (FieldName3 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3); - } - if (FieldName4 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4); - } - if (Field0Name5 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5); - } - if (Field0Name6 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6); - } - if (FieldName7 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7); - } - if (FieldName8 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8); - } - if (FieldName9 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9); - } - if (FieldName10 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10); - } - if (FIELDNAME11 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11); - } - if (FIELDName12 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12); - } - if (FieldName13 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName13); - } - if (FieldName14 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName14); - } - if (FieldName15 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName15); - } - if (FieldName16 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName16); - } - if (FieldName17 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName17); - } - if (FieldName18 != 0) { - size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(TestAllTypes other) { - if (other == null) { - return; - } - if (other.OptionalInt32 != 0) { - OptionalInt32 = other.OptionalInt32; - } - if (other.OptionalInt64 != 0L) { - OptionalInt64 = other.OptionalInt64; - } - if (other.OptionalUint32 != 0) { - OptionalUint32 = other.OptionalUint32; - } - if (other.OptionalUint64 != 0UL) { - OptionalUint64 = other.OptionalUint64; - } - if (other.OptionalSint32 != 0) { - OptionalSint32 = other.OptionalSint32; - } - if (other.OptionalSint64 != 0L) { - OptionalSint64 = other.OptionalSint64; - } - if (other.OptionalFixed32 != 0) { - OptionalFixed32 = other.OptionalFixed32; - } - if (other.OptionalFixed64 != 0UL) { - OptionalFixed64 = other.OptionalFixed64; - } - if (other.OptionalSfixed32 != 0) { - OptionalSfixed32 = other.OptionalSfixed32; - } - if (other.OptionalSfixed64 != 0L) { - OptionalSfixed64 = other.OptionalSfixed64; - } - if (other.OptionalFloat != 0F) { - OptionalFloat = other.OptionalFloat; - } - if (other.OptionalDouble != 0D) { - OptionalDouble = other.OptionalDouble; - } - if (other.OptionalBool != false) { - OptionalBool = other.OptionalBool; - } - if (other.OptionalString.Length != 0) { - OptionalString = other.OptionalString; - } - if (other.OptionalBytes.Length != 0) { - OptionalBytes = other.OptionalBytes; - } - if (other.optionalNestedMessage_ != null) { - if (optionalNestedMessage_ == null) { - optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage(); - } - OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage); - } - if (other.optionalForeignMessage_ != null) { - if (optionalForeignMessage_ == null) { - optionalForeignMessage_ = new global::Conformance.ForeignMessage(); - } - OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage); - } - if (other.OptionalNestedEnum != 0) { - OptionalNestedEnum = other.OptionalNestedEnum; - } - if (other.OptionalForeignEnum != 0) { - OptionalForeignEnum = other.OptionalForeignEnum; - } - if (other.OptionalStringPiece.Length != 0) { - OptionalStringPiece = other.OptionalStringPiece; - } - if (other.OptionalCord.Length != 0) { - OptionalCord = other.OptionalCord; - } - if (other.recursiveMessage_ != null) { - if (recursiveMessage_ == null) { - recursiveMessage_ = new global::Conformance.TestAllTypes(); - } - RecursiveMessage.MergeFrom(other.RecursiveMessage); - } - repeatedInt32_.Add(other.repeatedInt32_); - repeatedInt64_.Add(other.repeatedInt64_); - repeatedUint32_.Add(other.repeatedUint32_); - repeatedUint64_.Add(other.repeatedUint64_); - repeatedSint32_.Add(other.repeatedSint32_); - repeatedSint64_.Add(other.repeatedSint64_); - repeatedFixed32_.Add(other.repeatedFixed32_); - repeatedFixed64_.Add(other.repeatedFixed64_); - repeatedSfixed32_.Add(other.repeatedSfixed32_); - repeatedSfixed64_.Add(other.repeatedSfixed64_); - repeatedFloat_.Add(other.repeatedFloat_); - repeatedDouble_.Add(other.repeatedDouble_); - repeatedBool_.Add(other.repeatedBool_); - repeatedString_.Add(other.repeatedString_); - repeatedBytes_.Add(other.repeatedBytes_); - repeatedNestedMessage_.Add(other.repeatedNestedMessage_); - repeatedForeignMessage_.Add(other.repeatedForeignMessage_); - repeatedNestedEnum_.Add(other.repeatedNestedEnum_); - repeatedForeignEnum_.Add(other.repeatedForeignEnum_); - repeatedStringPiece_.Add(other.repeatedStringPiece_); - repeatedCord_.Add(other.repeatedCord_); - mapInt32Int32_.Add(other.mapInt32Int32_); - mapInt64Int64_.Add(other.mapInt64Int64_); - mapUint32Uint32_.Add(other.mapUint32Uint32_); - mapUint64Uint64_.Add(other.mapUint64Uint64_); - mapSint32Sint32_.Add(other.mapSint32Sint32_); - mapSint64Sint64_.Add(other.mapSint64Sint64_); - mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); - mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); - mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); - mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); - mapInt32Float_.Add(other.mapInt32Float_); - mapInt32Double_.Add(other.mapInt32Double_); - mapBoolBool_.Add(other.mapBoolBool_); - mapStringString_.Add(other.mapStringString_); - mapStringBytes_.Add(other.mapStringBytes_); - mapStringNestedMessage_.Add(other.mapStringNestedMessage_); - mapStringForeignMessage_.Add(other.mapStringForeignMessage_); - mapStringNestedEnum_.Add(other.mapStringNestedEnum_); - mapStringForeignEnum_.Add(other.mapStringForeignEnum_); - if (other.optionalBoolWrapper_ != null) { - if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) { - OptionalBoolWrapper = other.OptionalBoolWrapper; - } - } - if (other.optionalInt32Wrapper_ != null) { - if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) { - OptionalInt32Wrapper = other.OptionalInt32Wrapper; - } - } - if (other.optionalInt64Wrapper_ != null) { - if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) { - OptionalInt64Wrapper = other.OptionalInt64Wrapper; - } - } - if (other.optionalUint32Wrapper_ != null) { - if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) { - OptionalUint32Wrapper = other.OptionalUint32Wrapper; - } - } - if (other.optionalUint64Wrapper_ != null) { - if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) { - OptionalUint64Wrapper = other.OptionalUint64Wrapper; - } - } - if (other.optionalFloatWrapper_ != null) { - if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) { - OptionalFloatWrapper = other.OptionalFloatWrapper; - } - } - if (other.optionalDoubleWrapper_ != null) { - if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) { - OptionalDoubleWrapper = other.OptionalDoubleWrapper; - } - } - if (other.optionalStringWrapper_ != null) { - if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") { - OptionalStringWrapper = other.OptionalStringWrapper; - } - } - if (other.optionalBytesWrapper_ != null) { - if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) { - OptionalBytesWrapper = other.OptionalBytesWrapper; - } - } - repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_); - repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_); - repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_); - repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_); - repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_); - repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_); - repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_); - repeatedStringWrapper_.Add(other.repeatedStringWrapper_); - repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_); - if (other.optionalDuration_ != null) { - if (optionalDuration_ == null) { - optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); - } - OptionalDuration.MergeFrom(other.OptionalDuration); - } - if (other.optionalTimestamp_ != null) { - if (optionalTimestamp_ == null) { - optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); - } - OptionalTimestamp.MergeFrom(other.OptionalTimestamp); - } - if (other.optionalFieldMask_ != null) { - if (optionalFieldMask_ == null) { - optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); - } - OptionalFieldMask.MergeFrom(other.OptionalFieldMask); - } - if (other.optionalStruct_ != null) { - if (optionalStruct_ == null) { - optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - OptionalStruct.MergeFrom(other.OptionalStruct); - } - if (other.optionalAny_ != null) { - if (optionalAny_ == null) { - optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); - } - OptionalAny.MergeFrom(other.OptionalAny); - } - if (other.optionalValue_ != null) { - if (optionalValue_ == null) { - optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); - } - OptionalValue.MergeFrom(other.OptionalValue); - } - repeatedDuration_.Add(other.repeatedDuration_); - repeatedTimestamp_.Add(other.repeatedTimestamp_); - repeatedFieldmask_.Add(other.repeatedFieldmask_); - repeatedStruct_.Add(other.repeatedStruct_); - repeatedAny_.Add(other.repeatedAny_); - repeatedValue_.Add(other.repeatedValue_); - if (other.Fieldname1 != 0) { - Fieldname1 = other.Fieldname1; - } - if (other.FieldName2 != 0) { - FieldName2 = other.FieldName2; - } - if (other.FieldName3 != 0) { - FieldName3 = other.FieldName3; - } - if (other.FieldName4 != 0) { - FieldName4 = other.FieldName4; - } - if (other.Field0Name5 != 0) { - Field0Name5 = other.Field0Name5; - } - if (other.Field0Name6 != 0) { - Field0Name6 = other.Field0Name6; - } - if (other.FieldName7 != 0) { - FieldName7 = other.FieldName7; - } - if (other.FieldName8 != 0) { - FieldName8 = other.FieldName8; - } - if (other.FieldName9 != 0) { - FieldName9 = other.FieldName9; - } - if (other.FieldName10 != 0) { - FieldName10 = other.FieldName10; - } - if (other.FIELDNAME11 != 0) { - FIELDNAME11 = other.FIELDNAME11; - } - if (other.FIELDName12 != 0) { - FIELDName12 = other.FIELDName12; - } - if (other.FieldName13 != 0) { - FieldName13 = other.FieldName13; - } - if (other.FieldName14 != 0) { - FieldName14 = other.FieldName14; - } - if (other.FieldName15 != 0) { - FieldName15 = other.FieldName15; - } - if (other.FieldName16 != 0) { - FieldName16 = other.FieldName16; - } - if (other.FieldName17 != 0) { - FieldName17 = other.FieldName17; - } - if (other.FieldName18 != 0) { - FieldName18 = other.FieldName18; - } - switch (other.OneofFieldCase) { - case OneofFieldOneofCase.OneofUint32: - OneofUint32 = other.OneofUint32; - break; - case OneofFieldOneofCase.OneofNestedMessage: - OneofNestedMessage = other.OneofNestedMessage; - break; - case OneofFieldOneofCase.OneofString: - OneofString = other.OneofString; - break; - case OneofFieldOneofCase.OneofBytes: - OneofBytes = other.OneofBytes; - break; - case OneofFieldOneofCase.OneofBool: - OneofBool = other.OneofBool; - break; - case OneofFieldOneofCase.OneofUint64: - OneofUint64 = other.OneofUint64; - break; - case OneofFieldOneofCase.OneofFloat: - OneofFloat = other.OneofFloat; - break; - case OneofFieldOneofCase.OneofDouble: - OneofDouble = other.OneofDouble; - break; - case OneofFieldOneofCase.OneofEnum: - OneofEnum = other.OneofEnum; - break; - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - OptionalInt32 = input.ReadInt32(); - break; - } - case 16: { - OptionalInt64 = input.ReadInt64(); - break; - } - case 24: { - OptionalUint32 = input.ReadUInt32(); - break; - } - case 32: { - OptionalUint64 = input.ReadUInt64(); - break; - } - case 40: { - OptionalSint32 = input.ReadSInt32(); - break; - } - case 48: { - OptionalSint64 = input.ReadSInt64(); - break; - } - case 61: { - OptionalFixed32 = input.ReadFixed32(); - break; - } - case 65: { - OptionalFixed64 = input.ReadFixed64(); - break; - } - case 77: { - OptionalSfixed32 = input.ReadSFixed32(); - break; - } - case 81: { - OptionalSfixed64 = input.ReadSFixed64(); - break; - } - case 93: { - OptionalFloat = input.ReadFloat(); - break; - } - case 97: { - OptionalDouble = input.ReadDouble(); - break; - } - case 104: { - OptionalBool = input.ReadBool(); - break; - } - case 114: { - OptionalString = input.ReadString(); - break; - } - case 122: { - OptionalBytes = input.ReadBytes(); - break; - } - case 146: { - if (optionalNestedMessage_ == null) { - optionalNestedMessage_ = new global::Conformance.TestAllTypes.Types.NestedMessage(); - } - input.ReadMessage(optionalNestedMessage_); - break; - } - case 154: { - if (optionalForeignMessage_ == null) { - optionalForeignMessage_ = new global::Conformance.ForeignMessage(); - } - input.ReadMessage(optionalForeignMessage_); - break; - } - case 168: { - optionalNestedEnum_ = (global::Conformance.TestAllTypes.Types.NestedEnum) input.ReadEnum(); - break; - } - case 176: { - optionalForeignEnum_ = (global::Conformance.ForeignEnum) input.ReadEnum(); - break; - } - case 194: { - OptionalStringPiece = input.ReadString(); - break; - } - case 202: { - OptionalCord = input.ReadString(); - break; - } - case 218: { - if (recursiveMessage_ == null) { - recursiveMessage_ = new global::Conformance.TestAllTypes(); - } - input.ReadMessage(recursiveMessage_); - break; - } - case 250: - case 248: { - repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); - break; - } - case 258: - case 256: { - repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); - break; - } - case 266: - case 264: { - repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); - break; - } - case 274: - case 272: { - repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); - break; - } - case 282: - case 280: { - repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); - break; - } - case 290: - case 288: { - repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); - break; - } - case 298: - case 301: { - repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); - break; - } - case 306: - case 305: { - repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); - break; - } - case 314: - case 317: { - repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); - break; - } - case 322: - case 321: { - repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); - break; - } - case 330: - case 333: { - repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); - break; - } - case 338: - case 337: { - repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); - break; - } - case 346: - case 344: { - repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); - break; - } - case 354: { - repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); - break; - } - case 362: { - repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); - break; - } - case 386: { - repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); - break; - } - case 394: { - repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); - break; - } - case 410: - case 408: { - repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); - break; - } - case 418: - case 416: { - repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); - break; - } - case 434: { - repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); - break; - } - case 442: { - repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); - break; - } - case 450: { - mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); - break; - } - case 458: { - mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); - break; - } - case 466: { - mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); - break; - } - case 474: { - mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); - break; - } - case 482: { - mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); - break; - } - case 490: { - mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); - break; - } - case 498: { - mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); - break; - } - case 506: { - mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); - break; - } - case 514: { - mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); - break; - } - case 522: { - mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); - break; - } - case 530: { - mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); - break; - } - case 538: { - mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); - break; - } - case 546: { - mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); - break; - } - case 554: { - mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); - break; - } - case 562: { - mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); - break; - } - case 570: { - mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); - break; - } - case 578: { - mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); - break; - } - case 586: { - mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); - break; - } - case 594: { - mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); - break; - } - case 888: { - OneofUint32 = input.ReadUInt32(); - break; - } - case 898: { - global::Conformance.TestAllTypes.Types.NestedMessage subBuilder = new global::Conformance.TestAllTypes.Types.NestedMessage(); - if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { - subBuilder.MergeFrom(OneofNestedMessage); - } - input.ReadMessage(subBuilder); - OneofNestedMessage = subBuilder; - break; - } - case 906: { - OneofString = input.ReadString(); - break; - } - case 914: { - OneofBytes = input.ReadBytes(); - break; - } - case 920: { - OneofBool = input.ReadBool(); - break; - } - case 928: { - OneofUint64 = input.ReadUInt64(); - break; - } - case 941: { - OneofFloat = input.ReadFloat(); - break; - } - case 945: { - OneofDouble = input.ReadDouble(); - break; - } - case 952: { - oneofField_ = input.ReadEnum(); - oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; - break; - } - case 1610: { - bool? value = _single_optionalBoolWrapper_codec.Read(input); - if (optionalBoolWrapper_ == null || value != false) { - OptionalBoolWrapper = value; - } - break; - } - case 1618: { - int? value = _single_optionalInt32Wrapper_codec.Read(input); - if (optionalInt32Wrapper_ == null || value != 0) { - OptionalInt32Wrapper = value; - } - break; - } - case 1626: { - long? value = _single_optionalInt64Wrapper_codec.Read(input); - if (optionalInt64Wrapper_ == null || value != 0L) { - OptionalInt64Wrapper = value; - } - break; - } - case 1634: { - uint? value = _single_optionalUint32Wrapper_codec.Read(input); - if (optionalUint32Wrapper_ == null || value != 0) { - OptionalUint32Wrapper = value; - } - break; - } - case 1642: { - ulong? value = _single_optionalUint64Wrapper_codec.Read(input); - if (optionalUint64Wrapper_ == null || value != 0UL) { - OptionalUint64Wrapper = value; - } - break; - } - case 1650: { - float? value = _single_optionalFloatWrapper_codec.Read(input); - if (optionalFloatWrapper_ == null || value != 0F) { - OptionalFloatWrapper = value; - } - break; - } - case 1658: { - double? value = _single_optionalDoubleWrapper_codec.Read(input); - if (optionalDoubleWrapper_ == null || value != 0D) { - OptionalDoubleWrapper = value; - } - break; - } - case 1666: { - string value = _single_optionalStringWrapper_codec.Read(input); - if (optionalStringWrapper_ == null || value != "") { - OptionalStringWrapper = value; - } - break; - } - case 1674: { - pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input); - if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { - OptionalBytesWrapper = value; - } - break; - } - case 1690: { - repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec); - break; - } - case 1698: { - repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec); - break; - } - case 1706: { - repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec); - break; - } - case 1714: { - repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec); - break; - } - case 1722: { - repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec); - break; - } - case 1730: { - repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec); - break; - } - case 1738: { - repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec); - break; - } - case 1746: { - repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec); - break; - } - case 1754: { - repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec); - break; - } - case 2410: { - if (optionalDuration_ == null) { - optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); - } - input.ReadMessage(optionalDuration_); - break; - } - case 2418: { - if (optionalTimestamp_ == null) { - optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); - } - input.ReadMessage(optionalTimestamp_); - break; - } - case 2426: { - if (optionalFieldMask_ == null) { - optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); - } - input.ReadMessage(optionalFieldMask_); - break; - } - case 2434: { - if (optionalStruct_ == null) { - optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); - } - input.ReadMessage(optionalStruct_); - break; - } - case 2442: { - if (optionalAny_ == null) { - optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); - } - input.ReadMessage(optionalAny_); - break; - } - case 2450: { - if (optionalValue_ == null) { - optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); - } - input.ReadMessage(optionalValue_); - break; - } - case 2490: { - repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); - break; - } - case 2498: { - repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec); - break; - } - case 2506: { - repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec); - break; - } - case 2522: { - repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec); - break; - } - case 2530: { - repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec); - break; - } - case 2594: { - repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec); - break; - } - case 3208: { - Fieldname1 = input.ReadInt32(); - break; - } - case 3216: { - FieldName2 = input.ReadInt32(); - break; - } - case 3224: { - FieldName3 = input.ReadInt32(); - break; - } - case 3232: { - FieldName4 = input.ReadInt32(); - break; - } - case 3240: { - Field0Name5 = input.ReadInt32(); - break; - } - case 3248: { - Field0Name6 = input.ReadInt32(); - break; - } - case 3256: { - FieldName7 = input.ReadInt32(); - break; - } - case 3264: { - FieldName8 = input.ReadInt32(); - break; - } - case 3272: { - FieldName9 = input.ReadInt32(); - break; - } - case 3280: { - FieldName10 = input.ReadInt32(); - break; - } - case 3288: { - FIELDNAME11 = input.ReadInt32(); - break; - } - case 3296: { - FIELDName12 = input.ReadInt32(); - break; - } - case 3304: { - FieldName13 = input.ReadInt32(); - break; - } - case 3312: { - FieldName14 = input.ReadInt32(); - break; - } - case 3320: { - FieldName15 = input.ReadInt32(); - break; - } - case 3328: { - FieldName16 = input.ReadInt32(); - break; - } - case 3336: { - FieldName17 = input.ReadInt32(); - break; - } - case 3344: { - FieldName18 = input.ReadInt32(); - break; - } - } - } - } - - #region Nested types - /// <summary>Container for nested types declared in the TestAllTypes message type.</summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static partial class Types { - public enum NestedEnum { - [pbr::OriginalName("FOO")] Foo = 0, - [pbr::OriginalName("BAR")] Bar = 1, - [pbr::OriginalName("BAZ")] Baz = 2, - /// <summary> - /// Intentionally negative. - /// </summary> - [pbr::OriginalName("NEG")] Neg = -1, - } - - public sealed partial class NestedMessage : pb::IMessage<NestedMessage> { - private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.TestAllTypes.Descriptor.NestedTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage(NestedMessage other) : this() { - a_ = other.a_; - Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NestedMessage Clone() { - return new NestedMessage(this); - } - - /// <summary>Field number for the "a" field.</summary> - public const int AFieldNumber = 1; - private int a_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int A { - get { return a_; } - set { - a_ = value; - } - } - - /// <summary>Field number for the "corecursive" field.</summary> - public const int CorecursiveFieldNumber = 2; - private global::Conformance.TestAllTypes corecursive_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Conformance.TestAllTypes Corecursive { - get { return corecursive_; } - set { - corecursive_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as NestedMessage); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(NestedMessage other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (A != other.A) return false; - if (!object.Equals(Corecursive, other.Corecursive)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (A != 0) hash ^= A.GetHashCode(); - if (corecursive_ != null) hash ^= Corecursive.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (A != 0) { - output.WriteRawTag(8); - output.WriteInt32(A); - } - if (corecursive_ != null) { - output.WriteRawTag(18); - output.WriteMessage(Corecursive); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (A != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); - } - if (corecursive_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(NestedMessage other) { - if (other == null) { - return; - } - if (other.A != 0) { - A = other.A; - } - if (other.corecursive_ != null) { - if (corecursive_ == null) { - corecursive_ = new global::Conformance.TestAllTypes(); - } - Corecursive.MergeFrom(other.Corecursive); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - A = input.ReadInt32(); - break; - } - case 18: { - if (corecursive_ == null) { - corecursive_ = new global::Conformance.TestAllTypes(); - } - input.ReadMessage(corecursive_); - break; - } - } - } - } - - } - - } - #endregion - - } - - public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> { - private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Conformance.ConformanceReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ForeignMessage() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ForeignMessage(ForeignMessage other) : this() { - c_ = other.c_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public ForeignMessage Clone() { - return new ForeignMessage(this); - } - - /// <summary>Field number for the "c" field.</summary> - public const int CFieldNumber = 1; - private int c_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int C { - get { return c_; } - set { - c_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as ForeignMessage); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(ForeignMessage other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (C != other.C) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (C != 0) hash ^= C.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (C != 0) { - output.WriteRawTag(8); - output.WriteInt32(C); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (C != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(ForeignMessage other) { - if (other == null) { - return; - } - if (other.C != 0) { - C = other.C; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 8: { - C = input.ReadInt32(); - break; - } - } - } - } - - } - #endregion } diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs index 19827c48..00ee64f8 100644 --- a/csharp/src/Google.Protobuf.Conformance/Program.cs +++ b/csharp/src/Google.Protobuf.Conformance/Program.cs @@ -48,7 +48,7 @@ namespace Google.Protobuf.Conformance // This way we get the binary streams instead of readers/writers. var input = new BinaryReader(Console.OpenStandardInput()); var output = new BinaryWriter(Console.OpenStandardOutput()); - var typeRegistry = TypeRegistry.FromMessages(TestAllTypes.Descriptor); + var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypes.Descriptor); int count = 0; while (RunTest(input, output, typeRegistry)) @@ -81,17 +81,17 @@ namespace Google.Protobuf.Conformance private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry) { - TestAllTypes message; + ProtobufTestMessages.Proto3.TestAllTypes message; try { switch (request.PayloadCase) { case ConformanceRequest.PayloadOneofCase.JsonPayload: var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry)); - message = parser.Parse<TestAllTypes>(request.JsonPayload); + message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypes>(request.JsonPayload); break; case ConformanceRequest.PayloadOneofCase.ProtobufPayload: - message = TestAllTypes.Parser.ParseFrom(request.ProtobufPayload); + message = ProtobufTestMessages.Proto3.TestAllTypes.Parser.ParseFrom(request.ProtobufPayload); break; default: throw new Exception("Unsupported request payload: " + request.PayloadCase); diff --git a/csharp/src/Google.Protobuf.Conformance/project.json b/csharp/src/Google.Protobuf.Conformance/project.json index 84b23c45..4cf05231 100644 --- a/csharp/src/Google.Protobuf.Conformance/project.json +++ b/csharp/src/Google.Protobuf.Conformance/project.json @@ -4,10 +4,12 @@ "emitEntryPoint": true }, "dependencies": { - "Google.Protobuf": { "target": "project" } + "Google.Protobuf": { "target": "project" }, + "Google.Protobuf.Test": { "target": "project" } }, "frameworks": { "netcoreapp1.0": { + "imports": [ "dnxcore50", "netcoreapp1.0", "portable-net45+win8" ], "dependencies": { "Microsoft.NETCore.App": { "type": "platform", diff --git a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj index a9a1cc04..6370441e 100644 --- a/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj +++ b/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj @@ -11,9 +11,11 @@ <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> </PropertyGroup> - <PropertyGroup> <SchemaVersion>2.0</SchemaVersion> </PropertyGroup> + <ItemGroup> + <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> + </ItemGroup> <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> </Project>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs new file mode 100644 index 00000000..f519ba27 --- /dev/null +++ b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs @@ -0,0 +1,3688 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/protobuf/test_messages_proto3.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace ProtobufTestMessages.Proto3 { + + /// <summary>Holder for reflection information generated from google/protobuf/test_messages_proto3.proto</summary> + public static partial class TestMessagesProto3Reflection { + + #region Descriptor + /// <summary>File descriptor for google/protobuf/test_messages_proto3.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static TestMessagesProto3Reflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Cipnb29nbGUvcHJvdG9idWYvdGVzdF9tZXNzYWdlc19wcm90bzMucHJvdG8S", + "HXByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zGhlnb29nbGUvcHJvdG9i", + "dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a", + "IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv", + "dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w", + "LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8i+DkKDFRl", + "c3RBbGxUeXBlcxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5vcHRpb25h", + "bF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0SFwoPb3B0", + "aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgFIAEoERIX", + "Cg9vcHRpb25hbF9zaW50NjQYBiABKBISGAoQb3B0aW9uYWxfZml4ZWQzMhgH", + "IAEoBxIYChBvcHRpb25hbF9maXhlZDY0GAggASgGEhkKEW9wdGlvbmFsX3Nm", + "aXhlZDMyGAkgASgPEhkKEW9wdGlvbmFsX3NmaXhlZDY0GAogASgQEhYKDm9w", + "dGlvbmFsX2Zsb2F0GAsgASgCEhcKD29wdGlvbmFsX2RvdWJsZRgMIAEoARIV", + "Cg1vcHRpb25hbF9ib29sGA0gASgIEhcKD29wdGlvbmFsX3N0cmluZxgOIAEo", + "CRIWCg5vcHRpb25hbF9ieXRlcxgPIAEoDBJaChdvcHRpb25hbF9uZXN0ZWRf", + "bWVzc2FnZRgSIAEoCzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z", + "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlEk8KGG9wdGlvbmFsX2ZvcmVp", + "Z25fbWVzc2FnZRgTIAEoCzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJv", + "dG8zLkZvcmVpZ25NZXNzYWdlElQKFG9wdGlvbmFsX25lc3RlZF9lbnVtGBUg", + "ASgOMjYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5", + "cGVzLk5lc3RlZEVudW0SSQoVb3B0aW9uYWxfZm9yZWlnbl9lbnVtGBYgASgO", + "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW0S", + "IQoVb3B0aW9uYWxfc3RyaW5nX3BpZWNlGBggASgJQgIIAhIZCg1vcHRpb25h", + "bF9jb3JkGBkgASgJQgIIARJGChFyZWN1cnNpdmVfbWVzc2FnZRgbIAEoCzIr", + "LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcxIW", + "Cg5yZXBlYXRlZF9pbnQzMhgfIAMoBRIWCg5yZXBlYXRlZF9pbnQ2NBggIAMo", + "AxIXCg9yZXBlYXRlZF91aW50MzIYISADKA0SFwoPcmVwZWF0ZWRfdWludDY0", + "GCIgAygEEhcKD3JlcGVhdGVkX3NpbnQzMhgjIAMoERIXCg9yZXBlYXRlZF9z", + "aW50NjQYJCADKBISGAoQcmVwZWF0ZWRfZml4ZWQzMhglIAMoBxIYChByZXBl", + "YXRlZF9maXhlZDY0GCYgAygGEhkKEXJlcGVhdGVkX3NmaXhlZDMyGCcgAygP", + "EhkKEXJlcGVhdGVkX3NmaXhlZDY0GCggAygQEhYKDnJlcGVhdGVkX2Zsb2F0", + "GCkgAygCEhcKD3JlcGVhdGVkX2RvdWJsZRgqIAMoARIVCg1yZXBlYXRlZF9i", + "b29sGCsgAygIEhcKD3JlcGVhdGVkX3N0cmluZxgsIAMoCRIWCg5yZXBlYXRl", + "ZF9ieXRlcxgtIAMoDBJaChdyZXBlYXRlZF9uZXN0ZWRfbWVzc2FnZRgwIAMo", + "CzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBl", + "cy5OZXN0ZWRNZXNzYWdlEk8KGHJlcGVhdGVkX2ZvcmVpZ25fbWVzc2FnZRgx", + "IAMoCzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25N", + "ZXNzYWdlElQKFHJlcGVhdGVkX25lc3RlZF9lbnVtGDMgAygOMjYucHJvdG9i", + "dWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk5lc3RlZEVu", + "dW0SSQoVcmVwZWF0ZWRfZm9yZWlnbl9lbnVtGDQgAygOMioucHJvdG9idWZf", + "dGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW0SIQoVcmVwZWF0ZWRf", + "c3RyaW5nX3BpZWNlGDYgAygJQgIIAhIZCg1yZXBlYXRlZF9jb3JkGDcgAygJ", + "QgIIARJXCg9tYXBfaW50MzJfaW50MzIYOCADKAsyPi5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwSW50MzJJbnQzMkVu", + "dHJ5ElcKD21hcF9pbnQ2NF9pbnQ2NBg5IAMoCzI+LnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBJbnQ2NEludDY0RW50", + "cnkSWwoRbWFwX3VpbnQzMl91aW50MzIYOiADKAsyQC5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwVWludDMyVWludDMy", + "RW50cnkSWwoRbWFwX3VpbnQ2NF91aW50NjQYOyADKAsyQC5wcm90b2J1Zl90", + "ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwVWludDY0VWlu", + "dDY0RW50cnkSWwoRbWFwX3NpbnQzMl9zaW50MzIYPCADKAsyQC5wcm90b2J1", + "Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU2ludDMy", + "U2ludDMyRW50cnkSWwoRbWFwX3NpbnQ2NF9zaW50NjQYPSADKAsyQC5wcm90", + "b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU2lu", + "dDY0U2ludDY0RW50cnkSXwoTbWFwX2ZpeGVkMzJfZml4ZWQzMhg+IAMoCzJC", + "LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5N", + "YXBGaXhlZDMyRml4ZWQzMkVudHJ5El8KE21hcF9maXhlZDY0X2ZpeGVkNjQY", + "PyADKAsyQi5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxs", + "VHlwZXMuTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRJjChVtYXBfc2ZpeGVkMzJf", + "c2ZpeGVkMzIYQCADKAsyRC5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3Rv", + "My5UZXN0QWxsVHlwZXMuTWFwU2ZpeGVkMzJTZml4ZWQzMkVudHJ5EmMKFW1h", + "cF9zZml4ZWQ2NF9zZml4ZWQ2NBhBIAMoCzJELnByb3RvYnVmX3Rlc3RfbWVz", + "c2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBTZml4ZWQ2NFNmaXhlZDY0", + "RW50cnkSVwoPbWFwX2ludDMyX2Zsb2F0GEIgAygLMj4ucHJvdG9idWZfdGVz", + "dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcEludDMyRmxvYXRF", + "bnRyeRJZChBtYXBfaW50MzJfZG91YmxlGEMgAygLMj8ucHJvdG9idWZfdGVz", + "dF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcEludDMyRG91Ymxl", + "RW50cnkSUwoNbWFwX2Jvb2xfYm9vbBhEIAMoCzI8LnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5NYXBCb29sQm9vbEVudHJ5", + "ElsKEW1hcF9zdHJpbmdfc3RyaW5nGEUgAygLMkAucHJvdG9idWZfdGVzdF9t", + "ZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcFN0cmluZ1N0cmluZ0Vu", + "dHJ5ElkKEG1hcF9zdHJpbmdfYnl0ZXMYRiADKAsyPy5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nQnl0ZXNF", + "bnRyeRJqChltYXBfc3RyaW5nX25lc3RlZF9tZXNzYWdlGEcgAygLMkcucHJv", + "dG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1hcFN0", + "cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRJsChptYXBfc3RyaW5nX2ZvcmVpZ25f", + "bWVzc2FnZRhIIAMoCzJILnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z", + "LlRlc3RBbGxUeXBlcy5NYXBTdHJpbmdGb3JlaWduTWVzc2FnZUVudHJ5EmQK", + "Fm1hcF9zdHJpbmdfbmVzdGVkX2VudW0YSSADKAsyRC5wcm90b2J1Zl90ZXN0", + "X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTWFwU3RyaW5nTmVzdGVk", + "RW51bUVudHJ5EmYKF21hcF9zdHJpbmdfZm9yZWlnbl9lbnVtGEogAygLMkUu", + "cHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuVGVzdEFsbFR5cGVzLk1h", + "cFN0cmluZ0ZvcmVpZ25FbnVtRW50cnkSFgoMb25lb2ZfdWludDMyGG8gASgN", + "SAASWQoUb25lb2ZfbmVzdGVkX21lc3NhZ2UYcCABKAsyOS5wcm90b2J1Zl90", + "ZXN0X21lc3NhZ2VzLnByb3RvMy5UZXN0QWxsVHlwZXMuTmVzdGVkTWVzc2Fn", + "ZUgAEhYKDG9uZW9mX3N0cmluZxhxIAEoCUgAEhUKC29uZW9mX2J5dGVzGHIg", + "ASgMSAASFAoKb25lb2ZfYm9vbBhzIAEoCEgAEhYKDG9uZW9mX3VpbnQ2NBh0", + "IAEoBEgAEhUKC29uZW9mX2Zsb2F0GHUgASgCSAASFgoMb25lb2ZfZG91Ymxl", + "GHYgASgBSAASTAoKb25lb2ZfZW51bRh3IAEoDjI2LnByb3RvYnVmX3Rlc3Rf", + "bWVzc2FnZXMucHJvdG8zLlRlc3RBbGxUeXBlcy5OZXN0ZWRFbnVtSAASOgoV", + "b3B0aW9uYWxfYm9vbF93cmFwcGVyGMkBIAEoCzIaLmdvb2dsZS5wcm90b2J1", + "Zi5Cb29sVmFsdWUSPAoWb3B0aW9uYWxfaW50MzJfd3JhcHBlchjKASABKAsy", + "Gy5nb29nbGUucHJvdG9idWYuSW50MzJWYWx1ZRI8ChZvcHRpb25hbF9pbnQ2", + "NF93cmFwcGVyGMsBIAEoCzIbLmdvb2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVl", + "Ej4KF29wdGlvbmFsX3VpbnQzMl93cmFwcGVyGMwBIAEoCzIcLmdvb2dsZS5w", + "cm90b2J1Zi5VSW50MzJWYWx1ZRI+ChdvcHRpb25hbF91aW50NjRfd3JhcHBl", + "chjNASABKAsyHC5nb29nbGUucHJvdG9idWYuVUludDY0VmFsdWUSPAoWb3B0", + "aW9uYWxfZmxvYXRfd3JhcHBlchjOASABKAsyGy5nb29nbGUucHJvdG9idWYu", + "RmxvYXRWYWx1ZRI+ChdvcHRpb25hbF9kb3VibGVfd3JhcHBlchjPASABKAsy", + "HC5nb29nbGUucHJvdG9idWYuRG91YmxlVmFsdWUSPgoXb3B0aW9uYWxfc3Ry", + "aW5nX3dyYXBwZXIY0AEgASgLMhwuZ29vZ2xlLnByb3RvYnVmLlN0cmluZ1Zh", + "bHVlEjwKFm9wdGlvbmFsX2J5dGVzX3dyYXBwZXIY0QEgASgLMhsuZ29vZ2xl", + "LnByb3RvYnVmLkJ5dGVzVmFsdWUSOgoVcmVwZWF0ZWRfYm9vbF93cmFwcGVy", + "GNMBIAMoCzIaLmdvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUSPAoWcmVwZWF0", + "ZWRfaW50MzJfd3JhcHBlchjUASADKAsyGy5nb29nbGUucHJvdG9idWYuSW50", + "MzJWYWx1ZRI8ChZyZXBlYXRlZF9pbnQ2NF93cmFwcGVyGNUBIAMoCzIbLmdv", + "b2dsZS5wcm90b2J1Zi5JbnQ2NFZhbHVlEj4KF3JlcGVhdGVkX3VpbnQzMl93", + "cmFwcGVyGNYBIAMoCzIcLmdvb2dsZS5wcm90b2J1Zi5VSW50MzJWYWx1ZRI+", + "ChdyZXBlYXRlZF91aW50NjRfd3JhcHBlchjXASADKAsyHC5nb29nbGUucHJv", + "dG9idWYuVUludDY0VmFsdWUSPAoWcmVwZWF0ZWRfZmxvYXRfd3JhcHBlchjY", + "ASADKAsyGy5nb29nbGUucHJvdG9idWYuRmxvYXRWYWx1ZRI+ChdyZXBlYXRl", + "ZF9kb3VibGVfd3JhcHBlchjZASADKAsyHC5nb29nbGUucHJvdG9idWYuRG91", + "YmxlVmFsdWUSPgoXcmVwZWF0ZWRfc3RyaW5nX3dyYXBwZXIY2gEgAygLMhwu", + "Z29vZ2xlLnByb3RvYnVmLlN0cmluZ1ZhbHVlEjwKFnJlcGVhdGVkX2J5dGVz", + "X3dyYXBwZXIY2wEgAygLMhsuZ29vZ2xlLnByb3RvYnVmLkJ5dGVzVmFsdWUS", + "NQoRb3B0aW9uYWxfZHVyYXRpb24YrQIgASgLMhkuZ29vZ2xlLnByb3RvYnVm", + "LkR1cmF0aW9uEjcKEm9wdGlvbmFsX3RpbWVzdGFtcBiuAiABKAsyGi5nb29n", + "bGUucHJvdG9idWYuVGltZXN0YW1wEjgKE29wdGlvbmFsX2ZpZWxkX21hc2sY", + "rwIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIxCg9vcHRpb25h", + "bF9zdHJ1Y3QYsAIgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBIrCgxv", + "cHRpb25hbF9hbnkYsQIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRIvCg5v", + "cHRpb25hbF92YWx1ZRiyAiABKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUS", + "NQoRcmVwZWF0ZWRfZHVyYXRpb24YtwIgAygLMhkuZ29vZ2xlLnByb3RvYnVm", + "LkR1cmF0aW9uEjcKEnJlcGVhdGVkX3RpbWVzdGFtcBi4AiADKAsyGi5nb29n", + "bGUucHJvdG9idWYuVGltZXN0YW1wEjcKEnJlcGVhdGVkX2ZpZWxkbWFzaxi5", + "AiADKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrEjEKD3JlcGVhdGVk", + "X3N0cnVjdBjEAiADKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EisKDHJl", + "cGVhdGVkX2FueRi7AiADKAsyFC5nb29nbGUucHJvdG9idWYuQW55Ei8KDnJl", + "cGVhdGVkX3ZhbHVlGLwCIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZRIT", + "CgpmaWVsZG5hbWUxGJEDIAEoBRIUCgtmaWVsZF9uYW1lMhiSAyABKAUSFQoM", + "X2ZpZWxkX25hbWUzGJMDIAEoBRIWCg1maWVsZF9fbmFtZTRfGJQDIAEoBRIU", + "CgtmaWVsZDBuYW1lNRiVAyABKAUSFgoNZmllbGRfMF9uYW1lNhiWAyABKAUS", + "EwoKZmllbGROYW1lNxiXAyABKAUSEwoKRmllbGROYW1lOBiYAyABKAUSFAoL", + "ZmllbGRfTmFtZTkYmQMgASgFEhUKDEZpZWxkX05hbWUxMBiaAyABKAUSFQoM", + "RklFTERfTkFNRTExGJsDIAEoBRIVCgxGSUVMRF9uYW1lMTIYnAMgASgFEhcK", + "Dl9fZmllbGRfbmFtZTEzGJ0DIAEoBRIXCg5fX0ZpZWxkX25hbWUxNBieAyAB", + "KAUSFgoNZmllbGRfX25hbWUxNRifAyABKAUSFgoNZmllbGRfX05hbWUxNhig", + "AyABKAUSFwoOZmllbGRfbmFtZTE3X18YoQMgASgFEhcKDkZpZWxkX25hbWUx", + "OF9fGKIDIAEoBRpcCg1OZXN0ZWRNZXNzYWdlEgkKAWEYASABKAUSQAoLY29y", + "ZWN1cnNpdmUYAiABKAsyKy5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3Rv", + "My5UZXN0QWxsVHlwZXMaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tleRgB", + "IAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVudHJ5", + "EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWludDMy", + "VWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4ARo2", + "ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFsdWUY", + "AiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgBIAEo", + "ERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50cnkS", + "CwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhlZDMy", + "Rml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoCOAEa", + "OAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoFdmFs", + "dWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRILCgNr", + "ZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0U2Zp", + "eGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgBGjQK", + "Ek1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiAB", + "KAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgFEg0K", + "BXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tleRgB", + "IAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5nRW50", + "cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo1ChNNYXBTdHJp", + "bmdCeXRlc0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoDDoCOAEa", + "eAobTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRJI", + "CgV2YWx1ZRgCIAEoCzI5LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8z", + "LlRlc3RBbGxUeXBlcy5OZXN0ZWRNZXNzYWdlOgI4ARptChxNYXBTdHJpbmdG", + "b3JlaWduTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRI8CgV2YWx1ZRgCIAEo", + "CzItLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zLkZvcmVpZ25NZXNz", + "YWdlOgI4ARpyChhNYXBTdHJpbmdOZXN0ZWRFbnVtRW50cnkSCwoDa2V5GAEg", + "ASgJEkUKBXZhbHVlGAIgASgOMjYucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w", + "cm90bzMuVGVzdEFsbFR5cGVzLk5lc3RlZEVudW06AjgBGmcKGU1hcFN0cmlu", + "Z0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEgASgJEjkKBXZhbHVlGAIgASgO", + "MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW06", + "AjgBIjkKCk5lc3RlZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAIS", + "EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGQiGwoORm9yZWlnbk1l", + "c3NhZ2USCQoBYxgBIAEoBSpACgtGb3JlaWduRW51bRIPCgtGT1JFSUdOX0ZP", + "TxAAEg8KC0ZPUkVJR05fQkFSEAESDwoLRk9SRUlHTl9CQVoQAkIvCihjb20u", + "Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zSAH4AQFiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypes), global::ProtobufTestMessages.Proto3.TestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "OptionalBoolWrapper", "OptionalInt32Wrapper", "OptionalInt64Wrapper", "OptionalUint32Wrapper", "OptionalUint64Wrapper", "OptionalFloatWrapper", "OptionalDoubleWrapper", "OptionalStringWrapper", "OptionalBytesWrapper", "RepeatedBoolWrapper", "RepeatedInt32Wrapper", "RepeatedInt64Wrapper", "RepeatedUint32Wrapper", "RepeatedUint64Wrapper", "RepeatedFloatWrapper", "RepeatedDoubleWrapper", "RepeatedStringWrapper", "RepeatedBytesWrapper", "OptionalDuration", "OptionalTimestamp", "OptionalFieldMask", "OptionalStruct", "OptionalAny", "OptionalValue", "RepeatedDuration", "RepeatedTimestamp", "RepeatedFieldmask", "RepeatedStruct", "RepeatedAny", "RepeatedValue", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage), global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null), + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, }), + new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto3.ForeignMessage), global::ProtobufTestMessages.Proto3.ForeignMessage.Parser, new[]{ "C" }, null, null, null) + })); + } + #endregion + + } + #region Enums + public enum ForeignEnum { + [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0, + [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1, + [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2, + } + + #endregion + + #region Messages + /// <summary> + /// This proto includes every type of field in both singular and repeated + /// forms. + /// + /// Also, crucially, all messages and enums in this file are eventually + /// submessages of this message. So for example, a fuzz test of TestAllTypes + /// could trigger bugs that occur in any message type in this file. We verify + /// this stays true in a unit test. + /// </summary> + public sealed partial class TestAllTypes : pb::IMessage<TestAllTypes> { + private static readonly pb::MessageParser<TestAllTypes> _parser = new pb::MessageParser<TestAllTypes>(() => new TestAllTypes()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<TestAllTypes> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypes() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypes(TestAllTypes other) : this() { + optionalInt32_ = other.optionalInt32_; + optionalInt64_ = other.optionalInt64_; + optionalUint32_ = other.optionalUint32_; + optionalUint64_ = other.optionalUint64_; + optionalSint32_ = other.optionalSint32_; + optionalSint64_ = other.optionalSint64_; + optionalFixed32_ = other.optionalFixed32_; + optionalFixed64_ = other.optionalFixed64_; + optionalSfixed32_ = other.optionalSfixed32_; + optionalSfixed64_ = other.optionalSfixed64_; + optionalFloat_ = other.optionalFloat_; + optionalDouble_ = other.optionalDouble_; + optionalBool_ = other.optionalBool_; + optionalString_ = other.optionalString_; + optionalBytes_ = other.optionalBytes_; + OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null; + OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null; + optionalNestedEnum_ = other.optionalNestedEnum_; + optionalForeignEnum_ = other.optionalForeignEnum_; + optionalStringPiece_ = other.optionalStringPiece_; + optionalCord_ = other.optionalCord_; + RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null; + repeatedInt32_ = other.repeatedInt32_.Clone(); + repeatedInt64_ = other.repeatedInt64_.Clone(); + repeatedUint32_ = other.repeatedUint32_.Clone(); + repeatedUint64_ = other.repeatedUint64_.Clone(); + repeatedSint32_ = other.repeatedSint32_.Clone(); + repeatedSint64_ = other.repeatedSint64_.Clone(); + repeatedFixed32_ = other.repeatedFixed32_.Clone(); + repeatedFixed64_ = other.repeatedFixed64_.Clone(); + repeatedSfixed32_ = other.repeatedSfixed32_.Clone(); + repeatedSfixed64_ = other.repeatedSfixed64_.Clone(); + repeatedFloat_ = other.repeatedFloat_.Clone(); + repeatedDouble_ = other.repeatedDouble_.Clone(); + repeatedBool_ = other.repeatedBool_.Clone(); + repeatedString_ = other.repeatedString_.Clone(); + repeatedBytes_ = other.repeatedBytes_.Clone(); + repeatedNestedMessage_ = other.repeatedNestedMessage_.Clone(); + repeatedForeignMessage_ = other.repeatedForeignMessage_.Clone(); + repeatedNestedEnum_ = other.repeatedNestedEnum_.Clone(); + repeatedForeignEnum_ = other.repeatedForeignEnum_.Clone(); + repeatedStringPiece_ = other.repeatedStringPiece_.Clone(); + repeatedCord_ = other.repeatedCord_.Clone(); + mapInt32Int32_ = other.mapInt32Int32_.Clone(); + mapInt64Int64_ = other.mapInt64Int64_.Clone(); + mapUint32Uint32_ = other.mapUint32Uint32_.Clone(); + mapUint64Uint64_ = other.mapUint64Uint64_.Clone(); + mapSint32Sint32_ = other.mapSint32Sint32_.Clone(); + mapSint64Sint64_ = other.mapSint64Sint64_.Clone(); + mapFixed32Fixed32_ = other.mapFixed32Fixed32_.Clone(); + mapFixed64Fixed64_ = other.mapFixed64Fixed64_.Clone(); + mapSfixed32Sfixed32_ = other.mapSfixed32Sfixed32_.Clone(); + mapSfixed64Sfixed64_ = other.mapSfixed64Sfixed64_.Clone(); + mapInt32Float_ = other.mapInt32Float_.Clone(); + mapInt32Double_ = other.mapInt32Double_.Clone(); + mapBoolBool_ = other.mapBoolBool_.Clone(); + mapStringString_ = other.mapStringString_.Clone(); + mapStringBytes_ = other.mapStringBytes_.Clone(); + mapStringNestedMessage_ = other.mapStringNestedMessage_.Clone(); + mapStringForeignMessage_ = other.mapStringForeignMessage_.Clone(); + mapStringNestedEnum_ = other.mapStringNestedEnum_.Clone(); + mapStringForeignEnum_ = other.mapStringForeignEnum_.Clone(); + OptionalBoolWrapper = other.OptionalBoolWrapper; + OptionalInt32Wrapper = other.OptionalInt32Wrapper; + OptionalInt64Wrapper = other.OptionalInt64Wrapper; + OptionalUint32Wrapper = other.OptionalUint32Wrapper; + OptionalUint64Wrapper = other.OptionalUint64Wrapper; + OptionalFloatWrapper = other.OptionalFloatWrapper; + OptionalDoubleWrapper = other.OptionalDoubleWrapper; + OptionalStringWrapper = other.OptionalStringWrapper; + OptionalBytesWrapper = other.OptionalBytesWrapper; + repeatedBoolWrapper_ = other.repeatedBoolWrapper_.Clone(); + repeatedInt32Wrapper_ = other.repeatedInt32Wrapper_.Clone(); + repeatedInt64Wrapper_ = other.repeatedInt64Wrapper_.Clone(); + repeatedUint32Wrapper_ = other.repeatedUint32Wrapper_.Clone(); + repeatedUint64Wrapper_ = other.repeatedUint64Wrapper_.Clone(); + repeatedFloatWrapper_ = other.repeatedFloatWrapper_.Clone(); + repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); + repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); + repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); + OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null; + OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null; + OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null; + OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null; + OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null; + OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null; + repeatedDuration_ = other.repeatedDuration_.Clone(); + repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); + repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); + repeatedStruct_ = other.repeatedStruct_.Clone(); + repeatedAny_ = other.repeatedAny_.Clone(); + repeatedValue_ = other.repeatedValue_.Clone(); + fieldname1_ = other.fieldname1_; + fieldName2_ = other.fieldName2_; + FieldName3_ = other.FieldName3_; + fieldName4_ = other.fieldName4_; + field0Name5_ = other.field0Name5_; + field0Name6_ = other.field0Name6_; + fieldName7_ = other.fieldName7_; + fieldName8_ = other.fieldName8_; + fieldName9_ = other.fieldName9_; + fieldName10_ = other.fieldName10_; + fIELDNAME11_ = other.fIELDNAME11_; + fIELDName12_ = other.fIELDName12_; + FieldName13_ = other.FieldName13_; + FieldName14_ = other.FieldName14_; + fieldName15_ = other.fieldName15_; + fieldName16_ = other.fieldName16_; + fieldName17_ = other.fieldName17_; + fieldName18_ = other.fieldName18_; + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage.Clone(); + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + case OneofFieldOneofCase.OneofBool: + OneofBool = other.OneofBool; + break; + case OneofFieldOneofCase.OneofUint64: + OneofUint64 = other.OneofUint64; + break; + case OneofFieldOneofCase.OneofFloat: + OneofFloat = other.OneofFloat; + break; + case OneofFieldOneofCase.OneofDouble: + OneofDouble = other.OneofDouble; + break; + case OneofFieldOneofCase.OneofEnum: + OneofEnum = other.OneofEnum; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public TestAllTypes Clone() { + return new TestAllTypes(this); + } + + /// <summary>Field number for the "optional_int32" field.</summary> + public const int OptionalInt32FieldNumber = 1; + private int optionalInt32_; + /// <summary> + /// Singular + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalInt32 { + get { return optionalInt32_; } + set { + optionalInt32_ = value; + } + } + + /// <summary>Field number for the "optional_int64" field.</summary> + public const int OptionalInt64FieldNumber = 2; + private long optionalInt64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalInt64 { + get { return optionalInt64_; } + set { + optionalInt64_ = value; + } + } + + /// <summary>Field number for the "optional_uint32" field.</summary> + public const int OptionalUint32FieldNumber = 3; + private uint optionalUint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OptionalUint32 { + get { return optionalUint32_; } + set { + optionalUint32_ = value; + } + } + + /// <summary>Field number for the "optional_uint64" field.</summary> + public const int OptionalUint64FieldNumber = 4; + private ulong optionalUint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OptionalUint64 { + get { return optionalUint64_; } + set { + optionalUint64_ = value; + } + } + + /// <summary>Field number for the "optional_sint32" field.</summary> + public const int OptionalSint32FieldNumber = 5; + private int optionalSint32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalSint32 { + get { return optionalSint32_; } + set { + optionalSint32_ = value; + } + } + + /// <summary>Field number for the "optional_sint64" field.</summary> + public const int OptionalSint64FieldNumber = 6; + private long optionalSint64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalSint64 { + get { return optionalSint64_; } + set { + optionalSint64_ = value; + } + } + + /// <summary>Field number for the "optional_fixed32" field.</summary> + public const int OptionalFixed32FieldNumber = 7; + private uint optionalFixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OptionalFixed32 { + get { return optionalFixed32_; } + set { + optionalFixed32_ = value; + } + } + + /// <summary>Field number for the "optional_fixed64" field.</summary> + public const int OptionalFixed64FieldNumber = 8; + private ulong optionalFixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OptionalFixed64 { + get { return optionalFixed64_; } + set { + optionalFixed64_ = value; + } + } + + /// <summary>Field number for the "optional_sfixed32" field.</summary> + public const int OptionalSfixed32FieldNumber = 9; + private int optionalSfixed32_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int OptionalSfixed32 { + get { return optionalSfixed32_; } + set { + optionalSfixed32_ = value; + } + } + + /// <summary>Field number for the "optional_sfixed64" field.</summary> + public const int OptionalSfixed64FieldNumber = 10; + private long optionalSfixed64_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long OptionalSfixed64 { + get { return optionalSfixed64_; } + set { + optionalSfixed64_ = value; + } + } + + /// <summary>Field number for the "optional_float" field.</summary> + public const int OptionalFloatFieldNumber = 11; + private float optionalFloat_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float OptionalFloat { + get { return optionalFloat_; } + set { + optionalFloat_ = value; + } + } + + /// <summary>Field number for the "optional_double" field.</summary> + public const int OptionalDoubleFieldNumber = 12; + private double optionalDouble_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double OptionalDouble { + get { return optionalDouble_; } + set { + optionalDouble_ = value; + } + } + + /// <summary>Field number for the "optional_bool" field.</summary> + public const int OptionalBoolFieldNumber = 13; + private bool optionalBool_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool OptionalBool { + get { return optionalBool_; } + set { + optionalBool_ = value; + } + } + + /// <summary>Field number for the "optional_string" field.</summary> + public const int OptionalStringFieldNumber = 14; + private string optionalString_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalString { + get { return optionalString_; } + set { + optionalString_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "optional_bytes" field.</summary> + public const int OptionalBytesFieldNumber = 15; + private pb::ByteString optionalBytes_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OptionalBytes { + get { return optionalBytes_; } + set { + optionalBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "optional_nested_message" field.</summary> + public const int OptionalNestedMessageFieldNumber = 18; + private global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage optionalNestedMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage OptionalNestedMessage { + get { return optionalNestedMessage_; } + set { + optionalNestedMessage_ = value; + } + } + + /// <summary>Field number for the "optional_foreign_message" field.</summary> + public const int OptionalForeignMessageFieldNumber = 19; + private global::ProtobufTestMessages.Proto3.ForeignMessage optionalForeignMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.ForeignMessage OptionalForeignMessage { + get { return optionalForeignMessage_; } + set { + optionalForeignMessage_ = value; + } + } + + /// <summary>Field number for the "optional_nested_enum" field.</summary> + public const int OptionalNestedEnumFieldNumber = 21; + private global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum OptionalNestedEnum { + get { return optionalNestedEnum_; } + set { + optionalNestedEnum_ = value; + } + } + + /// <summary>Field number for the "optional_foreign_enum" field.</summary> + public const int OptionalForeignEnumFieldNumber = 22; + private global::ProtobufTestMessages.Proto3.ForeignEnum optionalForeignEnum_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.ForeignEnum OptionalForeignEnum { + get { return optionalForeignEnum_; } + set { + optionalForeignEnum_ = value; + } + } + + /// <summary>Field number for the "optional_string_piece" field.</summary> + public const int OptionalStringPieceFieldNumber = 24; + private string optionalStringPiece_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalStringPiece { + get { return optionalStringPiece_; } + set { + optionalStringPiece_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "optional_cord" field.</summary> + public const int OptionalCordFieldNumber = 25; + private string optionalCord_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalCord { + get { return optionalCord_; } + set { + optionalCord_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "recursive_message" field.</summary> + public const int RecursiveMessageFieldNumber = 27; + private global::ProtobufTestMessages.Proto3.TestAllTypes recursiveMessage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes RecursiveMessage { + get { return recursiveMessage_; } + set { + recursiveMessage_ = value; + } + } + + /// <summary>Field number for the "repeated_int32" field.</summary> + public const int RepeatedInt32FieldNumber = 31; + private static readonly pb::FieldCodec<int> _repeated_repeatedInt32_codec + = pb::FieldCodec.ForInt32(250); + private readonly pbc::RepeatedField<int> repeatedInt32_ = new pbc::RepeatedField<int>(); + /// <summary> + /// Repeated + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<int> RepeatedInt32 { + get { return repeatedInt32_; } + } + + /// <summary>Field number for the "repeated_int64" field.</summary> + public const int RepeatedInt64FieldNumber = 32; + private static readonly pb::FieldCodec<long> _repeated_repeatedInt64_codec + = pb::FieldCodec.ForInt64(258); + private readonly pbc::RepeatedField<long> repeatedInt64_ = new pbc::RepeatedField<long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<long> RepeatedInt64 { + get { return repeatedInt64_; } + } + + /// <summary>Field number for the "repeated_uint32" field.</summary> + public const int RepeatedUint32FieldNumber = 33; + private static readonly pb::FieldCodec<uint> _repeated_repeatedUint32_codec + = pb::FieldCodec.ForUInt32(266); + private readonly pbc::RepeatedField<uint> repeatedUint32_ = new pbc::RepeatedField<uint>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<uint> RepeatedUint32 { + get { return repeatedUint32_; } + } + + /// <summary>Field number for the "repeated_uint64" field.</summary> + public const int RepeatedUint64FieldNumber = 34; + private static readonly pb::FieldCodec<ulong> _repeated_repeatedUint64_codec + = pb::FieldCodec.ForUInt64(274); + private readonly pbc::RepeatedField<ulong> repeatedUint64_ = new pbc::RepeatedField<ulong>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<ulong> RepeatedUint64 { + get { return repeatedUint64_; } + } + + /// <summary>Field number for the "repeated_sint32" field.</summary> + public const int RepeatedSint32FieldNumber = 35; + private static readonly pb::FieldCodec<int> _repeated_repeatedSint32_codec + = pb::FieldCodec.ForSInt32(282); + private readonly pbc::RepeatedField<int> repeatedSint32_ = new pbc::RepeatedField<int>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<int> RepeatedSint32 { + get { return repeatedSint32_; } + } + + /// <summary>Field number for the "repeated_sint64" field.</summary> + public const int RepeatedSint64FieldNumber = 36; + private static readonly pb::FieldCodec<long> _repeated_repeatedSint64_codec + = pb::FieldCodec.ForSInt64(290); + private readonly pbc::RepeatedField<long> repeatedSint64_ = new pbc::RepeatedField<long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<long> RepeatedSint64 { + get { return repeatedSint64_; } + } + + /// <summary>Field number for the "repeated_fixed32" field.</summary> + public const int RepeatedFixed32FieldNumber = 37; + private static readonly pb::FieldCodec<uint> _repeated_repeatedFixed32_codec + = pb::FieldCodec.ForFixed32(298); + private readonly pbc::RepeatedField<uint> repeatedFixed32_ = new pbc::RepeatedField<uint>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<uint> RepeatedFixed32 { + get { return repeatedFixed32_; } + } + + /// <summary>Field number for the "repeated_fixed64" field.</summary> + public const int RepeatedFixed64FieldNumber = 38; + private static readonly pb::FieldCodec<ulong> _repeated_repeatedFixed64_codec + = pb::FieldCodec.ForFixed64(306); + private readonly pbc::RepeatedField<ulong> repeatedFixed64_ = new pbc::RepeatedField<ulong>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<ulong> RepeatedFixed64 { + get { return repeatedFixed64_; } + } + + /// <summary>Field number for the "repeated_sfixed32" field.</summary> + public const int RepeatedSfixed32FieldNumber = 39; + private static readonly pb::FieldCodec<int> _repeated_repeatedSfixed32_codec + = pb::FieldCodec.ForSFixed32(314); + private readonly pbc::RepeatedField<int> repeatedSfixed32_ = new pbc::RepeatedField<int>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<int> RepeatedSfixed32 { + get { return repeatedSfixed32_; } + } + + /// <summary>Field number for the "repeated_sfixed64" field.</summary> + public const int RepeatedSfixed64FieldNumber = 40; + private static readonly pb::FieldCodec<long> _repeated_repeatedSfixed64_codec + = pb::FieldCodec.ForSFixed64(322); + private readonly pbc::RepeatedField<long> repeatedSfixed64_ = new pbc::RepeatedField<long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<long> RepeatedSfixed64 { + get { return repeatedSfixed64_; } + } + + /// <summary>Field number for the "repeated_float" field.</summary> + public const int RepeatedFloatFieldNumber = 41; + private static readonly pb::FieldCodec<float> _repeated_repeatedFloat_codec + = pb::FieldCodec.ForFloat(330); + private readonly pbc::RepeatedField<float> repeatedFloat_ = new pbc::RepeatedField<float>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<float> RepeatedFloat { + get { return repeatedFloat_; } + } + + /// <summary>Field number for the "repeated_double" field.</summary> + public const int RepeatedDoubleFieldNumber = 42; + private static readonly pb::FieldCodec<double> _repeated_repeatedDouble_codec + = pb::FieldCodec.ForDouble(338); + private readonly pbc::RepeatedField<double> repeatedDouble_ = new pbc::RepeatedField<double>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<double> RepeatedDouble { + get { return repeatedDouble_; } + } + + /// <summary>Field number for the "repeated_bool" field.</summary> + public const int RepeatedBoolFieldNumber = 43; + private static readonly pb::FieldCodec<bool> _repeated_repeatedBool_codec + = pb::FieldCodec.ForBool(346); + private readonly pbc::RepeatedField<bool> repeatedBool_ = new pbc::RepeatedField<bool>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<bool> RepeatedBool { + get { return repeatedBool_; } + } + + /// <summary>Field number for the "repeated_string" field.</summary> + public const int RepeatedStringFieldNumber = 44; + private static readonly pb::FieldCodec<string> _repeated_repeatedString_codec + = pb::FieldCodec.ForString(354); + private readonly pbc::RepeatedField<string> repeatedString_ = new pbc::RepeatedField<string>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<string> RepeatedString { + get { return repeatedString_; } + } + + /// <summary>Field number for the "repeated_bytes" field.</summary> + public const int RepeatedBytesFieldNumber = 45; + private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytes_codec + = pb::FieldCodec.ForBytes(362); + private readonly pbc::RepeatedField<pb::ByteString> repeatedBytes_ = new pbc::RepeatedField<pb::ByteString>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<pb::ByteString> RepeatedBytes { + get { return repeatedBytes_; } + } + + /// <summary>Field number for the "repeated_nested_message" field.</summary> + public const int RepeatedNestedMessageFieldNumber = 48; + private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> _repeated_repeatedNestedMessage_codec + = pb::FieldCodec.ForMessage(386, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser); + private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> repeatedNestedMessage_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> RepeatedNestedMessage { + get { return repeatedNestedMessage_; } + } + + /// <summary>Field number for the "repeated_foreign_message" field.</summary> + public const int RepeatedForeignMessageFieldNumber = 49; + private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.ForeignMessage> _repeated_repeatedForeignMessage_codec + = pb::FieldCodec.ForMessage(394, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser); + private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage> repeatedForeignMessage_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignMessage> RepeatedForeignMessage { + get { return repeatedForeignMessage_; } + } + + /// <summary>Field number for the "repeated_nested_enum" field.</summary> + public const int RepeatedNestedEnumFieldNumber = 51; + private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> _repeated_repeatedNestedEnum_codec + = pb::FieldCodec.ForEnum(410, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) x); + private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> repeatedNestedEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> RepeatedNestedEnum { + get { return repeatedNestedEnum_; } + } + + /// <summary>Field number for the "repeated_foreign_enum" field.</summary> + public const int RepeatedForeignEnumFieldNumber = 52; + private static readonly pb::FieldCodec<global::ProtobufTestMessages.Proto3.ForeignEnum> _repeated_repeatedForeignEnum_codec + = pb::FieldCodec.ForEnum(418, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x); + private readonly pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum> repeatedForeignEnum_ = new pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::ProtobufTestMessages.Proto3.ForeignEnum> RepeatedForeignEnum { + get { return repeatedForeignEnum_; } + } + + /// <summary>Field number for the "repeated_string_piece" field.</summary> + public const int RepeatedStringPieceFieldNumber = 54; + private static readonly pb::FieldCodec<string> _repeated_repeatedStringPiece_codec + = pb::FieldCodec.ForString(434); + private readonly pbc::RepeatedField<string> repeatedStringPiece_ = new pbc::RepeatedField<string>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<string> RepeatedStringPiece { + get { return repeatedStringPiece_; } + } + + /// <summary>Field number for the "repeated_cord" field.</summary> + public const int RepeatedCordFieldNumber = 55; + private static readonly pb::FieldCodec<string> _repeated_repeatedCord_codec + = pb::FieldCodec.ForString(442); + private readonly pbc::RepeatedField<string> repeatedCord_ = new pbc::RepeatedField<string>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<string> RepeatedCord { + get { return repeatedCord_; } + } + + /// <summary>Field number for the "map_int32_int32" field.</summary> + public const int MapInt32Int32FieldNumber = 56; + private static readonly pbc::MapField<int, int>.Codec _map_mapInt32Int32_codec + = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForInt32(16), 450); + private readonly pbc::MapField<int, int> mapInt32Int32_ = new pbc::MapField<int, int>(); + /// <summary> + /// Map + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<int, int> MapInt32Int32 { + get { return mapInt32Int32_; } + } + + /// <summary>Field number for the "map_int64_int64" field.</summary> + public const int MapInt64Int64FieldNumber = 57; + private static readonly pbc::MapField<long, long>.Codec _map_mapInt64Int64_codec + = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForInt64(8), pb::FieldCodec.ForInt64(16), 458); + private readonly pbc::MapField<long, long> mapInt64Int64_ = new pbc::MapField<long, long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<long, long> MapInt64Int64 { + get { return mapInt64Int64_; } + } + + /// <summary>Field number for the "map_uint32_uint32" field.</summary> + public const int MapUint32Uint32FieldNumber = 58; + private static readonly pbc::MapField<uint, uint>.Codec _map_mapUint32Uint32_codec + = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForUInt32(8), pb::FieldCodec.ForUInt32(16), 466); + private readonly pbc::MapField<uint, uint> mapUint32Uint32_ = new pbc::MapField<uint, uint>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<uint, uint> MapUint32Uint32 { + get { return mapUint32Uint32_; } + } + + /// <summary>Field number for the "map_uint64_uint64" field.</summary> + public const int MapUint64Uint64FieldNumber = 59; + private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapUint64Uint64_codec + = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForUInt64(8), pb::FieldCodec.ForUInt64(16), 474); + private readonly pbc::MapField<ulong, ulong> mapUint64Uint64_ = new pbc::MapField<ulong, ulong>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<ulong, ulong> MapUint64Uint64 { + get { return mapUint64Uint64_; } + } + + /// <summary>Field number for the "map_sint32_sint32" field.</summary> + public const int MapSint32Sint32FieldNumber = 60; + private static readonly pbc::MapField<int, int>.Codec _map_mapSint32Sint32_codec + = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSInt32(8), pb::FieldCodec.ForSInt32(16), 482); + private readonly pbc::MapField<int, int> mapSint32Sint32_ = new pbc::MapField<int, int>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<int, int> MapSint32Sint32 { + get { return mapSint32Sint32_; } + } + + /// <summary>Field number for the "map_sint64_sint64" field.</summary> + public const int MapSint64Sint64FieldNumber = 61; + private static readonly pbc::MapField<long, long>.Codec _map_mapSint64Sint64_codec + = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSInt64(8), pb::FieldCodec.ForSInt64(16), 490); + private readonly pbc::MapField<long, long> mapSint64Sint64_ = new pbc::MapField<long, long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<long, long> MapSint64Sint64 { + get { return mapSint64Sint64_; } + } + + /// <summary>Field number for the "map_fixed32_fixed32" field.</summary> + public const int MapFixed32Fixed32FieldNumber = 62; + private static readonly pbc::MapField<uint, uint>.Codec _map_mapFixed32Fixed32_codec + = new pbc::MapField<uint, uint>.Codec(pb::FieldCodec.ForFixed32(13), pb::FieldCodec.ForFixed32(21), 498); + private readonly pbc::MapField<uint, uint> mapFixed32Fixed32_ = new pbc::MapField<uint, uint>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<uint, uint> MapFixed32Fixed32 { + get { return mapFixed32Fixed32_; } + } + + /// <summary>Field number for the "map_fixed64_fixed64" field.</summary> + public const int MapFixed64Fixed64FieldNumber = 63; + private static readonly pbc::MapField<ulong, ulong>.Codec _map_mapFixed64Fixed64_codec + = new pbc::MapField<ulong, ulong>.Codec(pb::FieldCodec.ForFixed64(9), pb::FieldCodec.ForFixed64(17), 506); + private readonly pbc::MapField<ulong, ulong> mapFixed64Fixed64_ = new pbc::MapField<ulong, ulong>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<ulong, ulong> MapFixed64Fixed64 { + get { return mapFixed64Fixed64_; } + } + + /// <summary>Field number for the "map_sfixed32_sfixed32" field.</summary> + public const int MapSfixed32Sfixed32FieldNumber = 64; + private static readonly pbc::MapField<int, int>.Codec _map_mapSfixed32Sfixed32_codec + = new pbc::MapField<int, int>.Codec(pb::FieldCodec.ForSFixed32(13), pb::FieldCodec.ForSFixed32(21), 514); + private readonly pbc::MapField<int, int> mapSfixed32Sfixed32_ = new pbc::MapField<int, int>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<int, int> MapSfixed32Sfixed32 { + get { return mapSfixed32Sfixed32_; } + } + + /// <summary>Field number for the "map_sfixed64_sfixed64" field.</summary> + public const int MapSfixed64Sfixed64FieldNumber = 65; + private static readonly pbc::MapField<long, long>.Codec _map_mapSfixed64Sfixed64_codec + = new pbc::MapField<long, long>.Codec(pb::FieldCodec.ForSFixed64(9), pb::FieldCodec.ForSFixed64(17), 522); + private readonly pbc::MapField<long, long> mapSfixed64Sfixed64_ = new pbc::MapField<long, long>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<long, long> MapSfixed64Sfixed64 { + get { return mapSfixed64Sfixed64_; } + } + + /// <summary>Field number for the "map_int32_float" field.</summary> + public const int MapInt32FloatFieldNumber = 66; + private static readonly pbc::MapField<int, float>.Codec _map_mapInt32Float_codec + = new pbc::MapField<int, float>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForFloat(21), 530); + private readonly pbc::MapField<int, float> mapInt32Float_ = new pbc::MapField<int, float>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<int, float> MapInt32Float { + get { return mapInt32Float_; } + } + + /// <summary>Field number for the "map_int32_double" field.</summary> + public const int MapInt32DoubleFieldNumber = 67; + private static readonly pbc::MapField<int, double>.Codec _map_mapInt32Double_codec + = new pbc::MapField<int, double>.Codec(pb::FieldCodec.ForInt32(8), pb::FieldCodec.ForDouble(17), 538); + private readonly pbc::MapField<int, double> mapInt32Double_ = new pbc::MapField<int, double>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<int, double> MapInt32Double { + get { return mapInt32Double_; } + } + + /// <summary>Field number for the "map_bool_bool" field.</summary> + public const int MapBoolBoolFieldNumber = 68; + private static readonly pbc::MapField<bool, bool>.Codec _map_mapBoolBool_codec + = new pbc::MapField<bool, bool>.Codec(pb::FieldCodec.ForBool(8), pb::FieldCodec.ForBool(16), 546); + private readonly pbc::MapField<bool, bool> mapBoolBool_ = new pbc::MapField<bool, bool>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<bool, bool> MapBoolBool { + get { return mapBoolBool_; } + } + + /// <summary>Field number for the "map_string_string" field.</summary> + public const int MapStringStringFieldNumber = 69; + private static readonly pbc::MapField<string, string>.Codec _map_mapStringString_codec + = new pbc::MapField<string, string>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForString(18), 554); + private readonly pbc::MapField<string, string> mapStringString_ = new pbc::MapField<string, string>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, string> MapStringString { + get { return mapStringString_; } + } + + /// <summary>Field number for the "map_string_bytes" field.</summary> + public const int MapStringBytesFieldNumber = 70; + private static readonly pbc::MapField<string, pb::ByteString>.Codec _map_mapStringBytes_codec + = new pbc::MapField<string, pb::ByteString>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForBytes(18), 562); + private readonly pbc::MapField<string, pb::ByteString> mapStringBytes_ = new pbc::MapField<string, pb::ByteString>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, pb::ByteString> MapStringBytes { + get { return mapStringBytes_; } + } + + /// <summary>Field number for the "map_string_nested_message" field.</summary> + public const int MapStringNestedMessageFieldNumber = 71; + private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>.Codec _map_mapStringNestedMessage_codec + = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage.Parser), 570); + private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> mapStringNestedMessage_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage> MapStringNestedMessage { + get { return mapStringNestedMessage_; } + } + + /// <summary>Field number for the "map_string_foreign_message" field.</summary> + public const int MapStringForeignMessageFieldNumber = 72; + private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>.Codec _map_mapStringForeignMessage_codec + = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::ProtobufTestMessages.Proto3.ForeignMessage.Parser), 578); + private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage> mapStringForeignMessage_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignMessage> MapStringForeignMessage { + get { return mapStringForeignMessage_; } + } + + /// <summary>Field number for the "map_string_nested_enum" field.</summary> + public const int MapStringNestedEnumFieldNumber = 73; + private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>.Codec _map_mapStringNestedEnum_codec + = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) x), 586); + private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> mapStringNestedEnum_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum> MapStringNestedEnum { + get { return mapStringNestedEnum_; } + } + + /// <summary>Field number for the "map_string_foreign_enum" field.</summary> + public const int MapStringForeignEnumFieldNumber = 74; + private static readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>.Codec _map_mapStringForeignEnum_codec + = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForEnum(16, x => (int) x, x => (global::ProtobufTestMessages.Proto3.ForeignEnum) x), 594); + private readonly pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum> mapStringForeignEnum_ = new pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::MapField<string, global::ProtobufTestMessages.Proto3.ForeignEnum> MapStringForeignEnum { + get { return mapStringForeignEnum_; } + } + + /// <summary>Field number for the "oneof_uint32" field.</summary> + public const int OneofUint32FieldNumber = 111; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint OneofUint32 { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint32 ? (uint) oneofField_ : 0; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofUint32; + } + } + + /// <summary>Field number for the "oneof_nested_message" field.</summary> + public const int OneofNestedMessageFieldNumber = 112; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage OneofNestedMessage { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage ? (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage) oneofField_ : null; } + set { + oneofField_ = value; + oneofFieldCase_ = value == null ? OneofFieldOneofCase.None : OneofFieldOneofCase.OneofNestedMessage; + } + } + + /// <summary>Field number for the "oneof_string" field.</summary> + public const int OneofStringFieldNumber = 113; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OneofString { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofString ? (string) oneofField_ : ""; } + set { + oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + oneofFieldCase_ = OneofFieldOneofCase.OneofString; + } + } + + /// <summary>Field number for the "oneof_bytes" field.</summary> + public const int OneofBytesFieldNumber = 114; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OneofBytes { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBytes ? (pb::ByteString) oneofField_ : pb::ByteString.Empty; } + set { + oneofField_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + oneofFieldCase_ = OneofFieldOneofCase.OneofBytes; + } + } + + /// <summary>Field number for the "oneof_bool" field.</summary> + public const int OneofBoolFieldNumber = 115; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool OneofBool { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofBool ? (bool) oneofField_ : false; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofBool; + } + } + + /// <summary>Field number for the "oneof_uint64" field.</summary> + public const int OneofUint64FieldNumber = 116; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong OneofUint64 { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofUint64 ? (ulong) oneofField_ : 0UL; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofUint64; + } + } + + /// <summary>Field number for the "oneof_float" field.</summary> + public const int OneofFloatFieldNumber = 117; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float OneofFloat { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofFloat ? (float) oneofField_ : 0F; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofFloat; + } + } + + /// <summary>Field number for the "oneof_double" field.</summary> + public const int OneofDoubleFieldNumber = 118; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double OneofDouble { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofDouble ? (double) oneofField_ : 0D; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofDouble; + } + } + + /// <summary>Field number for the "oneof_enum" field.</summary> + public const int OneofEnumFieldNumber = 119; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum OneofEnum { + get { return oneofFieldCase_ == OneofFieldOneofCase.OneofEnum ? (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) oneofField_ : 0; } + set { + oneofField_ = value; + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + } + } + + /// <summary>Field number for the "optional_bool_wrapper" field.</summary> + public const int OptionalBoolWrapperFieldNumber = 201; + private static readonly pb::FieldCodec<bool?> _single_optionalBoolWrapper_codec = pb::FieldCodec.ForStructWrapper<bool>(1610); + private bool? optionalBoolWrapper_; + /// <summary> + /// Well-known types + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool? OptionalBoolWrapper { + get { return optionalBoolWrapper_; } + set { + optionalBoolWrapper_ = value; + } + } + + /// <summary>Field number for the "optional_int32_wrapper" field.</summary> + public const int OptionalInt32WrapperFieldNumber = 202; + private static readonly pb::FieldCodec<int?> _single_optionalInt32Wrapper_codec = pb::FieldCodec.ForStructWrapper<int>(1618); + private int? optionalInt32Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int? OptionalInt32Wrapper { + get { return optionalInt32Wrapper_; } + set { + optionalInt32Wrapper_ = value; + } + } + + /// <summary>Field number for the "optional_int64_wrapper" field.</summary> + public const int OptionalInt64WrapperFieldNumber = 203; + private static readonly pb::FieldCodec<long?> _single_optionalInt64Wrapper_codec = pb::FieldCodec.ForStructWrapper<long>(1626); + private long? optionalInt64Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long? OptionalInt64Wrapper { + get { return optionalInt64Wrapper_; } + set { + optionalInt64Wrapper_ = value; + } + } + + /// <summary>Field number for the "optional_uint32_wrapper" field.</summary> + public const int OptionalUint32WrapperFieldNumber = 204; + private static readonly pb::FieldCodec<uint?> _single_optionalUint32Wrapper_codec = pb::FieldCodec.ForStructWrapper<uint>(1634); + private uint? optionalUint32Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint? OptionalUint32Wrapper { + get { return optionalUint32Wrapper_; } + set { + optionalUint32Wrapper_ = value; + } + } + + /// <summary>Field number for the "optional_uint64_wrapper" field.</summary> + public const int OptionalUint64WrapperFieldNumber = 205; + private static readonly pb::FieldCodec<ulong?> _single_optionalUint64Wrapper_codec = pb::FieldCodec.ForStructWrapper<ulong>(1642); + private ulong? optionalUint64Wrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong? OptionalUint64Wrapper { + get { return optionalUint64Wrapper_; } + set { + optionalUint64Wrapper_ = value; + } + } + + /// <summary>Field number for the "optional_float_wrapper" field.</summary> + public const int OptionalFloatWrapperFieldNumber = 206; + private static readonly pb::FieldCodec<float?> _single_optionalFloatWrapper_codec = pb::FieldCodec.ForStructWrapper<float>(1650); + private float? optionalFloatWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float? OptionalFloatWrapper { + get { return optionalFloatWrapper_; } + set { + optionalFloatWrapper_ = value; + } + } + + /// <summary>Field number for the "optional_double_wrapper" field.</summary> + public const int OptionalDoubleWrapperFieldNumber = 207; + private static readonly pb::FieldCodec<double?> _single_optionalDoubleWrapper_codec = pb::FieldCodec.ForStructWrapper<double>(1658); + private double? optionalDoubleWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double? OptionalDoubleWrapper { + get { return optionalDoubleWrapper_; } + set { + optionalDoubleWrapper_ = value; + } + } + + /// <summary>Field number for the "optional_string_wrapper" field.</summary> + public const int OptionalStringWrapperFieldNumber = 208; + private static readonly pb::FieldCodec<string> _single_optionalStringWrapper_codec = pb::FieldCodec.ForClassWrapper<string>(1666); + private string optionalStringWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OptionalStringWrapper { + get { return optionalStringWrapper_; } + set { + optionalStringWrapper_ = value; + } + } + + /// <summary>Field number for the "optional_bytes_wrapper" field.</summary> + public const int OptionalBytesWrapperFieldNumber = 209; + private static readonly pb::FieldCodec<pb::ByteString> _single_optionalBytesWrapper_codec = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1674); + private pb::ByteString optionalBytesWrapper_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString OptionalBytesWrapper { + get { return optionalBytesWrapper_; } + set { + optionalBytesWrapper_ = value; + } + } + + /// <summary>Field number for the "repeated_bool_wrapper" field.</summary> + public const int RepeatedBoolWrapperFieldNumber = 211; + private static readonly pb::FieldCodec<bool?> _repeated_repeatedBoolWrapper_codec + = pb::FieldCodec.ForStructWrapper<bool>(1690); + private readonly pbc::RepeatedField<bool?> repeatedBoolWrapper_ = new pbc::RepeatedField<bool?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<bool?> RepeatedBoolWrapper { + get { return repeatedBoolWrapper_; } + } + + /// <summary>Field number for the "repeated_int32_wrapper" field.</summary> + public const int RepeatedInt32WrapperFieldNumber = 212; + private static readonly pb::FieldCodec<int?> _repeated_repeatedInt32Wrapper_codec + = pb::FieldCodec.ForStructWrapper<int>(1698); + private readonly pbc::RepeatedField<int?> repeatedInt32Wrapper_ = new pbc::RepeatedField<int?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<int?> RepeatedInt32Wrapper { + get { return repeatedInt32Wrapper_; } + } + + /// <summary>Field number for the "repeated_int64_wrapper" field.</summary> + public const int RepeatedInt64WrapperFieldNumber = 213; + private static readonly pb::FieldCodec<long?> _repeated_repeatedInt64Wrapper_codec + = pb::FieldCodec.ForStructWrapper<long>(1706); + private readonly pbc::RepeatedField<long?> repeatedInt64Wrapper_ = new pbc::RepeatedField<long?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<long?> RepeatedInt64Wrapper { + get { return repeatedInt64Wrapper_; } + } + + /// <summary>Field number for the "repeated_uint32_wrapper" field.</summary> + public const int RepeatedUint32WrapperFieldNumber = 214; + private static readonly pb::FieldCodec<uint?> _repeated_repeatedUint32Wrapper_codec + = pb::FieldCodec.ForStructWrapper<uint>(1714); + private readonly pbc::RepeatedField<uint?> repeatedUint32Wrapper_ = new pbc::RepeatedField<uint?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<uint?> RepeatedUint32Wrapper { + get { return repeatedUint32Wrapper_; } + } + + /// <summary>Field number for the "repeated_uint64_wrapper" field.</summary> + public const int RepeatedUint64WrapperFieldNumber = 215; + private static readonly pb::FieldCodec<ulong?> _repeated_repeatedUint64Wrapper_codec + = pb::FieldCodec.ForStructWrapper<ulong>(1722); + private readonly pbc::RepeatedField<ulong?> repeatedUint64Wrapper_ = new pbc::RepeatedField<ulong?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<ulong?> RepeatedUint64Wrapper { + get { return repeatedUint64Wrapper_; } + } + + /// <summary>Field number for the "repeated_float_wrapper" field.</summary> + public const int RepeatedFloatWrapperFieldNumber = 216; + private static readonly pb::FieldCodec<float?> _repeated_repeatedFloatWrapper_codec + = pb::FieldCodec.ForStructWrapper<float>(1730); + private readonly pbc::RepeatedField<float?> repeatedFloatWrapper_ = new pbc::RepeatedField<float?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<float?> RepeatedFloatWrapper { + get { return repeatedFloatWrapper_; } + } + + /// <summary>Field number for the "repeated_double_wrapper" field.</summary> + public const int RepeatedDoubleWrapperFieldNumber = 217; + private static readonly pb::FieldCodec<double?> _repeated_repeatedDoubleWrapper_codec + = pb::FieldCodec.ForStructWrapper<double>(1738); + private readonly pbc::RepeatedField<double?> repeatedDoubleWrapper_ = new pbc::RepeatedField<double?>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<double?> RepeatedDoubleWrapper { + get { return repeatedDoubleWrapper_; } + } + + /// <summary>Field number for the "repeated_string_wrapper" field.</summary> + public const int RepeatedStringWrapperFieldNumber = 218; + private static readonly pb::FieldCodec<string> _repeated_repeatedStringWrapper_codec + = pb::FieldCodec.ForClassWrapper<string>(1746); + private readonly pbc::RepeatedField<string> repeatedStringWrapper_ = new pbc::RepeatedField<string>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<string> RepeatedStringWrapper { + get { return repeatedStringWrapper_; } + } + + /// <summary>Field number for the "repeated_bytes_wrapper" field.</summary> + public const int RepeatedBytesWrapperFieldNumber = 219; + private static readonly pb::FieldCodec<pb::ByteString> _repeated_repeatedBytesWrapper_codec + = pb::FieldCodec.ForClassWrapper<pb::ByteString>(1754); + private readonly pbc::RepeatedField<pb::ByteString> repeatedBytesWrapper_ = new pbc::RepeatedField<pb::ByteString>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<pb::ByteString> RepeatedBytesWrapper { + get { return repeatedBytesWrapper_; } + } + + /// <summary>Field number for the "optional_duration" field.</summary> + public const int OptionalDurationFieldNumber = 301; + private global::Google.Protobuf.WellKnownTypes.Duration optionalDuration_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Duration OptionalDuration { + get { return optionalDuration_; } + set { + optionalDuration_ = value; + } + } + + /// <summary>Field number for the "optional_timestamp" field.</summary> + public const int OptionalTimestampFieldNumber = 302; + private global::Google.Protobuf.WellKnownTypes.Timestamp optionalTimestamp_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Timestamp OptionalTimestamp { + get { return optionalTimestamp_; } + set { + optionalTimestamp_ = value; + } + } + + /// <summary>Field number for the "optional_field_mask" field.</summary> + public const int OptionalFieldMaskFieldNumber = 303; + private global::Google.Protobuf.WellKnownTypes.FieldMask optionalFieldMask_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.FieldMask OptionalFieldMask { + get { return optionalFieldMask_; } + set { + optionalFieldMask_ = value; + } + } + + /// <summary>Field number for the "optional_struct" field.</summary> + public const int OptionalStructFieldNumber = 304; + private global::Google.Protobuf.WellKnownTypes.Struct optionalStruct_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Struct OptionalStruct { + get { return optionalStruct_; } + set { + optionalStruct_ = value; + } + } + + /// <summary>Field number for the "optional_any" field.</summary> + public const int OptionalAnyFieldNumber = 305; + private global::Google.Protobuf.WellKnownTypes.Any optionalAny_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Any OptionalAny { + get { return optionalAny_; } + set { + optionalAny_ = value; + } + } + + /// <summary>Field number for the "optional_value" field.</summary> + public const int OptionalValueFieldNumber = 306; + private global::Google.Protobuf.WellKnownTypes.Value optionalValue_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.WellKnownTypes.Value OptionalValue { + get { return optionalValue_; } + set { + optionalValue_ = value; + } + } + + /// <summary>Field number for the "repeated_duration" field.</summary> + public const int RepeatedDurationFieldNumber = 311; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Duration> _repeated_repeatedDuration_codec + = pb::FieldCodec.ForMessage(2490, global::Google.Protobuf.WellKnownTypes.Duration.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> repeatedDuration_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Duration> RepeatedDuration { + get { return repeatedDuration_; } + } + + /// <summary>Field number for the "repeated_timestamp" field.</summary> + public const int RepeatedTimestampFieldNumber = 312; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Timestamp> _repeated_repeatedTimestamp_codec + = pb::FieldCodec.ForMessage(2498, global::Google.Protobuf.WellKnownTypes.Timestamp.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> repeatedTimestamp_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Timestamp> RepeatedTimestamp { + get { return repeatedTimestamp_; } + } + + /// <summary>Field number for the "repeated_fieldmask" field.</summary> + public const int RepeatedFieldmaskFieldNumber = 313; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.FieldMask> _repeated_repeatedFieldmask_codec + = pb::FieldCodec.ForMessage(2506, global::Google.Protobuf.WellKnownTypes.FieldMask.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> repeatedFieldmask_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.FieldMask> RepeatedFieldmask { + get { return repeatedFieldmask_; } + } + + /// <summary>Field number for the "repeated_struct" field.</summary> + public const int RepeatedStructFieldNumber = 324; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Struct> _repeated_repeatedStruct_codec + = pb::FieldCodec.ForMessage(2594, global::Google.Protobuf.WellKnownTypes.Struct.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> repeatedStruct_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Struct> RepeatedStruct { + get { return repeatedStruct_; } + } + + /// <summary>Field number for the "repeated_any" field.</summary> + public const int RepeatedAnyFieldNumber = 315; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Any> _repeated_repeatedAny_codec + = pb::FieldCodec.ForMessage(2522, global::Google.Protobuf.WellKnownTypes.Any.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> repeatedAny_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Any> RepeatedAny { + get { return repeatedAny_; } + } + + /// <summary>Field number for the "repeated_value" field.</summary> + public const int RepeatedValueFieldNumber = 316; + private static readonly pb::FieldCodec<global::Google.Protobuf.WellKnownTypes.Value> _repeated_repeatedValue_codec + = pb::FieldCodec.ForMessage(2530, global::Google.Protobuf.WellKnownTypes.Value.Parser); + private readonly pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> repeatedValue_ = new pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value>(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField<global::Google.Protobuf.WellKnownTypes.Value> RepeatedValue { + get { return repeatedValue_; } + } + + /// <summary>Field number for the "fieldname1" field.</summary> + public const int Fieldname1FieldNumber = 401; + private int fieldname1_; + /// <summary> + /// Test field-name-to-JSON-name convention. + /// (protobuf says names can be any valid C/C++ identifier.) + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Fieldname1 { + get { return fieldname1_; } + set { + fieldname1_ = value; + } + } + + /// <summary>Field number for the "field_name2" field.</summary> + public const int FieldName2FieldNumber = 402; + private int fieldName2_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName2 { + get { return fieldName2_; } + set { + fieldName2_ = value; + } + } + + /// <summary>Field number for the "_field_name3" field.</summary> + public const int FieldName3FieldNumber = 403; + private int FieldName3_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName3 { + get { return FieldName3_; } + set { + FieldName3_ = value; + } + } + + /// <summary>Field number for the "field__name4_" field.</summary> + public const int FieldName4FieldNumber = 404; + private int fieldName4_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName4 { + get { return fieldName4_; } + set { + fieldName4_ = value; + } + } + + /// <summary>Field number for the "field0name5" field.</summary> + public const int Field0Name5FieldNumber = 405; + private int field0Name5_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field0Name5 { + get { return field0Name5_; } + set { + field0Name5_ = value; + } + } + + /// <summary>Field number for the "field_0_name6" field.</summary> + public const int Field0Name6FieldNumber = 406; + private int field0Name6_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Field0Name6 { + get { return field0Name6_; } + set { + field0Name6_ = value; + } + } + + /// <summary>Field number for the "fieldName7" field.</summary> + public const int FieldName7FieldNumber = 407; + private int fieldName7_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName7 { + get { return fieldName7_; } + set { + fieldName7_ = value; + } + } + + /// <summary>Field number for the "FieldName8" field.</summary> + public const int FieldName8FieldNumber = 408; + private int fieldName8_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName8 { + get { return fieldName8_; } + set { + fieldName8_ = value; + } + } + + /// <summary>Field number for the "field_Name9" field.</summary> + public const int FieldName9FieldNumber = 409; + private int fieldName9_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName9 { + get { return fieldName9_; } + set { + fieldName9_ = value; + } + } + + /// <summary>Field number for the "Field_Name10" field.</summary> + public const int FieldName10FieldNumber = 410; + private int fieldName10_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName10 { + get { return fieldName10_; } + set { + fieldName10_ = value; + } + } + + /// <summary>Field number for the "FIELD_NAME11" field.</summary> + public const int FIELDNAME11FieldNumber = 411; + private int fIELDNAME11_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FIELDNAME11 { + get { return fIELDNAME11_; } + set { + fIELDNAME11_ = value; + } + } + + /// <summary>Field number for the "FIELD_name12" field.</summary> + public const int FIELDName12FieldNumber = 412; + private int fIELDName12_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FIELDName12 { + get { return fIELDName12_; } + set { + fIELDName12_ = value; + } + } + + /// <summary>Field number for the "__field_name13" field.</summary> + public const int FieldName13FieldNumber = 413; + private int FieldName13_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName13 { + get { return FieldName13_; } + set { + FieldName13_ = value; + } + } + + /// <summary>Field number for the "__Field_name14" field.</summary> + public const int FieldName14FieldNumber = 414; + private int FieldName14_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName14 { + get { return FieldName14_; } + set { + FieldName14_ = value; + } + } + + /// <summary>Field number for the "field__name15" field.</summary> + public const int FieldName15FieldNumber = 415; + private int fieldName15_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName15 { + get { return fieldName15_; } + set { + fieldName15_ = value; + } + } + + /// <summary>Field number for the "field__Name16" field.</summary> + public const int FieldName16FieldNumber = 416; + private int fieldName16_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName16 { + get { return fieldName16_; } + set { + fieldName16_ = value; + } + } + + /// <summary>Field number for the "field_name17__" field.</summary> + public const int FieldName17FieldNumber = 417; + private int fieldName17_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName17 { + get { return fieldName17_; } + set { + fieldName17_ = value; + } + } + + /// <summary>Field number for the "Field_name18__" field.</summary> + public const int FieldName18FieldNumber = 418; + private int fieldName18_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int FieldName18 { + get { return fieldName18_; } + set { + fieldName18_ = value; + } + } + + private object oneofField_; + /// <summary>Enum of possible cases for the "oneof_field" oneof.</summary> + public enum OneofFieldOneofCase { + None = 0, + OneofUint32 = 111, + OneofNestedMessage = 112, + OneofString = 113, + OneofBytes = 114, + OneofBool = 115, + OneofUint64 = 116, + OneofFloat = 117, + OneofDouble = 118, + OneofEnum = 119, + } + private OneofFieldOneofCase oneofFieldCase_ = OneofFieldOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public OneofFieldOneofCase OneofFieldCase { + get { return oneofFieldCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void ClearOneofField() { + oneofFieldCase_ = OneofFieldOneofCase.None; + oneofField_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as TestAllTypes); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(TestAllTypes other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (OptionalInt32 != other.OptionalInt32) return false; + if (OptionalInt64 != other.OptionalInt64) return false; + if (OptionalUint32 != other.OptionalUint32) return false; + if (OptionalUint64 != other.OptionalUint64) return false; + if (OptionalSint32 != other.OptionalSint32) return false; + if (OptionalSint64 != other.OptionalSint64) return false; + if (OptionalFixed32 != other.OptionalFixed32) return false; + if (OptionalFixed64 != other.OptionalFixed64) return false; + if (OptionalSfixed32 != other.OptionalSfixed32) return false; + if (OptionalSfixed64 != other.OptionalSfixed64) return false; + if (OptionalFloat != other.OptionalFloat) return false; + if (OptionalDouble != other.OptionalDouble) return false; + if (OptionalBool != other.OptionalBool) return false; + if (OptionalString != other.OptionalString) return false; + if (OptionalBytes != other.OptionalBytes) return false; + if (!object.Equals(OptionalNestedMessage, other.OptionalNestedMessage)) return false; + if (!object.Equals(OptionalForeignMessage, other.OptionalForeignMessage)) return false; + if (OptionalNestedEnum != other.OptionalNestedEnum) return false; + if (OptionalForeignEnum != other.OptionalForeignEnum) return false; + if (OptionalStringPiece != other.OptionalStringPiece) return false; + if (OptionalCord != other.OptionalCord) return false; + if (!object.Equals(RecursiveMessage, other.RecursiveMessage)) return false; + if(!repeatedInt32_.Equals(other.repeatedInt32_)) return false; + if(!repeatedInt64_.Equals(other.repeatedInt64_)) return false; + if(!repeatedUint32_.Equals(other.repeatedUint32_)) return false; + if(!repeatedUint64_.Equals(other.repeatedUint64_)) return false; + if(!repeatedSint32_.Equals(other.repeatedSint32_)) return false; + if(!repeatedSint64_.Equals(other.repeatedSint64_)) return false; + if(!repeatedFixed32_.Equals(other.repeatedFixed32_)) return false; + if(!repeatedFixed64_.Equals(other.repeatedFixed64_)) return false; + if(!repeatedSfixed32_.Equals(other.repeatedSfixed32_)) return false; + if(!repeatedSfixed64_.Equals(other.repeatedSfixed64_)) return false; + if(!repeatedFloat_.Equals(other.repeatedFloat_)) return false; + if(!repeatedDouble_.Equals(other.repeatedDouble_)) return false; + if(!repeatedBool_.Equals(other.repeatedBool_)) return false; + if(!repeatedString_.Equals(other.repeatedString_)) return false; + if(!repeatedBytes_.Equals(other.repeatedBytes_)) return false; + if(!repeatedNestedMessage_.Equals(other.repeatedNestedMessage_)) return false; + if(!repeatedForeignMessage_.Equals(other.repeatedForeignMessage_)) return false; + if(!repeatedNestedEnum_.Equals(other.repeatedNestedEnum_)) return false; + if(!repeatedForeignEnum_.Equals(other.repeatedForeignEnum_)) return false; + if(!repeatedStringPiece_.Equals(other.repeatedStringPiece_)) return false; + if(!repeatedCord_.Equals(other.repeatedCord_)) return false; + if (!MapInt32Int32.Equals(other.MapInt32Int32)) return false; + if (!MapInt64Int64.Equals(other.MapInt64Int64)) return false; + if (!MapUint32Uint32.Equals(other.MapUint32Uint32)) return false; + if (!MapUint64Uint64.Equals(other.MapUint64Uint64)) return false; + if (!MapSint32Sint32.Equals(other.MapSint32Sint32)) return false; + if (!MapSint64Sint64.Equals(other.MapSint64Sint64)) return false; + if (!MapFixed32Fixed32.Equals(other.MapFixed32Fixed32)) return false; + if (!MapFixed64Fixed64.Equals(other.MapFixed64Fixed64)) return false; + if (!MapSfixed32Sfixed32.Equals(other.MapSfixed32Sfixed32)) return false; + if (!MapSfixed64Sfixed64.Equals(other.MapSfixed64Sfixed64)) return false; + if (!MapInt32Float.Equals(other.MapInt32Float)) return false; + if (!MapInt32Double.Equals(other.MapInt32Double)) return false; + if (!MapBoolBool.Equals(other.MapBoolBool)) return false; + if (!MapStringString.Equals(other.MapStringString)) return false; + if (!MapStringBytes.Equals(other.MapStringBytes)) return false; + if (!MapStringNestedMessage.Equals(other.MapStringNestedMessage)) return false; + if (!MapStringForeignMessage.Equals(other.MapStringForeignMessage)) return false; + if (!MapStringNestedEnum.Equals(other.MapStringNestedEnum)) return false; + if (!MapStringForeignEnum.Equals(other.MapStringForeignEnum)) return false; + if (OneofUint32 != other.OneofUint32) return false; + if (!object.Equals(OneofNestedMessage, other.OneofNestedMessage)) return false; + if (OneofString != other.OneofString) return false; + if (OneofBytes != other.OneofBytes) return false; + if (OneofBool != other.OneofBool) return false; + if (OneofUint64 != other.OneofUint64) return false; + if (OneofFloat != other.OneofFloat) return false; + if (OneofDouble != other.OneofDouble) return false; + if (OneofEnum != other.OneofEnum) return false; + if (OptionalBoolWrapper != other.OptionalBoolWrapper) return false; + if (OptionalInt32Wrapper != other.OptionalInt32Wrapper) return false; + if (OptionalInt64Wrapper != other.OptionalInt64Wrapper) return false; + if (OptionalUint32Wrapper != other.OptionalUint32Wrapper) return false; + if (OptionalUint64Wrapper != other.OptionalUint64Wrapper) return false; + if (OptionalFloatWrapper != other.OptionalFloatWrapper) return false; + if (OptionalDoubleWrapper != other.OptionalDoubleWrapper) return false; + if (OptionalStringWrapper != other.OptionalStringWrapper) return false; + if (OptionalBytesWrapper != other.OptionalBytesWrapper) return false; + if(!repeatedBoolWrapper_.Equals(other.repeatedBoolWrapper_)) return false; + if(!repeatedInt32Wrapper_.Equals(other.repeatedInt32Wrapper_)) return false; + if(!repeatedInt64Wrapper_.Equals(other.repeatedInt64Wrapper_)) return false; + if(!repeatedUint32Wrapper_.Equals(other.repeatedUint32Wrapper_)) return false; + if(!repeatedUint64Wrapper_.Equals(other.repeatedUint64Wrapper_)) return false; + if(!repeatedFloatWrapper_.Equals(other.repeatedFloatWrapper_)) return false; + if(!repeatedDoubleWrapper_.Equals(other.repeatedDoubleWrapper_)) return false; + if(!repeatedStringWrapper_.Equals(other.repeatedStringWrapper_)) return false; + if(!repeatedBytesWrapper_.Equals(other.repeatedBytesWrapper_)) return false; + if (!object.Equals(OptionalDuration, other.OptionalDuration)) return false; + if (!object.Equals(OptionalTimestamp, other.OptionalTimestamp)) return false; + if (!object.Equals(OptionalFieldMask, other.OptionalFieldMask)) return false; + if (!object.Equals(OptionalStruct, other.OptionalStruct)) return false; + if (!object.Equals(OptionalAny, other.OptionalAny)) return false; + if (!object.Equals(OptionalValue, other.OptionalValue)) return false; + if(!repeatedDuration_.Equals(other.repeatedDuration_)) return false; + if(!repeatedTimestamp_.Equals(other.repeatedTimestamp_)) return false; + if(!repeatedFieldmask_.Equals(other.repeatedFieldmask_)) return false; + if(!repeatedStruct_.Equals(other.repeatedStruct_)) return false; + if(!repeatedAny_.Equals(other.repeatedAny_)) return false; + if(!repeatedValue_.Equals(other.repeatedValue_)) return false; + if (Fieldname1 != other.Fieldname1) return false; + if (FieldName2 != other.FieldName2) return false; + if (FieldName3 != other.FieldName3) return false; + if (FieldName4 != other.FieldName4) return false; + if (Field0Name5 != other.Field0Name5) return false; + if (Field0Name6 != other.Field0Name6) return false; + if (FieldName7 != other.FieldName7) return false; + if (FieldName8 != other.FieldName8) return false; + if (FieldName9 != other.FieldName9) return false; + if (FieldName10 != other.FieldName10) return false; + if (FIELDNAME11 != other.FIELDNAME11) return false; + if (FIELDName12 != other.FIELDName12) return false; + if (FieldName13 != other.FieldName13) return false; + if (FieldName14 != other.FieldName14) return false; + if (FieldName15 != other.FieldName15) return false; + if (FieldName16 != other.FieldName16) return false; + if (FieldName17 != other.FieldName17) return false; + if (FieldName18 != other.FieldName18) return false; + if (OneofFieldCase != other.OneofFieldCase) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (OptionalInt32 != 0) hash ^= OptionalInt32.GetHashCode(); + if (OptionalInt64 != 0L) hash ^= OptionalInt64.GetHashCode(); + if (OptionalUint32 != 0) hash ^= OptionalUint32.GetHashCode(); + if (OptionalUint64 != 0UL) hash ^= OptionalUint64.GetHashCode(); + if (OptionalSint32 != 0) hash ^= OptionalSint32.GetHashCode(); + if (OptionalSint64 != 0L) hash ^= OptionalSint64.GetHashCode(); + if (OptionalFixed32 != 0) hash ^= OptionalFixed32.GetHashCode(); + if (OptionalFixed64 != 0UL) hash ^= OptionalFixed64.GetHashCode(); + if (OptionalSfixed32 != 0) hash ^= OptionalSfixed32.GetHashCode(); + if (OptionalSfixed64 != 0L) hash ^= OptionalSfixed64.GetHashCode(); + if (OptionalFloat != 0F) hash ^= OptionalFloat.GetHashCode(); + if (OptionalDouble != 0D) hash ^= OptionalDouble.GetHashCode(); + if (OptionalBool != false) hash ^= OptionalBool.GetHashCode(); + if (OptionalString.Length != 0) hash ^= OptionalString.GetHashCode(); + if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode(); + if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode(); + if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode(); + if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode(); + if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode(); + if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode(); + if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode(); + if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode(); + hash ^= repeatedInt32_.GetHashCode(); + hash ^= repeatedInt64_.GetHashCode(); + hash ^= repeatedUint32_.GetHashCode(); + hash ^= repeatedUint64_.GetHashCode(); + hash ^= repeatedSint32_.GetHashCode(); + hash ^= repeatedSint64_.GetHashCode(); + hash ^= repeatedFixed32_.GetHashCode(); + hash ^= repeatedFixed64_.GetHashCode(); + hash ^= repeatedSfixed32_.GetHashCode(); + hash ^= repeatedSfixed64_.GetHashCode(); + hash ^= repeatedFloat_.GetHashCode(); + hash ^= repeatedDouble_.GetHashCode(); + hash ^= repeatedBool_.GetHashCode(); + hash ^= repeatedString_.GetHashCode(); + hash ^= repeatedBytes_.GetHashCode(); + hash ^= repeatedNestedMessage_.GetHashCode(); + hash ^= repeatedForeignMessage_.GetHashCode(); + hash ^= repeatedNestedEnum_.GetHashCode(); + hash ^= repeatedForeignEnum_.GetHashCode(); + hash ^= repeatedStringPiece_.GetHashCode(); + hash ^= repeatedCord_.GetHashCode(); + hash ^= MapInt32Int32.GetHashCode(); + hash ^= MapInt64Int64.GetHashCode(); + hash ^= MapUint32Uint32.GetHashCode(); + hash ^= MapUint64Uint64.GetHashCode(); + hash ^= MapSint32Sint32.GetHashCode(); + hash ^= MapSint64Sint64.GetHashCode(); + hash ^= MapFixed32Fixed32.GetHashCode(); + hash ^= MapFixed64Fixed64.GetHashCode(); + hash ^= MapSfixed32Sfixed32.GetHashCode(); + hash ^= MapSfixed64Sfixed64.GetHashCode(); + hash ^= MapInt32Float.GetHashCode(); + hash ^= MapInt32Double.GetHashCode(); + hash ^= MapBoolBool.GetHashCode(); + hash ^= MapStringString.GetHashCode(); + hash ^= MapStringBytes.GetHashCode(); + hash ^= MapStringNestedMessage.GetHashCode(); + hash ^= MapStringForeignMessage.GetHashCode(); + hash ^= MapStringNestedEnum.GetHashCode(); + hash ^= MapStringForeignEnum.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) hash ^= OneofUint32.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) hash ^= OneofNestedMessage.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) hash ^= OneofString.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) hash ^= OneofBytes.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) hash ^= OneofBool.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) hash ^= OneofUint64.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) hash ^= OneofFloat.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) hash ^= OneofDouble.GetHashCode(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) hash ^= OneofEnum.GetHashCode(); + if (optionalBoolWrapper_ != null) hash ^= OptionalBoolWrapper.GetHashCode(); + if (optionalInt32Wrapper_ != null) hash ^= OptionalInt32Wrapper.GetHashCode(); + if (optionalInt64Wrapper_ != null) hash ^= OptionalInt64Wrapper.GetHashCode(); + if (optionalUint32Wrapper_ != null) hash ^= OptionalUint32Wrapper.GetHashCode(); + if (optionalUint64Wrapper_ != null) hash ^= OptionalUint64Wrapper.GetHashCode(); + if (optionalFloatWrapper_ != null) hash ^= OptionalFloatWrapper.GetHashCode(); + if (optionalDoubleWrapper_ != null) hash ^= OptionalDoubleWrapper.GetHashCode(); + if (optionalStringWrapper_ != null) hash ^= OptionalStringWrapper.GetHashCode(); + if (optionalBytesWrapper_ != null) hash ^= OptionalBytesWrapper.GetHashCode(); + hash ^= repeatedBoolWrapper_.GetHashCode(); + hash ^= repeatedInt32Wrapper_.GetHashCode(); + hash ^= repeatedInt64Wrapper_.GetHashCode(); + hash ^= repeatedUint32Wrapper_.GetHashCode(); + hash ^= repeatedUint64Wrapper_.GetHashCode(); + hash ^= repeatedFloatWrapper_.GetHashCode(); + hash ^= repeatedDoubleWrapper_.GetHashCode(); + hash ^= repeatedStringWrapper_.GetHashCode(); + hash ^= repeatedBytesWrapper_.GetHashCode(); + if (optionalDuration_ != null) hash ^= OptionalDuration.GetHashCode(); + if (optionalTimestamp_ != null) hash ^= OptionalTimestamp.GetHashCode(); + if (optionalFieldMask_ != null) hash ^= OptionalFieldMask.GetHashCode(); + if (optionalStruct_ != null) hash ^= OptionalStruct.GetHashCode(); + if (optionalAny_ != null) hash ^= OptionalAny.GetHashCode(); + if (optionalValue_ != null) hash ^= OptionalValue.GetHashCode(); + hash ^= repeatedDuration_.GetHashCode(); + hash ^= repeatedTimestamp_.GetHashCode(); + hash ^= repeatedFieldmask_.GetHashCode(); + hash ^= repeatedStruct_.GetHashCode(); + hash ^= repeatedAny_.GetHashCode(); + hash ^= repeatedValue_.GetHashCode(); + if (Fieldname1 != 0) hash ^= Fieldname1.GetHashCode(); + if (FieldName2 != 0) hash ^= FieldName2.GetHashCode(); + if (FieldName3 != 0) hash ^= FieldName3.GetHashCode(); + if (FieldName4 != 0) hash ^= FieldName4.GetHashCode(); + if (Field0Name5 != 0) hash ^= Field0Name5.GetHashCode(); + if (Field0Name6 != 0) hash ^= Field0Name6.GetHashCode(); + if (FieldName7 != 0) hash ^= FieldName7.GetHashCode(); + if (FieldName8 != 0) hash ^= FieldName8.GetHashCode(); + if (FieldName9 != 0) hash ^= FieldName9.GetHashCode(); + if (FieldName10 != 0) hash ^= FieldName10.GetHashCode(); + if (FIELDNAME11 != 0) hash ^= FIELDNAME11.GetHashCode(); + if (FIELDName12 != 0) hash ^= FIELDName12.GetHashCode(); + if (FieldName13 != 0) hash ^= FieldName13.GetHashCode(); + if (FieldName14 != 0) hash ^= FieldName14.GetHashCode(); + if (FieldName15 != 0) hash ^= FieldName15.GetHashCode(); + if (FieldName16 != 0) hash ^= FieldName16.GetHashCode(); + if (FieldName17 != 0) hash ^= FieldName17.GetHashCode(); + if (FieldName18 != 0) hash ^= FieldName18.GetHashCode(); + hash ^= (int) oneofFieldCase_; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (OptionalInt32 != 0) { + output.WriteRawTag(8); + output.WriteInt32(OptionalInt32); + } + if (OptionalInt64 != 0L) { + output.WriteRawTag(16); + output.WriteInt64(OptionalInt64); + } + if (OptionalUint32 != 0) { + output.WriteRawTag(24); + output.WriteUInt32(OptionalUint32); + } + if (OptionalUint64 != 0UL) { + output.WriteRawTag(32); + output.WriteUInt64(OptionalUint64); + } + if (OptionalSint32 != 0) { + output.WriteRawTag(40); + output.WriteSInt32(OptionalSint32); + } + if (OptionalSint64 != 0L) { + output.WriteRawTag(48); + output.WriteSInt64(OptionalSint64); + } + if (OptionalFixed32 != 0) { + output.WriteRawTag(61); + output.WriteFixed32(OptionalFixed32); + } + if (OptionalFixed64 != 0UL) { + output.WriteRawTag(65); + output.WriteFixed64(OptionalFixed64); + } + if (OptionalSfixed32 != 0) { + output.WriteRawTag(77); + output.WriteSFixed32(OptionalSfixed32); + } + if (OptionalSfixed64 != 0L) { + output.WriteRawTag(81); + output.WriteSFixed64(OptionalSfixed64); + } + if (OptionalFloat != 0F) { + output.WriteRawTag(93); + output.WriteFloat(OptionalFloat); + } + if (OptionalDouble != 0D) { + output.WriteRawTag(97); + output.WriteDouble(OptionalDouble); + } + if (OptionalBool != false) { + output.WriteRawTag(104); + output.WriteBool(OptionalBool); + } + if (OptionalString.Length != 0) { + output.WriteRawTag(114); + output.WriteString(OptionalString); + } + if (OptionalBytes.Length != 0) { + output.WriteRawTag(122); + output.WriteBytes(OptionalBytes); + } + if (optionalNestedMessage_ != null) { + output.WriteRawTag(146, 1); + output.WriteMessage(OptionalNestedMessage); + } + if (optionalForeignMessage_ != null) { + output.WriteRawTag(154, 1); + output.WriteMessage(OptionalForeignMessage); + } + if (OptionalNestedEnum != 0) { + output.WriteRawTag(168, 1); + output.WriteEnum((int) OptionalNestedEnum); + } + if (OptionalForeignEnum != 0) { + output.WriteRawTag(176, 1); + output.WriteEnum((int) OptionalForeignEnum); + } + if (OptionalStringPiece.Length != 0) { + output.WriteRawTag(194, 1); + output.WriteString(OptionalStringPiece); + } + if (OptionalCord.Length != 0) { + output.WriteRawTag(202, 1); + output.WriteString(OptionalCord); + } + if (recursiveMessage_ != null) { + output.WriteRawTag(218, 1); + output.WriteMessage(RecursiveMessage); + } + repeatedInt32_.WriteTo(output, _repeated_repeatedInt32_codec); + repeatedInt64_.WriteTo(output, _repeated_repeatedInt64_codec); + repeatedUint32_.WriteTo(output, _repeated_repeatedUint32_codec); + repeatedUint64_.WriteTo(output, _repeated_repeatedUint64_codec); + repeatedSint32_.WriteTo(output, _repeated_repeatedSint32_codec); + repeatedSint64_.WriteTo(output, _repeated_repeatedSint64_codec); + repeatedFixed32_.WriteTo(output, _repeated_repeatedFixed32_codec); + repeatedFixed64_.WriteTo(output, _repeated_repeatedFixed64_codec); + repeatedSfixed32_.WriteTo(output, _repeated_repeatedSfixed32_codec); + repeatedSfixed64_.WriteTo(output, _repeated_repeatedSfixed64_codec); + repeatedFloat_.WriteTo(output, _repeated_repeatedFloat_codec); + repeatedDouble_.WriteTo(output, _repeated_repeatedDouble_codec); + repeatedBool_.WriteTo(output, _repeated_repeatedBool_codec); + repeatedString_.WriteTo(output, _repeated_repeatedString_codec); + repeatedBytes_.WriteTo(output, _repeated_repeatedBytes_codec); + repeatedNestedMessage_.WriteTo(output, _repeated_repeatedNestedMessage_codec); + repeatedForeignMessage_.WriteTo(output, _repeated_repeatedForeignMessage_codec); + repeatedNestedEnum_.WriteTo(output, _repeated_repeatedNestedEnum_codec); + repeatedForeignEnum_.WriteTo(output, _repeated_repeatedForeignEnum_codec); + repeatedStringPiece_.WriteTo(output, _repeated_repeatedStringPiece_codec); + repeatedCord_.WriteTo(output, _repeated_repeatedCord_codec); + mapInt32Int32_.WriteTo(output, _map_mapInt32Int32_codec); + mapInt64Int64_.WriteTo(output, _map_mapInt64Int64_codec); + mapUint32Uint32_.WriteTo(output, _map_mapUint32Uint32_codec); + mapUint64Uint64_.WriteTo(output, _map_mapUint64Uint64_codec); + mapSint32Sint32_.WriteTo(output, _map_mapSint32Sint32_codec); + mapSint64Sint64_.WriteTo(output, _map_mapSint64Sint64_codec); + mapFixed32Fixed32_.WriteTo(output, _map_mapFixed32Fixed32_codec); + mapFixed64Fixed64_.WriteTo(output, _map_mapFixed64Fixed64_codec); + mapSfixed32Sfixed32_.WriteTo(output, _map_mapSfixed32Sfixed32_codec); + mapSfixed64Sfixed64_.WriteTo(output, _map_mapSfixed64Sfixed64_codec); + mapInt32Float_.WriteTo(output, _map_mapInt32Float_codec); + mapInt32Double_.WriteTo(output, _map_mapInt32Double_codec); + mapBoolBool_.WriteTo(output, _map_mapBoolBool_codec); + mapStringString_.WriteTo(output, _map_mapStringString_codec); + mapStringBytes_.WriteTo(output, _map_mapStringBytes_codec); + mapStringNestedMessage_.WriteTo(output, _map_mapStringNestedMessage_codec); + mapStringForeignMessage_.WriteTo(output, _map_mapStringForeignMessage_codec); + mapStringNestedEnum_.WriteTo(output, _map_mapStringNestedEnum_codec); + mapStringForeignEnum_.WriteTo(output, _map_mapStringForeignEnum_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + output.WriteRawTag(248, 6); + output.WriteUInt32(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + output.WriteRawTag(130, 7); + output.WriteMessage(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + output.WriteRawTag(138, 7); + output.WriteString(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + output.WriteRawTag(146, 7); + output.WriteBytes(OneofBytes); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { + output.WriteRawTag(152, 7); + output.WriteBool(OneofBool); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { + output.WriteRawTag(160, 7); + output.WriteUInt64(OneofUint64); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { + output.WriteRawTag(173, 7); + output.WriteFloat(OneofFloat); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { + output.WriteRawTag(177, 7); + output.WriteDouble(OneofDouble); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { + output.WriteRawTag(184, 7); + output.WriteEnum((int) OneofEnum); + } + if (optionalBoolWrapper_ != null) { + _single_optionalBoolWrapper_codec.WriteTagAndValue(output, OptionalBoolWrapper); + } + if (optionalInt32Wrapper_ != null) { + _single_optionalInt32Wrapper_codec.WriteTagAndValue(output, OptionalInt32Wrapper); + } + if (optionalInt64Wrapper_ != null) { + _single_optionalInt64Wrapper_codec.WriteTagAndValue(output, OptionalInt64Wrapper); + } + if (optionalUint32Wrapper_ != null) { + _single_optionalUint32Wrapper_codec.WriteTagAndValue(output, OptionalUint32Wrapper); + } + if (optionalUint64Wrapper_ != null) { + _single_optionalUint64Wrapper_codec.WriteTagAndValue(output, OptionalUint64Wrapper); + } + if (optionalFloatWrapper_ != null) { + _single_optionalFloatWrapper_codec.WriteTagAndValue(output, OptionalFloatWrapper); + } + if (optionalDoubleWrapper_ != null) { + _single_optionalDoubleWrapper_codec.WriteTagAndValue(output, OptionalDoubleWrapper); + } + if (optionalStringWrapper_ != null) { + _single_optionalStringWrapper_codec.WriteTagAndValue(output, OptionalStringWrapper); + } + if (optionalBytesWrapper_ != null) { + _single_optionalBytesWrapper_codec.WriteTagAndValue(output, OptionalBytesWrapper); + } + repeatedBoolWrapper_.WriteTo(output, _repeated_repeatedBoolWrapper_codec); + repeatedInt32Wrapper_.WriteTo(output, _repeated_repeatedInt32Wrapper_codec); + repeatedInt64Wrapper_.WriteTo(output, _repeated_repeatedInt64Wrapper_codec); + repeatedUint32Wrapper_.WriteTo(output, _repeated_repeatedUint32Wrapper_codec); + repeatedUint64Wrapper_.WriteTo(output, _repeated_repeatedUint64Wrapper_codec); + repeatedFloatWrapper_.WriteTo(output, _repeated_repeatedFloatWrapper_codec); + repeatedDoubleWrapper_.WriteTo(output, _repeated_repeatedDoubleWrapper_codec); + repeatedStringWrapper_.WriteTo(output, _repeated_repeatedStringWrapper_codec); + repeatedBytesWrapper_.WriteTo(output, _repeated_repeatedBytesWrapper_codec); + if (optionalDuration_ != null) { + output.WriteRawTag(234, 18); + output.WriteMessage(OptionalDuration); + } + if (optionalTimestamp_ != null) { + output.WriteRawTag(242, 18); + output.WriteMessage(OptionalTimestamp); + } + if (optionalFieldMask_ != null) { + output.WriteRawTag(250, 18); + output.WriteMessage(OptionalFieldMask); + } + if (optionalStruct_ != null) { + output.WriteRawTag(130, 19); + output.WriteMessage(OptionalStruct); + } + if (optionalAny_ != null) { + output.WriteRawTag(138, 19); + output.WriteMessage(OptionalAny); + } + if (optionalValue_ != null) { + output.WriteRawTag(146, 19); + output.WriteMessage(OptionalValue); + } + repeatedDuration_.WriteTo(output, _repeated_repeatedDuration_codec); + repeatedTimestamp_.WriteTo(output, _repeated_repeatedTimestamp_codec); + repeatedFieldmask_.WriteTo(output, _repeated_repeatedFieldmask_codec); + repeatedAny_.WriteTo(output, _repeated_repeatedAny_codec); + repeatedValue_.WriteTo(output, _repeated_repeatedValue_codec); + repeatedStruct_.WriteTo(output, _repeated_repeatedStruct_codec); + if (Fieldname1 != 0) { + output.WriteRawTag(136, 25); + output.WriteInt32(Fieldname1); + } + if (FieldName2 != 0) { + output.WriteRawTag(144, 25); + output.WriteInt32(FieldName2); + } + if (FieldName3 != 0) { + output.WriteRawTag(152, 25); + output.WriteInt32(FieldName3); + } + if (FieldName4 != 0) { + output.WriteRawTag(160, 25); + output.WriteInt32(FieldName4); + } + if (Field0Name5 != 0) { + output.WriteRawTag(168, 25); + output.WriteInt32(Field0Name5); + } + if (Field0Name6 != 0) { + output.WriteRawTag(176, 25); + output.WriteInt32(Field0Name6); + } + if (FieldName7 != 0) { + output.WriteRawTag(184, 25); + output.WriteInt32(FieldName7); + } + if (FieldName8 != 0) { + output.WriteRawTag(192, 25); + output.WriteInt32(FieldName8); + } + if (FieldName9 != 0) { + output.WriteRawTag(200, 25); + output.WriteInt32(FieldName9); + } + if (FieldName10 != 0) { + output.WriteRawTag(208, 25); + output.WriteInt32(FieldName10); + } + if (FIELDNAME11 != 0) { + output.WriteRawTag(216, 25); + output.WriteInt32(FIELDNAME11); + } + if (FIELDName12 != 0) { + output.WriteRawTag(224, 25); + output.WriteInt32(FIELDName12); + } + if (FieldName13 != 0) { + output.WriteRawTag(232, 25); + output.WriteInt32(FieldName13); + } + if (FieldName14 != 0) { + output.WriteRawTag(240, 25); + output.WriteInt32(FieldName14); + } + if (FieldName15 != 0) { + output.WriteRawTag(248, 25); + output.WriteInt32(FieldName15); + } + if (FieldName16 != 0) { + output.WriteRawTag(128, 26); + output.WriteInt32(FieldName16); + } + if (FieldName17 != 0) { + output.WriteRawTag(136, 26); + output.WriteInt32(FieldName17); + } + if (FieldName18 != 0) { + output.WriteRawTag(144, 26); + output.WriteInt32(FieldName18); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (OptionalInt32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(OptionalInt32); + } + if (OptionalInt64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(OptionalInt64); + } + if (OptionalUint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(OptionalUint32); + } + if (OptionalUint64 != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(OptionalUint64); + } + if (OptionalSint32 != 0) { + size += 1 + pb::CodedOutputStream.ComputeSInt32Size(OptionalSint32); + } + if (OptionalSint64 != 0L) { + size += 1 + pb::CodedOutputStream.ComputeSInt64Size(OptionalSint64); + } + if (OptionalFixed32 != 0) { + size += 1 + 4; + } + if (OptionalFixed64 != 0UL) { + size += 1 + 8; + } + if (OptionalSfixed32 != 0) { + size += 1 + 4; + } + if (OptionalSfixed64 != 0L) { + size += 1 + 8; + } + if (OptionalFloat != 0F) { + size += 1 + 4; + } + if (OptionalDouble != 0D) { + size += 1 + 8; + } + if (OptionalBool != false) { + size += 1 + 1; + } + if (OptionalString.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OptionalString); + } + if (OptionalBytes.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(OptionalBytes); + } + if (optionalNestedMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalNestedMessage); + } + if (optionalForeignMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage); + } + if (OptionalNestedEnum != 0) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum); + } + if (OptionalForeignEnum != 0) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum); + } + if (OptionalStringPiece.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalStringPiece); + } + if (OptionalCord.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OptionalCord); + } + if (recursiveMessage_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(RecursiveMessage); + } + size += repeatedInt32_.CalculateSize(_repeated_repeatedInt32_codec); + size += repeatedInt64_.CalculateSize(_repeated_repeatedInt64_codec); + size += repeatedUint32_.CalculateSize(_repeated_repeatedUint32_codec); + size += repeatedUint64_.CalculateSize(_repeated_repeatedUint64_codec); + size += repeatedSint32_.CalculateSize(_repeated_repeatedSint32_codec); + size += repeatedSint64_.CalculateSize(_repeated_repeatedSint64_codec); + size += repeatedFixed32_.CalculateSize(_repeated_repeatedFixed32_codec); + size += repeatedFixed64_.CalculateSize(_repeated_repeatedFixed64_codec); + size += repeatedSfixed32_.CalculateSize(_repeated_repeatedSfixed32_codec); + size += repeatedSfixed64_.CalculateSize(_repeated_repeatedSfixed64_codec); + size += repeatedFloat_.CalculateSize(_repeated_repeatedFloat_codec); + size += repeatedDouble_.CalculateSize(_repeated_repeatedDouble_codec); + size += repeatedBool_.CalculateSize(_repeated_repeatedBool_codec); + size += repeatedString_.CalculateSize(_repeated_repeatedString_codec); + size += repeatedBytes_.CalculateSize(_repeated_repeatedBytes_codec); + size += repeatedNestedMessage_.CalculateSize(_repeated_repeatedNestedMessage_codec); + size += repeatedForeignMessage_.CalculateSize(_repeated_repeatedForeignMessage_codec); + size += repeatedNestedEnum_.CalculateSize(_repeated_repeatedNestedEnum_codec); + size += repeatedForeignEnum_.CalculateSize(_repeated_repeatedForeignEnum_codec); + size += repeatedStringPiece_.CalculateSize(_repeated_repeatedStringPiece_codec); + size += repeatedCord_.CalculateSize(_repeated_repeatedCord_codec); + size += mapInt32Int32_.CalculateSize(_map_mapInt32Int32_codec); + size += mapInt64Int64_.CalculateSize(_map_mapInt64Int64_codec); + size += mapUint32Uint32_.CalculateSize(_map_mapUint32Uint32_codec); + size += mapUint64Uint64_.CalculateSize(_map_mapUint64Uint64_codec); + size += mapSint32Sint32_.CalculateSize(_map_mapSint32Sint32_codec); + size += mapSint64Sint64_.CalculateSize(_map_mapSint64Sint64_codec); + size += mapFixed32Fixed32_.CalculateSize(_map_mapFixed32Fixed32_codec); + size += mapFixed64Fixed64_.CalculateSize(_map_mapFixed64Fixed64_codec); + size += mapSfixed32Sfixed32_.CalculateSize(_map_mapSfixed32Sfixed32_codec); + size += mapSfixed64Sfixed64_.CalculateSize(_map_mapSfixed64Sfixed64_codec); + size += mapInt32Float_.CalculateSize(_map_mapInt32Float_codec); + size += mapInt32Double_.CalculateSize(_map_mapInt32Double_codec); + size += mapBoolBool_.CalculateSize(_map_mapBoolBool_codec); + size += mapStringString_.CalculateSize(_map_mapStringString_codec); + size += mapStringBytes_.CalculateSize(_map_mapStringBytes_codec); + size += mapStringNestedMessage_.CalculateSize(_map_mapStringNestedMessage_codec); + size += mapStringForeignMessage_.CalculateSize(_map_mapStringForeignMessage_codec); + size += mapStringNestedEnum_.CalculateSize(_map_mapStringNestedEnum_codec); + size += mapStringForeignEnum_.CalculateSize(_map_mapStringForeignEnum_codec); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint32) { + size += 2 + pb::CodedOutputStream.ComputeUInt32Size(OneofUint32); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OneofNestedMessage); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofString) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(OneofString); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBytes) { + size += 2 + pb::CodedOutputStream.ComputeBytesSize(OneofBytes); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofBool) { + size += 2 + 1; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofUint64) { + size += 2 + pb::CodedOutputStream.ComputeUInt64Size(OneofUint64); + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofFloat) { + size += 2 + 4; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofDouble) { + size += 2 + 8; + } + if (oneofFieldCase_ == OneofFieldOneofCase.OneofEnum) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OneofEnum); + } + if (optionalBoolWrapper_ != null) { + size += _single_optionalBoolWrapper_codec.CalculateSizeWithTag(OptionalBoolWrapper); + } + if (optionalInt32Wrapper_ != null) { + size += _single_optionalInt32Wrapper_codec.CalculateSizeWithTag(OptionalInt32Wrapper); + } + if (optionalInt64Wrapper_ != null) { + size += _single_optionalInt64Wrapper_codec.CalculateSizeWithTag(OptionalInt64Wrapper); + } + if (optionalUint32Wrapper_ != null) { + size += _single_optionalUint32Wrapper_codec.CalculateSizeWithTag(OptionalUint32Wrapper); + } + if (optionalUint64Wrapper_ != null) { + size += _single_optionalUint64Wrapper_codec.CalculateSizeWithTag(OptionalUint64Wrapper); + } + if (optionalFloatWrapper_ != null) { + size += _single_optionalFloatWrapper_codec.CalculateSizeWithTag(OptionalFloatWrapper); + } + if (optionalDoubleWrapper_ != null) { + size += _single_optionalDoubleWrapper_codec.CalculateSizeWithTag(OptionalDoubleWrapper); + } + if (optionalStringWrapper_ != null) { + size += _single_optionalStringWrapper_codec.CalculateSizeWithTag(OptionalStringWrapper); + } + if (optionalBytesWrapper_ != null) { + size += _single_optionalBytesWrapper_codec.CalculateSizeWithTag(OptionalBytesWrapper); + } + size += repeatedBoolWrapper_.CalculateSize(_repeated_repeatedBoolWrapper_codec); + size += repeatedInt32Wrapper_.CalculateSize(_repeated_repeatedInt32Wrapper_codec); + size += repeatedInt64Wrapper_.CalculateSize(_repeated_repeatedInt64Wrapper_codec); + size += repeatedUint32Wrapper_.CalculateSize(_repeated_repeatedUint32Wrapper_codec); + size += repeatedUint64Wrapper_.CalculateSize(_repeated_repeatedUint64Wrapper_codec); + size += repeatedFloatWrapper_.CalculateSize(_repeated_repeatedFloatWrapper_codec); + size += repeatedDoubleWrapper_.CalculateSize(_repeated_repeatedDoubleWrapper_codec); + size += repeatedStringWrapper_.CalculateSize(_repeated_repeatedStringWrapper_codec); + size += repeatedBytesWrapper_.CalculateSize(_repeated_repeatedBytesWrapper_codec); + if (optionalDuration_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalDuration); + } + if (optionalTimestamp_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalTimestamp); + } + if (optionalFieldMask_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalFieldMask); + } + if (optionalStruct_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalStruct); + } + if (optionalAny_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalAny); + } + if (optionalValue_ != null) { + size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalValue); + } + size += repeatedDuration_.CalculateSize(_repeated_repeatedDuration_codec); + size += repeatedTimestamp_.CalculateSize(_repeated_repeatedTimestamp_codec); + size += repeatedFieldmask_.CalculateSize(_repeated_repeatedFieldmask_codec); + size += repeatedStruct_.CalculateSize(_repeated_repeatedStruct_codec); + size += repeatedAny_.CalculateSize(_repeated_repeatedAny_codec); + size += repeatedValue_.CalculateSize(_repeated_repeatedValue_codec); + if (Fieldname1 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1); + } + if (FieldName2 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName2); + } + if (FieldName3 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName3); + } + if (FieldName4 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName4); + } + if (Field0Name5 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name5); + } + if (Field0Name6 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(Field0Name6); + } + if (FieldName7 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName7); + } + if (FieldName8 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName8); + } + if (FieldName9 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName9); + } + if (FieldName10 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName10); + } + if (FIELDNAME11 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDNAME11); + } + if (FIELDName12 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FIELDName12); + } + if (FieldName13 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName13); + } + if (FieldName14 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName14); + } + if (FieldName15 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName15); + } + if (FieldName16 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName16); + } + if (FieldName17 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName17); + } + if (FieldName18 != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(FieldName18); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(TestAllTypes other) { + if (other == null) { + return; + } + if (other.OptionalInt32 != 0) { + OptionalInt32 = other.OptionalInt32; + } + if (other.OptionalInt64 != 0L) { + OptionalInt64 = other.OptionalInt64; + } + if (other.OptionalUint32 != 0) { + OptionalUint32 = other.OptionalUint32; + } + if (other.OptionalUint64 != 0UL) { + OptionalUint64 = other.OptionalUint64; + } + if (other.OptionalSint32 != 0) { + OptionalSint32 = other.OptionalSint32; + } + if (other.OptionalSint64 != 0L) { + OptionalSint64 = other.OptionalSint64; + } + if (other.OptionalFixed32 != 0) { + OptionalFixed32 = other.OptionalFixed32; + } + if (other.OptionalFixed64 != 0UL) { + OptionalFixed64 = other.OptionalFixed64; + } + if (other.OptionalSfixed32 != 0) { + OptionalSfixed32 = other.OptionalSfixed32; + } + if (other.OptionalSfixed64 != 0L) { + OptionalSfixed64 = other.OptionalSfixed64; + } + if (other.OptionalFloat != 0F) { + OptionalFloat = other.OptionalFloat; + } + if (other.OptionalDouble != 0D) { + OptionalDouble = other.OptionalDouble; + } + if (other.OptionalBool != false) { + OptionalBool = other.OptionalBool; + } + if (other.OptionalString.Length != 0) { + OptionalString = other.OptionalString; + } + if (other.OptionalBytes.Length != 0) { + OptionalBytes = other.OptionalBytes; + } + if (other.optionalNestedMessage_ != null) { + if (optionalNestedMessage_ == null) { + optionalNestedMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage(); + } + OptionalNestedMessage.MergeFrom(other.OptionalNestedMessage); + } + if (other.optionalForeignMessage_ != null) { + if (optionalForeignMessage_ == null) { + optionalForeignMessage_ = new global::ProtobufTestMessages.Proto3.ForeignMessage(); + } + OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage); + } + if (other.OptionalNestedEnum != 0) { + OptionalNestedEnum = other.OptionalNestedEnum; + } + if (other.OptionalForeignEnum != 0) { + OptionalForeignEnum = other.OptionalForeignEnum; + } + if (other.OptionalStringPiece.Length != 0) { + OptionalStringPiece = other.OptionalStringPiece; + } + if (other.OptionalCord.Length != 0) { + OptionalCord = other.OptionalCord; + } + if (other.recursiveMessage_ != null) { + if (recursiveMessage_ == null) { + recursiveMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes(); + } + RecursiveMessage.MergeFrom(other.RecursiveMessage); + } + repeatedInt32_.Add(other.repeatedInt32_); + repeatedInt64_.Add(other.repeatedInt64_); + repeatedUint32_.Add(other.repeatedUint32_); + repeatedUint64_.Add(other.repeatedUint64_); + repeatedSint32_.Add(other.repeatedSint32_); + repeatedSint64_.Add(other.repeatedSint64_); + repeatedFixed32_.Add(other.repeatedFixed32_); + repeatedFixed64_.Add(other.repeatedFixed64_); + repeatedSfixed32_.Add(other.repeatedSfixed32_); + repeatedSfixed64_.Add(other.repeatedSfixed64_); + repeatedFloat_.Add(other.repeatedFloat_); + repeatedDouble_.Add(other.repeatedDouble_); + repeatedBool_.Add(other.repeatedBool_); + repeatedString_.Add(other.repeatedString_); + repeatedBytes_.Add(other.repeatedBytes_); + repeatedNestedMessage_.Add(other.repeatedNestedMessage_); + repeatedForeignMessage_.Add(other.repeatedForeignMessage_); + repeatedNestedEnum_.Add(other.repeatedNestedEnum_); + repeatedForeignEnum_.Add(other.repeatedForeignEnum_); + repeatedStringPiece_.Add(other.repeatedStringPiece_); + repeatedCord_.Add(other.repeatedCord_); + mapInt32Int32_.Add(other.mapInt32Int32_); + mapInt64Int64_.Add(other.mapInt64Int64_); + mapUint32Uint32_.Add(other.mapUint32Uint32_); + mapUint64Uint64_.Add(other.mapUint64Uint64_); + mapSint32Sint32_.Add(other.mapSint32Sint32_); + mapSint64Sint64_.Add(other.mapSint64Sint64_); + mapFixed32Fixed32_.Add(other.mapFixed32Fixed32_); + mapFixed64Fixed64_.Add(other.mapFixed64Fixed64_); + mapSfixed32Sfixed32_.Add(other.mapSfixed32Sfixed32_); + mapSfixed64Sfixed64_.Add(other.mapSfixed64Sfixed64_); + mapInt32Float_.Add(other.mapInt32Float_); + mapInt32Double_.Add(other.mapInt32Double_); + mapBoolBool_.Add(other.mapBoolBool_); + mapStringString_.Add(other.mapStringString_); + mapStringBytes_.Add(other.mapStringBytes_); + mapStringNestedMessage_.Add(other.mapStringNestedMessage_); + mapStringForeignMessage_.Add(other.mapStringForeignMessage_); + mapStringNestedEnum_.Add(other.mapStringNestedEnum_); + mapStringForeignEnum_.Add(other.mapStringForeignEnum_); + if (other.optionalBoolWrapper_ != null) { + if (optionalBoolWrapper_ == null || other.OptionalBoolWrapper != false) { + OptionalBoolWrapper = other.OptionalBoolWrapper; + } + } + if (other.optionalInt32Wrapper_ != null) { + if (optionalInt32Wrapper_ == null || other.OptionalInt32Wrapper != 0) { + OptionalInt32Wrapper = other.OptionalInt32Wrapper; + } + } + if (other.optionalInt64Wrapper_ != null) { + if (optionalInt64Wrapper_ == null || other.OptionalInt64Wrapper != 0L) { + OptionalInt64Wrapper = other.OptionalInt64Wrapper; + } + } + if (other.optionalUint32Wrapper_ != null) { + if (optionalUint32Wrapper_ == null || other.OptionalUint32Wrapper != 0) { + OptionalUint32Wrapper = other.OptionalUint32Wrapper; + } + } + if (other.optionalUint64Wrapper_ != null) { + if (optionalUint64Wrapper_ == null || other.OptionalUint64Wrapper != 0UL) { + OptionalUint64Wrapper = other.OptionalUint64Wrapper; + } + } + if (other.optionalFloatWrapper_ != null) { + if (optionalFloatWrapper_ == null || other.OptionalFloatWrapper != 0F) { + OptionalFloatWrapper = other.OptionalFloatWrapper; + } + } + if (other.optionalDoubleWrapper_ != null) { + if (optionalDoubleWrapper_ == null || other.OptionalDoubleWrapper != 0D) { + OptionalDoubleWrapper = other.OptionalDoubleWrapper; + } + } + if (other.optionalStringWrapper_ != null) { + if (optionalStringWrapper_ == null || other.OptionalStringWrapper != "") { + OptionalStringWrapper = other.OptionalStringWrapper; + } + } + if (other.optionalBytesWrapper_ != null) { + if (optionalBytesWrapper_ == null || other.OptionalBytesWrapper != pb::ByteString.Empty) { + OptionalBytesWrapper = other.OptionalBytesWrapper; + } + } + repeatedBoolWrapper_.Add(other.repeatedBoolWrapper_); + repeatedInt32Wrapper_.Add(other.repeatedInt32Wrapper_); + repeatedInt64Wrapper_.Add(other.repeatedInt64Wrapper_); + repeatedUint32Wrapper_.Add(other.repeatedUint32Wrapper_); + repeatedUint64Wrapper_.Add(other.repeatedUint64Wrapper_); + repeatedFloatWrapper_.Add(other.repeatedFloatWrapper_); + repeatedDoubleWrapper_.Add(other.repeatedDoubleWrapper_); + repeatedStringWrapper_.Add(other.repeatedStringWrapper_); + repeatedBytesWrapper_.Add(other.repeatedBytesWrapper_); + if (other.optionalDuration_ != null) { + if (optionalDuration_ == null) { + optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + OptionalDuration.MergeFrom(other.OptionalDuration); + } + if (other.optionalTimestamp_ != null) { + if (optionalTimestamp_ == null) { + optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + OptionalTimestamp.MergeFrom(other.OptionalTimestamp); + } + if (other.optionalFieldMask_ != null) { + if (optionalFieldMask_ == null) { + optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + OptionalFieldMask.MergeFrom(other.OptionalFieldMask); + } + if (other.optionalStruct_ != null) { + if (optionalStruct_ == null) { + optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + OptionalStruct.MergeFrom(other.OptionalStruct); + } + if (other.optionalAny_ != null) { + if (optionalAny_ == null) { + optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + OptionalAny.MergeFrom(other.OptionalAny); + } + if (other.optionalValue_ != null) { + if (optionalValue_ == null) { + optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); + } + OptionalValue.MergeFrom(other.OptionalValue); + } + repeatedDuration_.Add(other.repeatedDuration_); + repeatedTimestamp_.Add(other.repeatedTimestamp_); + repeatedFieldmask_.Add(other.repeatedFieldmask_); + repeatedStruct_.Add(other.repeatedStruct_); + repeatedAny_.Add(other.repeatedAny_); + repeatedValue_.Add(other.repeatedValue_); + if (other.Fieldname1 != 0) { + Fieldname1 = other.Fieldname1; + } + if (other.FieldName2 != 0) { + FieldName2 = other.FieldName2; + } + if (other.FieldName3 != 0) { + FieldName3 = other.FieldName3; + } + if (other.FieldName4 != 0) { + FieldName4 = other.FieldName4; + } + if (other.Field0Name5 != 0) { + Field0Name5 = other.Field0Name5; + } + if (other.Field0Name6 != 0) { + Field0Name6 = other.Field0Name6; + } + if (other.FieldName7 != 0) { + FieldName7 = other.FieldName7; + } + if (other.FieldName8 != 0) { + FieldName8 = other.FieldName8; + } + if (other.FieldName9 != 0) { + FieldName9 = other.FieldName9; + } + if (other.FieldName10 != 0) { + FieldName10 = other.FieldName10; + } + if (other.FIELDNAME11 != 0) { + FIELDNAME11 = other.FIELDNAME11; + } + if (other.FIELDName12 != 0) { + FIELDName12 = other.FIELDName12; + } + if (other.FieldName13 != 0) { + FieldName13 = other.FieldName13; + } + if (other.FieldName14 != 0) { + FieldName14 = other.FieldName14; + } + if (other.FieldName15 != 0) { + FieldName15 = other.FieldName15; + } + if (other.FieldName16 != 0) { + FieldName16 = other.FieldName16; + } + if (other.FieldName17 != 0) { + FieldName17 = other.FieldName17; + } + if (other.FieldName18 != 0) { + FieldName18 = other.FieldName18; + } + switch (other.OneofFieldCase) { + case OneofFieldOneofCase.OneofUint32: + OneofUint32 = other.OneofUint32; + break; + case OneofFieldOneofCase.OneofNestedMessage: + OneofNestedMessage = other.OneofNestedMessage; + break; + case OneofFieldOneofCase.OneofString: + OneofString = other.OneofString; + break; + case OneofFieldOneofCase.OneofBytes: + OneofBytes = other.OneofBytes; + break; + case OneofFieldOneofCase.OneofBool: + OneofBool = other.OneofBool; + break; + case OneofFieldOneofCase.OneofUint64: + OneofUint64 = other.OneofUint64; + break; + case OneofFieldOneofCase.OneofFloat: + OneofFloat = other.OneofFloat; + break; + case OneofFieldOneofCase.OneofDouble: + OneofDouble = other.OneofDouble; + break; + case OneofFieldOneofCase.OneofEnum: + OneofEnum = other.OneofEnum; + break; + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + OptionalInt32 = input.ReadInt32(); + break; + } + case 16: { + OptionalInt64 = input.ReadInt64(); + break; + } + case 24: { + OptionalUint32 = input.ReadUInt32(); + break; + } + case 32: { + OptionalUint64 = input.ReadUInt64(); + break; + } + case 40: { + OptionalSint32 = input.ReadSInt32(); + break; + } + case 48: { + OptionalSint64 = input.ReadSInt64(); + break; + } + case 61: { + OptionalFixed32 = input.ReadFixed32(); + break; + } + case 65: { + OptionalFixed64 = input.ReadFixed64(); + break; + } + case 77: { + OptionalSfixed32 = input.ReadSFixed32(); + break; + } + case 81: { + OptionalSfixed64 = input.ReadSFixed64(); + break; + } + case 93: { + OptionalFloat = input.ReadFloat(); + break; + } + case 97: { + OptionalDouble = input.ReadDouble(); + break; + } + case 104: { + OptionalBool = input.ReadBool(); + break; + } + case 114: { + OptionalString = input.ReadString(); + break; + } + case 122: { + OptionalBytes = input.ReadBytes(); + break; + } + case 146: { + if (optionalNestedMessage_ == null) { + optionalNestedMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage(); + } + input.ReadMessage(optionalNestedMessage_); + break; + } + case 154: { + if (optionalForeignMessage_ == null) { + optionalForeignMessage_ = new global::ProtobufTestMessages.Proto3.ForeignMessage(); + } + input.ReadMessage(optionalForeignMessage_); + break; + } + case 168: { + optionalNestedEnum_ = (global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedEnum) input.ReadEnum(); + break; + } + case 176: { + optionalForeignEnum_ = (global::ProtobufTestMessages.Proto3.ForeignEnum) input.ReadEnum(); + break; + } + case 194: { + OptionalStringPiece = input.ReadString(); + break; + } + case 202: { + OptionalCord = input.ReadString(); + break; + } + case 218: { + if (recursiveMessage_ == null) { + recursiveMessage_ = new global::ProtobufTestMessages.Proto3.TestAllTypes(); + } + input.ReadMessage(recursiveMessage_); + break; + } + case 250: + case 248: { + repeatedInt32_.AddEntriesFrom(input, _repeated_repeatedInt32_codec); + break; + } + case 258: + case 256: { + repeatedInt64_.AddEntriesFrom(input, _repeated_repeatedInt64_codec); + break; + } + case 266: + case 264: { + repeatedUint32_.AddEntriesFrom(input, _repeated_repeatedUint32_codec); + break; + } + case 274: + case 272: { + repeatedUint64_.AddEntriesFrom(input, _repeated_repeatedUint64_codec); + break; + } + case 282: + case 280: { + repeatedSint32_.AddEntriesFrom(input, _repeated_repeatedSint32_codec); + break; + } + case 290: + case 288: { + repeatedSint64_.AddEntriesFrom(input, _repeated_repeatedSint64_codec); + break; + } + case 298: + case 301: { + repeatedFixed32_.AddEntriesFrom(input, _repeated_repeatedFixed32_codec); + break; + } + case 306: + case 305: { + repeatedFixed64_.AddEntriesFrom(input, _repeated_repeatedFixed64_codec); + break; + } + case 314: + case 317: { + repeatedSfixed32_.AddEntriesFrom(input, _repeated_repeatedSfixed32_codec); + break; + } + case 322: + case 321: { + repeatedSfixed64_.AddEntriesFrom(input, _repeated_repeatedSfixed64_codec); + break; + } + case 330: + case 333: { + repeatedFloat_.AddEntriesFrom(input, _repeated_repeatedFloat_codec); + break; + } + case 338: + case 337: { + repeatedDouble_.AddEntriesFrom(input, _repeated_repeatedDouble_codec); + break; + } + case 346: + case 344: { + repeatedBool_.AddEntriesFrom(input, _repeated_repeatedBool_codec); + break; + } + case 354: { + repeatedString_.AddEntriesFrom(input, _repeated_repeatedString_codec); + break; + } + case 362: { + repeatedBytes_.AddEntriesFrom(input, _repeated_repeatedBytes_codec); + break; + } + case 386: { + repeatedNestedMessage_.AddEntriesFrom(input, _repeated_repeatedNestedMessage_codec); + break; + } + case 394: { + repeatedForeignMessage_.AddEntriesFrom(input, _repeated_repeatedForeignMessage_codec); + break; + } + case 410: + case 408: { + repeatedNestedEnum_.AddEntriesFrom(input, _repeated_repeatedNestedEnum_codec); + break; + } + case 418: + case 416: { + repeatedForeignEnum_.AddEntriesFrom(input, _repeated_repeatedForeignEnum_codec); + break; + } + case 434: { + repeatedStringPiece_.AddEntriesFrom(input, _repeated_repeatedStringPiece_codec); + break; + } + case 442: { + repeatedCord_.AddEntriesFrom(input, _repeated_repeatedCord_codec); + break; + } + case 450: { + mapInt32Int32_.AddEntriesFrom(input, _map_mapInt32Int32_codec); + break; + } + case 458: { + mapInt64Int64_.AddEntriesFrom(input, _map_mapInt64Int64_codec); + break; + } + case 466: { + mapUint32Uint32_.AddEntriesFrom(input, _map_mapUint32Uint32_codec); + break; + } + case 474: { + mapUint64Uint64_.AddEntriesFrom(input, _map_mapUint64Uint64_codec); + break; + } + case 482: { + mapSint32Sint32_.AddEntriesFrom(input, _map_mapSint32Sint32_codec); + break; + } + case 490: { + mapSint64Sint64_.AddEntriesFrom(input, _map_mapSint64Sint64_codec); + break; + } + case 498: { + mapFixed32Fixed32_.AddEntriesFrom(input, _map_mapFixed32Fixed32_codec); + break; + } + case 506: { + mapFixed64Fixed64_.AddEntriesFrom(input, _map_mapFixed64Fixed64_codec); + break; + } + case 514: { + mapSfixed32Sfixed32_.AddEntriesFrom(input, _map_mapSfixed32Sfixed32_codec); + break; + } + case 522: { + mapSfixed64Sfixed64_.AddEntriesFrom(input, _map_mapSfixed64Sfixed64_codec); + break; + } + case 530: { + mapInt32Float_.AddEntriesFrom(input, _map_mapInt32Float_codec); + break; + } + case 538: { + mapInt32Double_.AddEntriesFrom(input, _map_mapInt32Double_codec); + break; + } + case 546: { + mapBoolBool_.AddEntriesFrom(input, _map_mapBoolBool_codec); + break; + } + case 554: { + mapStringString_.AddEntriesFrom(input, _map_mapStringString_codec); + break; + } + case 562: { + mapStringBytes_.AddEntriesFrom(input, _map_mapStringBytes_codec); + break; + } + case 570: { + mapStringNestedMessage_.AddEntriesFrom(input, _map_mapStringNestedMessage_codec); + break; + } + case 578: { + mapStringForeignMessage_.AddEntriesFrom(input, _map_mapStringForeignMessage_codec); + break; + } + case 586: { + mapStringNestedEnum_.AddEntriesFrom(input, _map_mapStringNestedEnum_codec); + break; + } + case 594: { + mapStringForeignEnum_.AddEntriesFrom(input, _map_mapStringForeignEnum_codec); + break; + } + case 888: { + OneofUint32 = input.ReadUInt32(); + break; + } + case 898: { + global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage subBuilder = new global::ProtobufTestMessages.Proto3.TestAllTypes.Types.NestedMessage(); + if (oneofFieldCase_ == OneofFieldOneofCase.OneofNestedMessage) { + subBuilder.MergeFrom(OneofNestedMessage); + } + input.ReadMessage(subBuilder); + OneofNestedMessage = subBuilder; + break; + } + case 906: { + OneofString = input.ReadString(); + break; + } + case 914: { + OneofBytes = input.ReadBytes(); + break; + } + case 920: { + OneofBool = input.ReadBool(); + break; + } + case 928: { + OneofUint64 = input.ReadUInt64(); + break; + } + case 941: { + OneofFloat = input.ReadFloat(); + break; + } + case 945: { + OneofDouble = input.ReadDouble(); + break; + } + case 952: { + oneofField_ = input.ReadEnum(); + oneofFieldCase_ = OneofFieldOneofCase.OneofEnum; + break; + } + case 1610: { + bool? value = _single_optionalBoolWrapper_codec.Read(input); + if (optionalBoolWrapper_ == null || value != false) { + OptionalBoolWrapper = value; + } + break; + } + case 1618: { + int? value = _single_optionalInt32Wrapper_codec.Read(input); + if (optionalInt32Wrapper_ == null || value != 0) { + OptionalInt32Wrapper = value; + } + break; + } + case 1626: { + long? value = _single_optionalInt64Wrapper_codec.Read(input); + if (optionalInt64Wrapper_ == null || value != 0L) { + OptionalInt64Wrapper = value; + } + break; + } + case 1634: { + uint? value = _single_optionalUint32Wrapper_codec.Read(input); + if (optionalUint32Wrapper_ == null || value != 0) { + OptionalUint32Wrapper = value; + } + break; + } + case 1642: { + ulong? value = _single_optionalUint64Wrapper_codec.Read(input); + if (optionalUint64Wrapper_ == null || value != 0UL) { + OptionalUint64Wrapper = value; + } + break; + } + case 1650: { + float? value = _single_optionalFloatWrapper_codec.Read(input); + if (optionalFloatWrapper_ == null || value != 0F) { + OptionalFloatWrapper = value; + } + break; + } + case 1658: { + double? value = _single_optionalDoubleWrapper_codec.Read(input); + if (optionalDoubleWrapper_ == null || value != 0D) { + OptionalDoubleWrapper = value; + } + break; + } + case 1666: { + string value = _single_optionalStringWrapper_codec.Read(input); + if (optionalStringWrapper_ == null || value != "") { + OptionalStringWrapper = value; + } + break; + } + case 1674: { + pb::ByteString value = _single_optionalBytesWrapper_codec.Read(input); + if (optionalBytesWrapper_ == null || value != pb::ByteString.Empty) { + OptionalBytesWrapper = value; + } + break; + } + case 1690: { + repeatedBoolWrapper_.AddEntriesFrom(input, _repeated_repeatedBoolWrapper_codec); + break; + } + case 1698: { + repeatedInt32Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt32Wrapper_codec); + break; + } + case 1706: { + repeatedInt64Wrapper_.AddEntriesFrom(input, _repeated_repeatedInt64Wrapper_codec); + break; + } + case 1714: { + repeatedUint32Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint32Wrapper_codec); + break; + } + case 1722: { + repeatedUint64Wrapper_.AddEntriesFrom(input, _repeated_repeatedUint64Wrapper_codec); + break; + } + case 1730: { + repeatedFloatWrapper_.AddEntriesFrom(input, _repeated_repeatedFloatWrapper_codec); + break; + } + case 1738: { + repeatedDoubleWrapper_.AddEntriesFrom(input, _repeated_repeatedDoubleWrapper_codec); + break; + } + case 1746: { + repeatedStringWrapper_.AddEntriesFrom(input, _repeated_repeatedStringWrapper_codec); + break; + } + case 1754: { + repeatedBytesWrapper_.AddEntriesFrom(input, _repeated_repeatedBytesWrapper_codec); + break; + } + case 2410: { + if (optionalDuration_ == null) { + optionalDuration_ = new global::Google.Protobuf.WellKnownTypes.Duration(); + } + input.ReadMessage(optionalDuration_); + break; + } + case 2418: { + if (optionalTimestamp_ == null) { + optionalTimestamp_ = new global::Google.Protobuf.WellKnownTypes.Timestamp(); + } + input.ReadMessage(optionalTimestamp_); + break; + } + case 2426: { + if (optionalFieldMask_ == null) { + optionalFieldMask_ = new global::Google.Protobuf.WellKnownTypes.FieldMask(); + } + input.ReadMessage(optionalFieldMask_); + break; + } + case 2434: { + if (optionalStruct_ == null) { + optionalStruct_ = new global::Google.Protobuf.WellKnownTypes.Struct(); + } + input.ReadMessage(optionalStruct_); + break; + } + case 2442: { + if (optionalAny_ == null) { + optionalAny_ = new global::Google.Protobuf.WellKnownTypes.Any(); + } + input.ReadMessage(optionalAny_); + break; + } + case 2450: { + if (optionalValue_ == null) { + optionalValue_ = new global::Google.Protobuf.WellKnownTypes.Value(); + } + input.ReadMessage(optionalValue_); + break; + } + case 2490: { + repeatedDuration_.AddEntriesFrom(input, _repeated_repeatedDuration_codec); + break; + } + case 2498: { + repeatedTimestamp_.AddEntriesFrom(input, _repeated_repeatedTimestamp_codec); + break; + } + case 2506: { + repeatedFieldmask_.AddEntriesFrom(input, _repeated_repeatedFieldmask_codec); + break; + } + case 2522: { + repeatedAny_.AddEntriesFrom(input, _repeated_repeatedAny_codec); + break; + } + case 2530: { + repeatedValue_.AddEntriesFrom(input, _repeated_repeatedValue_codec); + break; + } + case 2594: { + repeatedStruct_.AddEntriesFrom(input, _repeated_repeatedStruct_codec); + break; + } + case 3208: { + Fieldname1 = input.ReadInt32(); + break; + } + case 3216: { + FieldName2 = input.ReadInt32(); + break; + } + case 3224: { + FieldName3 = input.ReadInt32(); + break; + } + case 3232: { + FieldName4 = input.ReadInt32(); + break; + } + case 3240: { + Field0Name5 = input.ReadInt32(); + break; + } + case 3248: { + Field0Name6 = input.ReadInt32(); + break; + } + case 3256: { + FieldName7 = input.ReadInt32(); + break; + } + case 3264: { + FieldName8 = input.ReadInt32(); + break; + } + case 3272: { + FieldName9 = input.ReadInt32(); + break; + } + case 3280: { + FieldName10 = input.ReadInt32(); + break; + } + case 3288: { + FIELDNAME11 = input.ReadInt32(); + break; + } + case 3296: { + FIELDName12 = input.ReadInt32(); + break; + } + case 3304: { + FieldName13 = input.ReadInt32(); + break; + } + case 3312: { + FieldName14 = input.ReadInt32(); + break; + } + case 3320: { + FieldName15 = input.ReadInt32(); + break; + } + case 3328: { + FieldName16 = input.ReadInt32(); + break; + } + case 3336: { + FieldName17 = input.ReadInt32(); + break; + } + case 3344: { + FieldName18 = input.ReadInt32(); + break; + } + } + } + } + + #region Nested types + /// <summary>Container for nested types declared in the TestAllTypes message type.</summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + public enum NestedEnum { + [pbr::OriginalName("FOO")] Foo = 0, + [pbr::OriginalName("BAR")] Bar = 1, + [pbr::OriginalName("BAZ")] Baz = 2, + /// <summary> + /// Intentionally negative. + /// </summary> + [pbr::OriginalName("NEG")] Neg = -1, + } + + public sealed partial class NestedMessage : pb::IMessage<NestedMessage> { + private static readonly pb::MessageParser<NestedMessage> _parser = new pb::MessageParser<NestedMessage>(() => new NestedMessage()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<NestedMessage> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestAllTypes.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage(NestedMessage other) : this() { + a_ = other.a_; + Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NestedMessage Clone() { + return new NestedMessage(this); + } + + /// <summary>Field number for the "a" field.</summary> + public const int AFieldNumber = 1; + private int a_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int A { + get { return a_; } + set { + a_ = value; + } + } + + /// <summary>Field number for the "corecursive" field.</summary> + public const int CorecursiveFieldNumber = 2; + private global::ProtobufTestMessages.Proto3.TestAllTypes corecursive_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::ProtobufTestMessages.Proto3.TestAllTypes Corecursive { + get { return corecursive_; } + set { + corecursive_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NestedMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NestedMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (A != other.A) return false; + if (!object.Equals(Corecursive, other.Corecursive)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (A != 0) hash ^= A.GetHashCode(); + if (corecursive_ != null) hash ^= Corecursive.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (A != 0) { + output.WriteRawTag(8); + output.WriteInt32(A); + } + if (corecursive_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Corecursive); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (A != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(A); + } + if (corecursive_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Corecursive); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NestedMessage other) { + if (other == null) { + return; + } + if (other.A != 0) { + A = other.A; + } + if (other.corecursive_ != null) { + if (corecursive_ == null) { + corecursive_ = new global::ProtobufTestMessages.Proto3.TestAllTypes(); + } + Corecursive.MergeFrom(other.Corecursive); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + A = input.ReadInt32(); + break; + } + case 18: { + if (corecursive_ == null) { + corecursive_ = new global::ProtobufTestMessages.Proto3.TestAllTypes(); + } + input.ReadMessage(corecursive_); + break; + } + } + } + } + + } + + } + #endregion + + } + + public sealed partial class ForeignMessage : pb::IMessage<ForeignMessage> { + private static readonly pb::MessageParser<ForeignMessage> _parser = new pb::MessageParser<ForeignMessage>(() => new ForeignMessage()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ForeignMessage> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::ProtobufTestMessages.Proto3.TestMessagesProto3Reflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage(ForeignMessage other) : this() { + c_ = other.c_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ForeignMessage Clone() { + return new ForeignMessage(this); + } + + /// <summary>Field number for the "c" field.</summary> + public const int CFieldNumber = 1; + private int c_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int C { + get { return c_; } + set { + c_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ForeignMessage); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ForeignMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (C != other.C) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (C != 0) hash ^= C.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (C != 0) { + output.WriteRawTag(8); + output.WriteInt32(C); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (C != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(C); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ForeignMessage other) { + if (other == null) { + return; + } + if (other.C != 0) { + C = other.C; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + C = input.ReadInt32(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 19155469..decc0b06 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection { "ASgJEhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5n", "b29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFt", "aW5nGAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVm", - "YWxzZSKEBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", + "YWxzZSKaBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwK", "FGphdmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVf", "ZmlsZXMYCiABKAg6BWZhbHNlEikKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2Fu", "ZF9oYXNoGBQgASgIQgIYARIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg", @@ -91,55 +91,60 @@ namespace Google.Protobuf.Reflection { "cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl", "ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs", "c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz", - "cGFjZRglIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n", - "b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRpbWl6", - "ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JVTlRJ", - "TUUQAyoJCOgHEICAgIACSgQIJhAnIuwBCg5NZXNzYWdlT3B0aW9ucxImChdt", - "ZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3Rh", - "bmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVw", - "cmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVu", - "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V", - "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAJKBAgIEAkingMKDEZpZWxk", - "T3B0aW9ucxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVs", - "ZE9wdGlvbnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0", - "eXBlGAYgASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5", - "cGU6CUpTX05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNh", - "dGVkGAMgASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmlu", - "dGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5p", - "bnRlcnByZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JE", - "EAESEAoMU1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAA", - "Eg0KCUpTX1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAJKBAgE", - "EAUiXgoMT25lb2ZPcHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcH", - "IAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI", - "6AcQgICAgAIijQEKC0VudW1PcHRpb25zEhMKC2FsbG93X2FsaWFzGAIgASgI", - "EhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRf", - "b3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVk", - "T3B0aW9uKgkI6AcQgICAgAIifQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXBy", - "ZWNhdGVkGAEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjn", - "ByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJ", - "COgHEICAgIACInsKDlNlcnZpY2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISAB", - "KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv", - "b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi", - "egoNTWV0aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJD", - "ChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9i", - "dWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIp4CChNVbmludGVy", - "cHJldGVkT3B0aW9uEjsKBG5hbWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYu", - "VW5pbnRlcnByZXRlZE9wdGlvbi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3Zh", - "bHVlGAMgASgJEhoKEnBvc2l0aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdh", - "dGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQK", - "DHN0cmluZ192YWx1ZRgHIAEoDBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAka", - "MwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lv", - "bhgCIAIoCCLVAQoOU291cmNlQ29kZUluZm8SOgoIbG9jYXRpb24YASADKAsy", - "KC5nb29nbGUucHJvdG9idWYuU291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEK", - "CExvY2F0aW9uEhAKBHBhdGgYASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhAB", - "EhgKEGxlYWRpbmdfY29tbWVudHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVu", - "dHMYBCABKAkSIQoZbGVhZGluZ19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKn", - "AQoRR2VuZXJhdGVkQ29kZUluZm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdv", - "b2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8K", - "CkFubm90YXRpb24SEAoEcGF0aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUY", - "AiABKAkSDQoFYmVnaW4YAyABKAUSCwoDZW5kGAQgASgFQlgKE2NvbS5nb29n", - "bGUucHJvdG9idWZCEERlc2NyaXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqIC", - "A0dQQqoCGkdvb2dsZS5Qcm90b2J1Zi5SZWZsZWN0aW9u")); + "cGFjZRglIAEoCRIUCgxzd2lmdF9wcmVmaXgYJyABKAkSQwoUdW5pbnRlcnBy", + "ZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJw", + "cmV0ZWRPcHRpb24iOgoMT3B0aW1pemVNb2RlEgkKBVNQRUVEEAESDQoJQ09E", + "RV9TSVpFEAISEAoMTElURV9SVU5USU1FEAMqCQjoBxCAgICAAkoECCYQJyLs", + "AQoOTWVzc2FnZU9wdGlvbnMSJgoXbWVzc2FnZV9zZXRfd2lyZV9mb3JtYXQY", + "ASABKAg6BWZhbHNlEi4KH25vX3N0YW5kYXJkX2Rlc2NyaXB0b3JfYWNjZXNz", + "b3IYAiABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEhEK", + "CW1hcF9lbnRyeRgHIAEoCBJDChR1bmludGVycHJldGVkX29wdGlvbhjnByAD", + "KAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgH", + "EICAgIACSgQICBAJIp4DCgxGaWVsZE9wdGlvbnMSOgoFY3R5cGUYASABKA4y", + "Iy5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLkNUeXBlOgZTVFJJTkcS", + "DgoGcGFja2VkGAIgASgIEj8KBmpzdHlwZRgGIAEoDjIkLmdvb2dsZS5wcm90", + "b2J1Zi5GaWVsZE9wdGlvbnMuSlNUeXBlOglKU19OT1JNQUwSEwoEbGF6eRgF", + "IAEoCDoFZmFsc2USGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEwoEd2Vh", + "axgKIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygL", + "MiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iLwoFQ1R5", + "cGUSCgoGU1RSSU5HEAASCAoEQ09SRBABEhAKDFNUUklOR19QSUVDRRACIjUK", + "BkpTVHlwZRINCglKU19OT1JNQUwQABINCglKU19TVFJJTkcQARINCglKU19O", + "VU1CRVIQAioJCOgHEICAgIACSgQIBBAFIl4KDE9uZW9mT3B0aW9ucxJDChR1", + "bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu", + "VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIo0BCgtFbnVtT3B0aW9u", + "cxITCgthbGxvd19hbGlhcxgCIAEoCBIZCgpkZXByZWNhdGVkGAMgASgIOgVm", + "YWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUu", + "cHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIn0KEEVu", + "dW1WYWx1ZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBgBIAEoCDoFZmFsc2USQwoU", + "dW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVm", + "LlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiJ7Cg5TZXJ2aWNlT3B0", + "aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJl", + "dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy", + "ZXRlZE9wdGlvbioJCOgHEICAgIACIq0CCg1NZXRob2RPcHRpb25zEhkKCmRl", + "cHJlY2F0ZWQYISABKAg6BWZhbHNlEl8KEWlkZW1wb3RlbmN5X2xldmVsGCIg", + "ASgOMi8uZ29vZ2xlLnByb3RvYnVmLk1ldGhvZE9wdGlvbnMuSWRlbXBvdGVu", + "Y3lMZXZlbDoTSURFTVBPVEVOQ1lfVU5LTk9XThJDChR1bmludGVycHJldGVk", + "X29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRl", + "ZE9wdGlvbiJQChBJZGVtcG90ZW5jeUxldmVsEhcKE0lERU1QT1RFTkNZX1VO", + "S05PV04QABITCg9OT19TSURFX0VGRkVDVFMQARIOCgpJREVNUE9URU5UEAIq", + "CQjoBxCAgICAAiKeAgoTVW5pbnRlcnByZXRlZE9wdGlvbhI7CgRuYW1lGAIg", + "AygLMi0uZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24uTmFt", + "ZVBhcnQSGAoQaWRlbnRpZmllcl92YWx1ZRgDIAEoCRIaChJwb3NpdGl2ZV9p", + "bnRfdmFsdWUYBCABKAQSGgoSbmVnYXRpdmVfaW50X3ZhbHVlGAUgASgDEhQK", + "DGRvdWJsZV92YWx1ZRgGIAEoARIUCgxzdHJpbmdfdmFsdWUYByABKAwSFwoP", + "YWdncmVnYXRlX3ZhbHVlGAggASgJGjMKCE5hbWVQYXJ0EhEKCW5hbWVfcGFy", + "dBgBIAIoCRIUCgxpc19leHRlbnNpb24YAiACKAgi1QEKDlNvdXJjZUNvZGVJ", + "bmZvEjoKCGxvY2F0aW9uGAEgAygLMiguZ29vZ2xlLnByb3RvYnVmLlNvdXJj", + "ZUNvZGVJbmZvLkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygF", + "QgIQARIQCgRzcGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMg", + "ASgJEhkKEXRyYWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0", + "YWNoZWRfY29tbWVudHMYBiADKAkipwEKEUdlbmVyYXRlZENvZGVJbmZvEkEK", + "CmFubm90YXRpb24YASADKAsyLS5nb29nbGUucHJvdG9idWYuR2VuZXJhdGVk", + "Q29kZUluZm8uQW5ub3RhdGlvbhpPCgpBbm5vdGF0aW9uEhAKBHBhdGgYASAD", + "KAVCAhABEhMKC3NvdXJjZV9maWxlGAIgASgJEg0KBWJlZ2luGAMgASgFEgsK", + "A2VuZBgEIAEoBUJYChNjb20uZ29vZ2xlLnByb3RvYnVmQhBEZXNjcmlwdG9y", + "UHJvdG9zSAFaCmRlc2NyaXB0b3KiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYu", + "UmVmbGVjdGlvbg==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -153,14 +158,14 @@ namespace Google.Protobuf.Reflection { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceOptions), global::Google.Protobuf.Reflection.ServiceOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodOptions), global::Google.Protobuf.Reflection.MethodOptions.Parser, new[]{ "Deprecated", "IdempotencyLevel", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption), global::Google.Protobuf.Reflection.UninterpretedOption.Parser, new[]{ "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart), global::Google.Protobuf.Reflection.UninterpretedOption.Types.NamePart.Parser, new[]{ "NamePart_", "IsExtension" }, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo), global::Google.Protobuf.Reflection.SourceCodeInfo.Parser, new[]{ "Location" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location), global::Google.Protobuf.Reflection.SourceCodeInfo.Types.Location.Parser, new[]{ "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments" }, null, null, null)}), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Parser, new[]{ "Annotation" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation), global::Google.Protobuf.Reflection.GeneratedCodeInfo.Types.Annotation.Parser, new[]{ "Path", "SourceFile", "Begin", "End" }, null, null, null)}) @@ -1790,9 +1795,6 @@ namespace Google.Protobuf.Reflection { /// </summary> [pbr::OriginalName("LABEL_OPTIONAL")] Optional = 1, [pbr::OriginalName("LABEL_REQUIRED")] Required = 2, - /// <summary> - /// TODO(sanjay): Should we add LABEL_MAP? - /// </summary> [pbr::OriginalName("LABEL_REPEATED")] Repeated = 3, } @@ -2799,6 +2801,7 @@ namespace Google.Protobuf.Reflection { ccEnableArenas_ = other.ccEnableArenas_; objcClassPrefix_ = other.objcClassPrefix_; csharpNamespace_ = other.csharpNamespace_; + swiftPrefix_ = other.swiftPrefix_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -3030,6 +3033,23 @@ namespace Google.Protobuf.Reflection { } } + /// <summary>Field number for the "swift_prefix" field.</summary> + public const int SwiftPrefixFieldNumber = 39; + private string swiftPrefix_ = ""; + /// <summary> + /// By default Swift generators will take the proto package and CamelCase it + /// replacing '.' with underscore and use that to prefix the types/symbols + /// defined. When this options is provided, they will use this value instead + /// to prefix the types/symbols defined. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string SwiftPrefix { + get { return swiftPrefix_; } + set { + swiftPrefix_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + /// <summary>Field number for the "uninterpreted_option" field.</summary> public const int UninterpretedOptionFieldNumber = 999; private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec @@ -3070,6 +3090,7 @@ namespace Google.Protobuf.Reflection { if (CcEnableArenas != other.CcEnableArenas) return false; if (ObjcClassPrefix != other.ObjcClassPrefix) return false; if (CsharpNamespace != other.CsharpNamespace) return false; + if (SwiftPrefix != other.SwiftPrefix) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; return true; } @@ -3091,6 +3112,7 @@ namespace Google.Protobuf.Reflection { if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); + if (SwiftPrefix.Length != 0) hash ^= SwiftPrefix.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); return hash; } @@ -3158,6 +3180,10 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(170, 2); output.WriteString(CsharpNamespace); } + if (SwiftPrefix.Length != 0) { + output.WriteRawTag(186, 2); + output.WriteString(SwiftPrefix); + } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } @@ -3206,6 +3232,9 @@ namespace Google.Protobuf.Reflection { if (CsharpNamespace.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } + if (SwiftPrefix.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(SwiftPrefix); + } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3257,6 +3286,9 @@ namespace Google.Protobuf.Reflection { if (other.CsharpNamespace.Length != 0) { CsharpNamespace = other.CsharpNamespace; } + if (other.SwiftPrefix.Length != 0) { + SwiftPrefix = other.SwiftPrefix; + } uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -3324,6 +3356,10 @@ namespace Google.Protobuf.Reflection { CsharpNamespace = input.ReadString(); break; } + case 314: { + SwiftPrefix = input.ReadString(); + break; + } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -4617,6 +4653,7 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodOptions(MethodOptions other) : this() { deprecated_ = other.deprecated_; + idempotencyLevel_ = other.idempotencyLevel_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -4642,6 +4679,17 @@ namespace Google.Protobuf.Reflection { } } + /// <summary>Field number for the "idempotency_level" field.</summary> + public const int IdempotencyLevelFieldNumber = 34; + private global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel idempotencyLevel_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel IdempotencyLevel { + get { return idempotencyLevel_; } + set { + idempotencyLevel_ = value; + } + } + /// <summary>Field number for the "uninterpreted_option" field.</summary> public const int UninterpretedOptionFieldNumber = 999; private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec @@ -4669,6 +4717,7 @@ namespace Google.Protobuf.Reflection { return true; } if (Deprecated != other.Deprecated) return false; + if (IdempotencyLevel != other.IdempotencyLevel) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; return true; } @@ -4677,6 +4726,7 @@ namespace Google.Protobuf.Reflection { public override int GetHashCode() { int hash = 1; if (Deprecated != false) hash ^= Deprecated.GetHashCode(); + if (IdempotencyLevel != 0) hash ^= IdempotencyLevel.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); return hash; } @@ -4692,6 +4742,10 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(136, 2); output.WriteBool(Deprecated); } + if (IdempotencyLevel != 0) { + output.WriteRawTag(144, 2); + output.WriteEnum((int) IdempotencyLevel); + } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } @@ -4701,6 +4755,9 @@ namespace Google.Protobuf.Reflection { if (Deprecated != false) { size += 2 + 1; } + if (IdempotencyLevel != 0) { + size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) IdempotencyLevel); + } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -4713,6 +4770,9 @@ namespace Google.Protobuf.Reflection { if (other.Deprecated != false) { Deprecated = other.Deprecated; } + if (other.IdempotencyLevel != 0) { + IdempotencyLevel = other.IdempotencyLevel; + } uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -4728,6 +4788,10 @@ namespace Google.Protobuf.Reflection { Deprecated = input.ReadBool(); break; } + case 272: { + idempotencyLevel_ = (global::Google.Protobuf.Reflection.MethodOptions.Types.IdempotencyLevel) input.ReadEnum(); + break; + } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -4736,6 +4800,30 @@ namespace Google.Protobuf.Reflection { } } + #region Nested types + /// <summary>Container for nested types declared in the MethodOptions message type.</summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static partial class Types { + /// <summary> + /// Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + /// or neither? HTTP based RPC implementation may choose GET verb for safe + /// methods, and PUT verb for idempotent methods instead of the default POST. + /// </summary> + internal enum IdempotencyLevel { + [pbr::OriginalName("IDEMPOTENCY_UNKNOWN")] IdempotencyUnknown = 0, + /// <summary> + /// implies idempotent + /// </summary> + [pbr::OriginalName("NO_SIDE_EFFECTS")] NoSideEffects = 1, + /// <summary> + /// idempotent, but may have side effects + /// </summary> + [pbr::OriginalName("IDEMPOTENT")] Idempotent = 2, + } + + } + #endregion + } /// <summary> diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index 234095e9..f72571d7 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -35,8 +35,9 @@ namespace Google.Protobuf.WellKnownTypes { "ChFyZXNwb25zZV90eXBlX3VybBgEIAEoCRIaChJyZXNwb25zZV9zdHJlYW1p", "bmcYBSABKAgSKAoHb3B0aW9ucxgGIAMoCzIXLmdvb2dsZS5wcm90b2J1Zi5P", "cHRpb24SJwoGc3ludGF4GAcgASgOMhcuZ29vZ2xlLnByb3RvYnVmLlN5bnRh", - "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCSAoTY29t", - "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAaICA0dQQqoCHkdvb2dsZS5Q", + "eCIjCgVNaXhpbhIMCgRuYW1lGAEgASgJEgwKBHJvb3QYAiABKAlCdQoTY29t", + "Lmdvb2dsZS5wcm90b2J1ZkIIQXBpUHJvdG9QAVorZ29vZ2xlLmdvbGFuZy5v", + "cmcvZ2VucHJvdG8vcHJvdG9idWYvYXBpO2FwaaICA0dQQqoCHkdvb2dsZS5Q", "cm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, }, diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index c73d6bd8..99a8011e 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -23,9 +23,11 @@ namespace Google.Protobuf.WellKnownTypes { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiBnb29nbGUvcHJvdG9idWYvZmllbGRfbWFzay5wcm90bxIPZ29vZ2xlLnBy", - "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUJOChNjb20uZ29v", - "Z2xlLnByb3RvYnVmQg5GaWVsZE1hc2tQcm90b1ABogIDR1BCqgIeR29vZ2xl", - "LlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); + "b3RvYnVmIhoKCUZpZWxkTWFzaxINCgVwYXRocxgBIAMoCUKJAQoTY29tLmdv", + "b2dsZS5wcm90b2J1ZkIORmllbGRNYXNrUHJvdG9QAVo5Z29vZ2xlLmdvbGFu", + "Zy5vcmcvZ2VucHJvdG8vcHJvdG9idWYvZmllbGRfbWFzaztmaWVsZF9tYXNr", + "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90", + "bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs index c3400327..c5713466 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs @@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes { string.Concat( "CiRnb29nbGUvcHJvdG9idWYvc291cmNlX2NvbnRleHQucHJvdG8SD2dvb2ds", "ZS5wcm90b2J1ZiIiCg1Tb3VyY2VDb250ZXh0EhEKCWZpbGVfbmFtZRgBIAEo", - "CUJSChNjb20uZ29vZ2xlLnByb3RvYnVmQhJTb3VyY2VDb250ZXh0UHJvdG9Q", - "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", - "dG8z")); + "CUKVAQoTY29tLmdvb2dsZS5wcm90b2J1ZkISU291cmNlQ29udGV4dFByb3Rv", + "UAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL3Byb3RvYnVmL3NvdXJj", + "ZV9jb250ZXh0O3NvdXJjZV9jb250ZXh0ogIDR1BCqgIeR29vZ2xlLlByb3Rv", + "YnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index e6363480..d80735f1 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -54,9 +54,10 @@ namespace Google.Protobuf.WellKnownTypes { "ASgFEigKB29wdGlvbnMYAyADKAsyFy5nb29nbGUucHJvdG9idWYuT3B0aW9u", "IjsKBk9wdGlvbhIMCgRuYW1lGAEgASgJEiMKBXZhbHVlGAIgASgLMhQuZ29v", "Z2xlLnByb3RvYnVmLkFueSouCgZTeW50YXgSEQoNU1lOVEFYX1BST1RPMhAA", - "EhEKDVNZTlRBWF9QUk9UTzMQAUJMChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", - "eXBlUHJvdG9QAfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25v", - "d25UeXBlc2IGcHJvdG8z")); + "EhEKDVNZTlRBWF9QUk9UTzMQAUJ9ChNjb20uZ29vZ2xlLnByb3RvYnVmQglU", + "eXBlUHJvdG9QAVovZ29vZ2xlLmdvbGFuZy5vcmcvZ2VucHJvdG8vcHJvdG9i", + "dWYvcHR5cGU7cHR5cGX4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2Vs", + "bEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.Syntax), }, new pbr::GeneratedClrTypeInfo[] { diff --git a/java/core/src/main/java/com/google/protobuf/AbstractParser.java b/java/core/src/main/java/com/google/protobuf/AbstractParser.java index 66b0ee3b..7ff73ba4 100644 --- a/java/core/src/main/java/com/google/protobuf/AbstractParser.java +++ b/java/core/src/main/java/com/google/protobuf/AbstractParser.java @@ -232,7 +232,7 @@ public abstract class AbstractParser<MessageType extends MessageLite> } size = CodedInputStream.readRawVarint32(firstByte, input); } catch (IOException e) { - throw new InvalidProtocolBufferException(e.getMessage()); + throw new InvalidProtocolBufferException(e); } InputStream limitedInput = new LimitedInputStream(input, size); return parsePartialFrom(limitedInput, extensionRegistry); 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 5b24976d..99a31209 100644 --- a/java/core/src/main/java/com/google/protobuf/ByteString.java +++ b/java/core/src/main/java/com/google/protobuf/ByteString.java @@ -51,14 +51,12 @@ import java.util.List; import java.util.NoSuchElementException; /** - * Immutable sequence of bytes. Substring is supported by sharing the reference - * to the immutable underlying bytes. Concatenation is likewise supported - * without copying (long strings) by building a tree of pieces in - * {@link RopeByteString}. - * <p> - * Like {@link String}, the contents of a {@link ByteString} can never be - * observed to change, not even in the presence of a data race or incorrect - * API usage in the client code. + * Immutable sequence of bytes. Substring is supported by sharing the reference to the immutable + * underlying bytes. Concatenation is likewise supported without copying (long strings) by building + * a tree of pieces in {@link RopeByteString}. + * + * <p>Like {@link String}, the contents of a {@link ByteString} can never be observed to change, not + * even in the presence of a data race or incorrect API usage in the client code. * * @author crazybob@google.com Bob Lee * @author kenton@google.com Kenton Varda @@ -565,7 +563,9 @@ public abstract class ByteString implements Iterable<Byte>, Serializable { // Create a balanced concatenation of the next "length" elements from the // iterable. private static ByteString balancedConcat(Iterator<ByteString> iterator, int length) { - assert length >= 1; + if (length < 1) { + throw new IllegalArgumentException(String.format("length (%s) must be >= 1", length)); + } ByteString result; if (length == 1) { result = iterator.next(); diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java index e461fa28..14169dc4 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java @@ -60,7 +60,8 @@ import java.util.List; public abstract class CodedInputStream { private static final int DEFAULT_BUFFER_SIZE = 4096; private static final int DEFAULT_RECURSION_LIMIT = 100; - private static final int DEFAULT_SIZE_LIMIT = 64 << 20; // 64MB + // Integer.MAX_VALUE == 0x7FFFFFF == INT_MAX from limits.h + private static final int DEFAULT_SIZE_LIMIT = Integer.MAX_VALUE; /** Visible for subclasses. See setRecursionLimit() */ int recursionDepth; @@ -2762,9 +2763,9 @@ public abstract class CodedInputStream { throw InvalidProtocolBufferException.negativeSize(); } - // Verify that the message size so far has not exceeded sizeLimit. + // Integer-overflow-conscious check that the message size so far has not exceeded sizeLimit. int currentMessageSize = totalBytesRetired + pos + size; - if (currentMessageSize > sizeLimit) { + if (currentMessageSize - sizeLimit > 0) { throw InvalidProtocolBufferException.sizeLimitExceeded(); } diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java index cab7118a..38346f15 100644 --- a/java/core/src/main/java/com/google/protobuf/Descriptors.java +++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java @@ -2123,7 +2123,7 @@ public final class Descriptors { // Can't happen, because addPackage() only fails when the name // conflicts with a non-package, but we have not yet added any // non-packages at this point. - assert false; + throw new AssertionError(e); } } } diff --git a/java/core/src/main/java/com/google/protobuf/DynamicMessage.java b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java index c54da67f..e6358c3b 100644 --- a/java/core/src/main/java/com/google/protobuf/DynamicMessage.java +++ b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java @@ -297,7 +297,7 @@ public final class DynamicMessage extends AbstractMessage { } catch (InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(builder.buildPartial()); } catch (IOException e) { - throw new InvalidProtocolBufferException(e.getMessage()) + throw new InvalidProtocolBufferException(e) .setUnfinishedMessage(builder.buildPartial()); } return builder.buildPartial(); diff --git a/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java index 1c2e7e6f..a22a74a0 100644 --- a/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java +++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java @@ -32,7 +32,6 @@ package com.google.protobuf; import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Descriptors.FieldDescriptor; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; diff --git a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java index 5e4d7739..f3d48d3a 100644 --- a/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java @@ -105,9 +105,9 @@ public class ExtensionRegistryLite { /** * Construct a new, empty instance. - * - * <p> - * This may be an {@code ExtensionRegistry} if the full (non-Lite) proto libraries are available. + * + * <p>This may be an {@code ExtensionRegistry} if the full (non-Lite) proto libraries are + * available. */ public static ExtensionRegistryLite newInstance() { return ExtensionRegistryFactory.create(); @@ -121,6 +121,7 @@ public class ExtensionRegistryLite { return ExtensionRegistryFactory.createEmpty(); } + /** Returns an unmodifiable view of the registry. */ public ExtensionRegistryLite getUnmodifiable() { return new ExtensionRegistryLite(this); 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 214971b1..f885b01e 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -39,7 +39,6 @@ import com.google.protobuf.Internal.IntList; import com.google.protobuf.Internal.LongList; import com.google.protobuf.Internal.ProtobufList; import com.google.protobuf.WireFormat.FieldType; - import java.io.IOException; import java.io.InputStream; import java.io.ObjectStreamException; @@ -479,7 +478,6 @@ public abstract class GeneratedMessageLite< CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) throws IOException { - int wireType = WireFormat.getTagWireType(tag); int fieldNumber = WireFormat.getTagFieldNumber(tag); // TODO(dweis): How much bytecode would be saved by not requiring the generated code to @@ -487,6 +485,17 @@ public abstract class GeneratedMessageLite< GeneratedExtension<MessageType, ?> extension = extensionRegistry.findLiteExtensionByNumber( defaultInstance, fieldNumber); + return parseExtension(input, extensionRegistry, extension, tag, fieldNumber); + } + + private boolean parseExtension( + CodedInputStream input, + ExtensionRegistryLite extensionRegistry, + GeneratedExtension<?, ?> extension, + int tag, + int fieldNumber) + throws IOException { + int wireType = WireFormat.getTagWireType(tag); boolean unknown = false; boolean packed = false; if (extension == null) { @@ -508,7 +517,7 @@ public abstract class GeneratedMessageLite< if (unknown) { // Unknown field or wrong wire type. Skip. return parseUnknownField(tag, input); } - + if (packed) { int length = input.readRawVarint32(); int limit = input.pushLimit(length); @@ -587,9 +596,147 @@ public abstract class GeneratedMessageLite< extension.singularToFieldSetType(value)); } } - return true; } + + /** + * Parse an unknown field or an extension. For use by generated code only. + * + * <p>For use by generated code only. + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected <MessageType extends MessageLite> boolean parseUnknownFieldAsMessageSet( + MessageType defaultInstance, + CodedInputStream input, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + + if (tag == WireFormat.MESSAGE_SET_ITEM_TAG) { + mergeMessageSetExtensionFromCodedStream(defaultInstance, input, extensionRegistry); + return true; + } + + // TODO(dweis): Do we really want to support non message set wire format in message sets? + // Full runtime does... So we do for now. + int wireType = WireFormat.getTagWireType(tag); + if (wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) { + return parseUnknownField(defaultInstance, input, extensionRegistry, tag); + } else { + // TODO(dweis): Should we throw on invalid input? Full runtime does not... + return input.skipField(tag); + } + } + + /** + * Merges the message set from the input stream; requires message set wire format. + * + * @param defaultInstance the default instance of the containing message we are parsing in + * @param input the stream to parse from + * @param extensionRegistry the registry to use when parsing + */ + private <MessageType extends MessageLite> void mergeMessageSetExtensionFromCodedStream( + MessageType defaultInstance, + CodedInputStream input, + ExtensionRegistryLite extensionRegistry) + throws IOException { + // The wire format for MessageSet is: + // message MessageSet { + // repeated group Item = 1 { + // required int32 typeId = 2; + // required bytes message = 3; + // } + // } + // "typeId" is the extension's field number. The extension can only be + // a message type, where "message" contains the encoded bytes of that + // message. + // + // In practice, we will probably never see a MessageSet item in which + // the message appears before the type ID, or where either field does not + // appear exactly once. However, in theory such cases are valid, so we + // should be prepared to accept them. + + int typeId = 0; + ByteString rawBytes = null; // If we encounter "message" before "typeId" + GeneratedExtension<?, ?> extension = null; + + // Read bytes from input, if we get it's type first then parse it eagerly, + // otherwise we store the raw bytes in a local variable. + while (true) { + final int tag = input.readTag(); + if (tag == 0) { + break; + } + + if (tag == WireFormat.MESSAGE_SET_TYPE_ID_TAG) { + typeId = input.readUInt32(); + if (typeId != 0) { + extension = extensionRegistry.findLiteExtensionByNumber(defaultInstance, typeId); + } + + } else if (tag == WireFormat.MESSAGE_SET_MESSAGE_TAG) { + if (typeId != 0) { + if (extension != null) { + // We already know the type, so we can parse directly from the + // input with no copying. Hooray! + eagerlyMergeMessageSetExtension(input, extension, extensionRegistry, typeId); + rawBytes = null; + continue; + } + } + // We haven't seen a type ID yet or we want parse message lazily. + rawBytes = input.readBytes(); + + } else { // Unknown tag. Skip it. + if (!input.skipField(tag)) { + break; // End of group + } + } + } + input.checkLastTagWas(WireFormat.MESSAGE_SET_ITEM_END_TAG); + + // Process the raw bytes. + if (rawBytes != null && typeId != 0) { // Zero is not a valid type ID. + if (extension != null) { // We known the type + mergeMessageSetExtensionFromBytes(rawBytes, extensionRegistry, extension); + } else { // We don't know how to parse this. Ignore it. + if (rawBytes != null) { + mergeLengthDelimitedField(typeId, rawBytes); + } + } + } + } + + private void eagerlyMergeMessageSetExtension( + CodedInputStream input, + GeneratedExtension<?, ?> extension, + ExtensionRegistryLite extensionRegistry, + int typeId) + throws IOException { + int fieldNumber = typeId; + int tag = WireFormat.makeTag(typeId, WireFormat.WIRETYPE_LENGTH_DELIMITED); + parseExtension(input, extensionRegistry, extension, tag, fieldNumber); + } + + private void mergeMessageSetExtensionFromBytes( + ByteString rawBytes, + ExtensionRegistryLite extensionRegistry, + GeneratedExtension<?, ?> extension) + throws IOException { + MessageLite.Builder subBuilder = null; + MessageLite existingValue = (MessageLite) extensions.getField(extension.descriptor); + if (existingValue != null) { + subBuilder = existingValue.toBuilder(); + } + if (subBuilder == null) { + subBuilder = extension.getMessageDefaultInstance().newBuilderForType(); + } + rawBytes.newCodedInput().readMessage(subBuilder, extensionRegistry); + MessageLite value = subBuilder.build(); + + extensions.setField(extension.descriptor, extension.singularToFieldSetType(value)); + } private void verifyExtensionContainingType( final GeneratedExtension<MessageType, ?> extension) { @@ -807,14 +954,6 @@ public abstract class GeneratedMessageLite< return instance.getExtension(extension, index); } - // This is implemented here only to work around an apparent bug in the - // Java compiler and/or build system. See bug #1898463. The mere presence - // of this dummy clone() implementation makes it go away. - @Override - public BuilderType clone() { - return super.clone(); - } - /** Set the value of an extension. */ public final <Type> BuilderType setExtension( final ExtensionLite<MessageType, Type> extension, diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java index 4cbbd296..2a5d8b50 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -36,6 +36,16 @@ import com.google.protobuf.Descriptors.EnumValueDescriptor; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.Descriptors.OneofDescriptor; +// In opensource protobuf, we have versioned this GeneratedMessageV3 class to GeneratedMessageV3V3 and +// in the future may have GeneratedMessageV3V4 etc. This allows us to change some aspects of this +// class without breaking binary compatibility with old generated code that still subclasses +// the old GeneratedMessageV3 class. To allow these different GeneratedMessageV3V? classes to +// interoperate (e.g., a GeneratedMessageV3V3 object has a message extension field whose class +// type is GeneratedMessageV3V4), these classes still share a common parent class AbstarctMessage +// and are using the same GeneratedMessage.GeneratedExtension class for extension definitions. +// Since this class becomes GeneratedMessageV3V? in opensource, we have to add an import here +// to be able to use GeneratedMessage.GeneratedExtension. The GeneratedExtension definition in +// this file is also excluded from opensource to avoid conflict. import com.google.protobuf.GeneratedMessage.GeneratedExtension; import java.io.IOException; @@ -1207,14 +1217,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage return super.clear(); } - // This is implemented here only to work around an apparent bug in the - // Java compiler and/or build system. See bug #1898463. The mere presence - // of this clone() implementation makes it go away. - @Override - public BuilderType clone() { - return super.clone(); - } - private void ensureExtensionsIsMutable() { if (extensions.isImmutable()) { extensions = extensions.clone(); @@ -1610,6 +1612,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage FieldDescriptor getDescriptor(); } + // ================================================================= /** Calls Class.getMethod and throws a RuntimeException if it fails. */ @@ -1705,11 +1708,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage initialized = false; } - private boolean isMapFieldEnabled(FieldDescriptor field) { - boolean result = true; - return result; - } - /** * Ensures the field accessors are initialized. This method is thread-safe. * @@ -1733,7 +1731,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage } if (field.isRepeated()) { if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { - if (field.isMapField() && isMapFieldEnabled(field)) { + if (field.isMapField()) { fields[i] = new MapFieldAccessor( field, camelCaseNames[i], messageClass, builderClass); } else { diff --git a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java index 2febaace..4b0ba0fd 100644 --- a/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java +++ b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java @@ -284,29 +284,8 @@ public class LazyFieldLite { return; } - // At this point we have two fully parsed messages. We can't merge directly from one to the - // other because only generated builder code contains methods to mergeFrom another parsed - // message. We have to serialize one instance and then merge the bytes into the other. This may - // drop extensions from one of the messages if one of the values had an extension set on it - // directly. - // - // To mitigate this we prefer serializing a message that has an extension registry, and - // therefore a chance that all extensions set on it are in that registry. - // - // NOTE: The check for other.extensionRegistry not being null must come first because at this - // point in time if other.extensionRegistry is not null then this.extensionRegistry will not be - // null either. - if (other.extensionRegistry != null) { - setValue(mergeValueAndBytes(this.value, other.toByteString(), other.extensionRegistry)); - return; - } else if (this.extensionRegistry != null) { - setValue(mergeValueAndBytes(other.value, this.toByteString(), this.extensionRegistry)); - return; - } else { - // All extensions from the other message will be dropped because we have no registry. - setValue(mergeValueAndBytes(this.value, other.toByteString(), EMPTY_REGISTRY)); - return; - } + // At this point we have two fully parsed messages. + setValue(this.value.toBuilder().mergeFrom(other.value).build()); } /** diff --git a/java/core/src/main/java/com/google/protobuf/MapEntry.java b/java/core/src/main/java/com/google/protobuf/MapEntry.java index 4f0351f4..179c3348 100644 --- a/java/core/src/main/java/com/google/protobuf/MapEntry.java +++ b/java/core/src/main/java/com/google/protobuf/MapEntry.java @@ -109,7 +109,7 @@ public final class MapEntry<K, V> extends AbstractMessage { } catch (InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(this); } catch (IOException e) { - throw new InvalidProtocolBufferException(e.getMessage()).setUnfinishedMessage(this); + throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this); } } diff --git a/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java index 43847651..23373ef4 100644 --- a/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java +++ b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java @@ -95,7 +95,7 @@ final class MessageLiteToString { // Try to reflectively get the value and toString() the field as if it were repeated. This // only works if the method names have not be proguarded out or renamed. Method listMethod = nameToNoArgMethod.get("get" + suffix); - if (listMethod != null) { + if (listMethod != null && listMethod.getReturnType().equals(List.class)) { printField( buffer, indent, @@ -115,7 +115,7 @@ final class MessageLiteToString { // Heuristic to skip bytes based accessors for string fields. continue; } - + String camelCase = suffix.substring(0, 1).toLowerCase() + suffix.substring(1); // Try to reflectively get the value and toString() the field as if it were optional. This diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java index 6d33d3a8..49b3504f 100644 --- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java @@ -1022,7 +1022,7 @@ public final class UnknownFieldSet implements MessageLite { } catch (InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(builder.buildPartial()); } catch (IOException e) { - throw new InvalidProtocolBufferException(e.getMessage()) + throw new InvalidProtocolBufferException(e) .setUnfinishedMessage(builder.buildPartial()); } return builder.buildPartial(); diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java index 9500f905..104f8007 100644 --- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java +++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java @@ -176,6 +176,41 @@ public final class UnknownFieldSetLite { } /** + * Serializes the set and writes it to {@code output} using {@code MessageSet} wire format. + * + * <p>For use by generated code only. + */ + public void writeAsMessageSetTo(CodedOutputStream output) throws IOException { + for (int i = 0; i < count; i++) { + int fieldNumber = WireFormat.getTagFieldNumber(tags[i]); + output.writeRawMessageSetExtension(fieldNumber, (ByteString) objects[i]); + } + } + + /** + * Get the number of bytes required to encode this field, including field + * number, using {@code MessageSet} wire format. + */ + public int getSerializedSizeAsMessageSet() { + int size = memoizedSerializedSize; + if (size != -1) { + return size; + } + + size = 0; + for (int i = 0; i < count; i++) { + int tag = tags[i]; + int fieldNumber = WireFormat.getTagFieldNumber(tag); + size += CodedOutputStream.computeRawMessageSetExtensionSize( + fieldNumber, (ByteString) objects[i]); + } + + memoizedSerializedSize = size; + + return size; + } + + /** * Get the number of bytes required to encode this set. * * <p>For use by generated code only. @@ -268,7 +303,8 @@ public final class UnknownFieldSetLite { } } - private void storeField(int tag, Object value) { + // Package private for unsafe experimental runtime. + void storeField(int tag, Object value) { ensureCapacity(); tags[count] = tag; diff --git a/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java index e2ab0df9..e440c7db 100644 --- a/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java +++ b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java @@ -30,8 +30,6 @@ package com.google.protobuf; -import static org.junit.Assert.assertArrayEquals; - import protobuf_unittest.UnittestProto.BoolMessage; import protobuf_unittest.UnittestProto.Int32Message; import protobuf_unittest.UnittestProto.Int64Message; @@ -445,6 +443,82 @@ public class CodedInputStreamTest extends TestCase { } } + /** + * Test we can do messages that are up to CodedInputStream#DEFAULT_SIZE_LIMIT + * in size (2G or Integer#MAX_SIZE). + * @throws IOException + */ + public void testParseMessagesCloseTo2G() throws IOException { + byte[] serializedMessage = getBigSerializedMessage(); + // How many of these big messages do we need to take us near our 2G limit? + int count = Integer.MAX_VALUE / serializedMessage.length; + // Now make an inputstream that will fake a near 2G message of messages + // returning our big serialized message 'count' times. + InputStream is = new RepeatingInputStream(serializedMessage, count); + // Parse should succeed! + TestAllTypes.parseFrom(is); + } + + /** + * Test there is an exception if a message exceeds + * CodedInputStream#DEFAULT_SIZE_LIMIT in size (2G or Integer#MAX_SIZE). + * @throws IOException + */ + public void testParseMessagesOver2G() throws IOException { + byte[] serializedMessage = getBigSerializedMessage(); + // How many of these big messages do we need to take us near our 2G limit? + int count = Integer.MAX_VALUE / serializedMessage.length; + // Now add one to take us over the limit + count++; + // Now make an inputstream that will fake a near 2G message of messages + // returning our big serialized message 'count' times. + InputStream is = new RepeatingInputStream(serializedMessage, count); + try { + TestAllTypes.parseFrom(is); + fail("Should have thrown an exception!"); + } catch (InvalidProtocolBufferException e) { + assertTrue(e.getMessage().contains("too large")); + } + } + + /* + * @return A serialized big message. + */ + private static byte[] getBigSerializedMessage() { + byte[] value = new byte[16 * 1024 * 1024]; + ByteString bsValue = ByteString.wrap(value); + return TestAllTypes.newBuilder().setOptionalBytes(bsValue).build().toByteArray(); + } + + /* + * An input stream that repeats a byte arrays' content a number of times. + * Simulates really large input without consuming loads of memory. Used above + * to test the parsing behavior when the input size exceeds 2G or close to it. + */ + private static class RepeatingInputStream extends InputStream { + private final byte[] serializedMessage; + private final int count; + private int index = 0; + private int offset = 0; + + RepeatingInputStream(byte[] serializedMessage, int count) { + this.serializedMessage = serializedMessage; + this.count = count; + } + + @Override + public int read() throws IOException { + if (this.offset == this.serializedMessage.length) { + this.index++; + this.offset = 0; + } + if (this.index == this.count) { + return -1; + } + return this.serializedMessage[offset++]; + } + } + private TestRecursiveMessage makeRecursiveMessage(int depth) { if (depth == 0) { return TestRecursiveMessage.newBuilder().setI(5).build(); diff --git a/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java index efdfdfbe..813fe6bc 100644 --- a/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java +++ b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java @@ -31,7 +31,6 @@ package com.google.protobuf; import static protobuf_unittest.UnittestProto.optionalInt32Extension; -import static protobuf_unittest.UnittestProto.optionalInt64Extension; import protobuf_unittest.UnittestProto.TestAllExtensions; import protobuf_unittest.UnittestProto.TestAllTypes; @@ -219,29 +218,6 @@ public class LazyFieldLiteTest extends TestCase { assertEquals(messageWithExtensions, field.getValue(TestAllExtensions.getDefaultInstance())); } - public void testMergeMightLoseExtensions() throws Exception { - // Test that we don't know about the extensions when parsing. - TestAllExtensions message1 = - TestAllExtensions.newBuilder().setExtension(optionalInt32Extension, 1).build(); - TestAllExtensions message2 = - TestAllExtensions.newBuilder().setExtension(optionalInt64Extension, 2L).build(); - - LazyFieldLite field = LazyFieldLite.fromValue(message1); - field.merge(LazyFieldLite.fromValue(message2)); - - // We lose the extensions from message 2 because we have to serialize it and then parse it - // again, using the empty registry this time. - TestAllExtensions value = - (TestAllExtensions) field.getValue(TestAllExtensions.getDefaultInstance()); - assertTrue(value.hasExtension(optionalInt32Extension)); - assertEquals(Integer.valueOf(1), value.getExtension(optionalInt32Extension)); - assertFalse(value.hasExtension(optionalInt64Extension)); - - // The field is still there, it is just unknown. - assertTrue(value.getUnknownFields() - .hasField(optionalInt64Extension.getDescriptor().getNumber())); - } - // Help methods. diff --git a/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java index c8ca9b6a..968ca206 100644 --- a/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java +++ b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java @@ -101,6 +101,19 @@ public class LazyMessageLiteTest extends TestCase { assertEquals(119, outer.getRepeatedInner(0).getNum()); assertEquals(122, outer.getRepeatedInner(1).getNum()); } + + public void testRepeatedMutability() throws Exception { + LazyMessageLite outer = LazyMessageLite.newBuilder() + .addRepeatedInner(LazyInnerMessageLite.newBuilder().setNum(119)) + .addRepeatedInner(LazyInnerMessageLite.newBuilder().setNum(122)) + .build(); + + outer = LazyMessageLite.parseFrom(outer.toByteArray()); + try { + outer.getRepeatedInnerList().set(1, null); + fail(); + } catch (UnsupportedOperationException expected) {} + } public void testAddAll() { ArrayList<LazyInnerMessageLite> inners = new ArrayList<LazyInnerMessageLite>(); diff --git a/java/core/src/test/java/com/google/protobuf/LiteTest.java b/java/core/src/test/java/com/google/protobuf/LiteTest.java index 254beba1..538432f7 100644 --- a/java/core/src/test/java/com/google/protobuf/LiteTest.java +++ b/java/core/src/test/java/com/google/protobuf/LiteTest.java @@ -45,6 +45,7 @@ import com.google.protobuf.UnittestLite.TestAllTypesLite.OneofFieldCase; import com.google.protobuf.UnittestLite.TestAllTypesLite.OptionalGroup; import com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup; import com.google.protobuf.UnittestLite.TestAllTypesLiteOrBuilder; +import com.google.protobuf.UnittestLite.TestHugeFieldNumbersLite; import com.google.protobuf.UnittestLite.TestNestedExtensionLite; import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar; import protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.BarPrime; @@ -1424,6 +1425,12 @@ public class LiteTest extends TestCase { assertToStringEquals("", TestAllTypesLite.getDefaultInstance()); } + public void testToStringScalarFieldsSuffixedWithList() throws Exception { + assertToStringEquals("deceptively_named_list: 7", TestAllTypesLite.newBuilder() + .setDeceptivelyNamedList(7) + .build()); + } + public void testToStringPrimitives() throws Exception { TestAllTypesLite proto = TestAllTypesLite.newBuilder() .setOptionalInt32(1) @@ -2235,6 +2242,25 @@ public class LiteTest extends TestCase { assertFalse(other.equals(mine)); } + public void testHugeFieldNumbers() throws InvalidProtocolBufferException { + TestHugeFieldNumbersLite message = + TestHugeFieldNumbersLite.newBuilder() + .setOptionalInt32(1) + .addRepeatedInt32(2) + .setOptionalEnum(ForeignEnumLite.FOREIGN_LITE_FOO) + .setOptionalString("xyz") + .setOptionalMessage(ForeignMessageLite.newBuilder().setC(3).build()) + .build(); + + TestHugeFieldNumbersLite parsedMessage = + TestHugeFieldNumbersLite.parseFrom(message.toByteArray()); + assertEquals(1, parsedMessage.getOptionalInt32()); + assertEquals(2, parsedMessage.getRepeatedInt32(0)); + assertEquals(ForeignEnumLite.FOREIGN_LITE_FOO, parsedMessage.getOptionalEnum()); + assertEquals("xyz", parsedMessage.getOptionalString()); + assertEquals(3, parsedMessage.getOptionalMessage().getC()); + } + private void assertEqualsAndHashCodeAreFalse(Object o1, Object o2) { assertFalse(o1.equals(o2)); assertFalse(o1.hashCode() == o2.hashCode()); diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java index 8b64fa27..0a14f584 100644 --- a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java +++ b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java @@ -501,7 +501,6 @@ public final class MapForProto2LiteTest extends TestCase { assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue()); } - public void testIterationOrder() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); setMapValues(builder); diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java index 76bd7bd9..cfe4c453 100644 --- a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java +++ b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java @@ -58,26 +58,26 @@ public class MapForProto2Test extends TestCase { builder.getMutableInt32ToInt32Field().put(1, 11); builder.getMutableInt32ToInt32Field().put(2, 22); builder.getMutableInt32ToInt32Field().put(3, 33); - + // builder.getMutableInt32ToStringField().put(1, "11"); builder.getMutableInt32ToStringField().put(2, "22"); builder.getMutableInt32ToStringField().put(3, "33"); - + // builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11")); builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22")); builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33")); - + // builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO); builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR); builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ); - + // builder.getMutableInt32ToMessageField().put( 1, MessageValue.newBuilder().setValue(11).build()); builder.getMutableInt32ToMessageField().put( 2, MessageValue.newBuilder().setValue(22).build()); builder.getMutableInt32ToMessageField().put( 3, MessageValue.newBuilder().setValue(33).build()); - + // builder.getMutableStringToInt32Field().put("1", 11); builder.getMutableStringToInt32Field().put("2", 22); builder.getMutableStringToInt32Field().put("3", 33); @@ -120,6 +120,7 @@ public class MapForProto2Test extends TestCase { setMapValuesUsingAccessors(usingAccessorsBuilder); TestMap usingAccessors = usingAccessorsBuilder.build(); assertMapValuesSet(usingAccessors); + assertEquals(usingAccessors, usingMutableMap); } @@ -169,25 +170,25 @@ public class MapForProto2Test extends TestCase { builder.getMutableInt32ToInt32Field().put(1, 111); builder.getMutableInt32ToInt32Field().remove(2); builder.getMutableInt32ToInt32Field().put(4, 44); - + // builder.getMutableInt32ToStringField().put(1, "111"); builder.getMutableInt32ToStringField().remove(2); builder.getMutableInt32ToStringField().put(4, "44"); - + // builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111")); builder.getMutableInt32ToBytesField().remove(2); builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44")); - + // builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR); builder.getMutableInt32ToEnumField().remove(2); builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX); - + // builder.getMutableInt32ToMessageField().put( 1, MessageValue.newBuilder().setValue(111).build()); builder.getMutableInt32ToMessageField().remove(2); builder.getMutableInt32ToMessageField().put( 4, MessageValue.newBuilder().setValue(44).build()); - + // builder.getMutableStringToInt32Field().put("1", 111); builder.getMutableStringToInt32Field().remove("2"); builder.getMutableStringToInt32Field().put("4", 44); @@ -230,8 +231,9 @@ public class MapForProto2Test extends TestCase { setMapValuesUsingAccessors(usingAccessorsBuilder); TestMap usingAccessors = usingAccessorsBuilder.build(); assertMapValuesSet(usingAccessors); - assertEquals(usingAccessors, usingMutableMap); + assertEquals(usingAccessors, usingMutableMap); + // usingMutableMapBuilder = usingMutableMap.toBuilder(); updateMapValuesUsingMutableMap(usingMutableMapBuilder); usingMutableMap = usingMutableMapBuilder.build(); @@ -335,7 +337,7 @@ public class MapForProto2Test extends TestCase { assertEquals(newMap(1, 2), builder.getInt32ToInt32Field()); builder.getMutableInt32ToInt32Field().put(2, 3); assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field()); - + // Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField(); enumMap.put(1, TestMap.EnumValue.BAR); assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField()); @@ -350,7 +352,7 @@ public class MapForProto2Test extends TestCase { assertEquals( newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO), builder.getInt32ToEnumField()); - + // Map<Integer, String> stringMap = builder.getMutableInt32ToStringField(); stringMap.put(1, "1"); assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField()); @@ -365,7 +367,7 @@ public class MapForProto2Test extends TestCase { assertEquals( newMap(1, "1", 2, "2"), builder.getInt32ToStringField()); - + // Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField(); messageMap.put(1, TestMap.MessageValue.getDefaultInstance()); assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()), @@ -384,7 +386,7 @@ public class MapForProto2Test extends TestCase { 2, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageField()); } - + // public void testMutableMapLifecycle_collections() { TestMap.Builder builder = TestMap.newBuilder(); Map<Integer, Integer> intMap = builder.getMutableInt32ToInt32Field(); @@ -431,18 +433,19 @@ public class MapForProto2Test extends TestCase { assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field()); } + public void testGettersAndSetters() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); TestMap message = builder.build(); assertMapValuesCleared(message); builder = message.toBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); message = builder.build(); assertMapValuesSet(message); builder = message.toBuilder(); - updateMapValuesUsingMutableMap(builder); + updateMapValuesUsingAccessors(builder); message = builder.build(); assertMapValuesUpdated(message); @@ -455,7 +458,7 @@ public class MapForProto2Test extends TestCase { public void testPutAll() throws Exception { TestMap.Builder sourceBuilder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(sourceBuilder); + setMapValuesUsingAccessors(sourceBuilder); TestMap source = sourceBuilder.build(); assertMapValuesSet(source); @@ -507,14 +510,14 @@ public class MapForProto2Test extends TestCase { public void testSerializeAndParse() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); assertEquals(message.getSerializedSize(), message.toByteString().size()); message = TestMap.parser().parseFrom(message.toByteString()); assertMapValuesSet(message); builder = message.toBuilder(); - updateMapValuesUsingMutableMap(builder); + updateMapValuesUsingAccessors(builder); message = builder.build(); assertEquals(message.getSerializedSize(), message.toByteString().size()); message = TestMap.parser().parseFrom(message.toByteString()); @@ -579,7 +582,7 @@ public class MapForProto2Test extends TestCase { public void testMergeFrom() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); TestMap.Builder other = TestMap.newBuilder(); @@ -594,22 +597,22 @@ public class MapForProto2Test extends TestCase { // We can't control the order of elements in a HashMap. The best we can do // here is to add elements in different order. TestMap.Builder b1 = TestMap.newBuilder(); - b1.getMutableInt32ToInt32Field().put(1, 2); - b1.getMutableInt32ToInt32Field().put(3, 4); - b1.getMutableInt32ToInt32Field().put(5, 6); + b1.putInt32ToInt32Field(1, 2); + b1.putInt32ToInt32Field(3, 4); + b1.putInt32ToInt32Field(5, 6); TestMap m1 = b1.build(); TestMap.Builder b2 = TestMap.newBuilder(); - b2.getMutableInt32ToInt32Field().put(5, 6); - b2.getMutableInt32ToInt32Field().put(1, 2); - b2.getMutableInt32ToInt32Field().put(3, 4); + b2.putInt32ToInt32Field(5, 6); + b2.putInt32ToInt32Field(1, 2); + b2.putInt32ToInt32Field(3, 4); TestMap m2 = b2.build(); assertEquals(m1, m2); assertEquals(m1.hashCode(), m2.hashCode()); // Make sure we did compare map fields. - b2.getMutableInt32ToInt32Field().put(1, 0); + b2.putInt32ToInt32Field(1, 0); m2 = b2.build(); assertFalse(m1.equals(m2)); // Don't check m1.hashCode() != m2.hashCode() because it's not guaranteed @@ -684,13 +687,11 @@ public class MapForProto2Test extends TestCase { public void testReflectionApi() throws Exception { // In reflection API, map fields are just repeated message fields. - TestMap.Builder builder = TestMap.newBuilder(); - builder.getMutableInt32ToInt32Field().put(1, 2); - builder.getMutableInt32ToInt32Field().put(3, 4); - builder.getMutableInt32ToMessageField().put( - 11, MessageValue.newBuilder().setValue(22).build()); - builder.getMutableInt32ToMessageField().put( - 33, MessageValue.newBuilder().setValue(44).build()); + TestMap.Builder builder = TestMap.newBuilder() + .putInt32ToInt32Field(1, 2) + .putInt32ToInt32Field(3, 4) + .putInt32ToMessageField(11, MessageValue.newBuilder().setValue(22).build()) + .putInt32ToMessageField(33, MessageValue.newBuilder().setValue(44).build()); TestMap message = builder.build(); // Test getField(), getRepeatedFieldCount(), getRepeatedField(). @@ -760,7 +761,7 @@ public class MapForProto2Test extends TestCase { public void testTextFormat() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); String textData = TextFormat.printToString(message); @@ -774,7 +775,7 @@ public class MapForProto2Test extends TestCase { public void testDynamicMessage() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); Message dynamicDefaultInstance = @@ -819,10 +820,9 @@ public class MapForProto2Test extends TestCase { } public void testUnknownEnumValues() throws Exception { - TestUnknownEnumValue.Builder builder = - TestUnknownEnumValue.newBuilder(); - builder.getMutableInt32ToInt32Field().put(1, 1); - builder.getMutableInt32ToInt32Field().put(2, 54321); + TestUnknownEnumValue.Builder builder = TestUnknownEnumValue.newBuilder() + .putInt32ToInt32Field(1, 1) + .putInt32ToInt32Field(2, 54321); ByteString data = builder.build().toByteString(); TestMap message = TestMap.parseFrom(data); @@ -841,26 +841,21 @@ public class MapForProto2Test extends TestCase { assertEquals(54321, messageWithUnknownEnums.getInt32ToInt32Field().get(2).intValue()); } - public void testRequiredMessage() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - builder.getMutableRequiredMessageMap().put(0, - MessageWithRequiredFields.newBuilder().buildPartial()); + builder.putRequiredMessageMap(0, MessageWithRequiredFields.newBuilder().buildPartial()); TestMap message = builder.buildPartial(); assertFalse(message.isInitialized()); - builder.getMutableRequiredMessageMap().put(0, - MessageWithRequiredFields.newBuilder().setValue(1).build()); + builder.putRequiredMessageMap(0, MessageWithRequiredFields.newBuilder().setValue(1).build()); message = builder.build(); assertTrue(message.isInitialized()); } public void testRecursiveMap() throws Exception { TestRecursiveMap.Builder builder = TestRecursiveMap.newBuilder(); - builder.getMutableRecursiveMapField().put( - 1, TestRecursiveMap.newBuilder().setValue(2).build()); - builder.getMutableRecursiveMapField().put( - 3, TestRecursiveMap.newBuilder().setValue(4).build()); + builder.putRecursiveMapField(1, TestRecursiveMap.newBuilder().setValue(2).build()); + builder.putRecursiveMapField(3, TestRecursiveMap.newBuilder().setValue(4).build()); ByteString data = builder.build().toByteString(); TestRecursiveMap message = TestRecursiveMap.parseFrom(data); @@ -870,7 +865,7 @@ public class MapForProto2Test extends TestCase { public void testIterationOrder() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); assertEquals(Arrays.asList("1", "2", "3"), @@ -879,7 +874,7 @@ public class MapForProto2Test extends TestCase { public void testContains() { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertMapContainsSetValues(builder); assertMapContainsSetValues(builder.build()); } @@ -920,7 +915,7 @@ public class MapForProto2Test extends TestCase { TestMap.Builder builder = TestMap.newBuilder(); assertMapCounts(0, builder); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertMapCounts(3, builder); TestMap message = builder.build(); @@ -1091,7 +1086,7 @@ public class MapForProto2Test extends TestCase { public void testRemove() { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertEquals(11, builder.getInt32ToInt32FieldOrThrow(1)); for (int times = 0; times < 2; times++) { builder.removeInt32ToInt32Field(1); @@ -1137,7 +1132,7 @@ public class MapForProto2Test extends TestCase { map_test.Message1.Builder builder = map_test.Message1.newBuilder(); - builder.getMutableMapField().put("key", true); + builder.putMapField("key", true); map_test.Message1 message = builder.build(); Message mapEntry = (Message) message.getRepeatedField( message.getDescriptorForType().findFieldByName("map_field"), 0); diff --git a/java/core/src/test/java/com/google/protobuf/MapTest.java b/java/core/src/test/java/com/google/protobuf/MapTest.java index 035a8335..81e951cc 100644 --- a/java/core/src/test/java/com/google/protobuf/MapTest.java +++ b/java/core/src/test/java/com/google/protobuf/MapTest.java @@ -60,26 +60,26 @@ public class MapTest extends TestCase { builder.getMutableInt32ToInt32Field().put(1, 11); builder.getMutableInt32ToInt32Field().put(2, 22); builder.getMutableInt32ToInt32Field().put(3, 33); - + // builder.getMutableInt32ToStringField().put(1, "11"); builder.getMutableInt32ToStringField().put(2, "22"); builder.getMutableInt32ToStringField().put(3, "33"); - + // builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("11")); builder.getMutableInt32ToBytesField().put(2, TestUtil.toBytes("22")); builder.getMutableInt32ToBytesField().put(3, TestUtil.toBytes("33")); - + // builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.FOO); builder.getMutableInt32ToEnumField().put(2, TestMap.EnumValue.BAR); builder.getMutableInt32ToEnumField().put(3, TestMap.EnumValue.BAZ); - + // builder.getMutableInt32ToMessageField().put( 1, MessageValue.newBuilder().setValue(11).build()); builder.getMutableInt32ToMessageField().put( 2, MessageValue.newBuilder().setValue(22).build()); builder.getMutableInt32ToMessageField().put( 3, MessageValue.newBuilder().setValue(33).build()); - + // builder.getMutableStringToInt32Field().put("1", 11); builder.getMutableStringToInt32Field().put("2", 22); builder.getMutableStringToInt32Field().put("3", 33); @@ -122,6 +122,7 @@ public class MapTest extends TestCase { setMapValuesUsingAccessors(usingAccessorsBuilder); TestMap usingAccessors = usingAccessorsBuilder.build(); assertMapValuesSet(usingAccessors); + assertEquals(usingAccessors, usingMutableMap); } @@ -171,25 +172,25 @@ public class MapTest extends TestCase { builder.getMutableInt32ToInt32Field().put(1, 111); builder.getMutableInt32ToInt32Field().remove(2); builder.getMutableInt32ToInt32Field().put(4, 44); - + // builder.getMutableInt32ToStringField().put(1, "111"); builder.getMutableInt32ToStringField().remove(2); builder.getMutableInt32ToStringField().put(4, "44"); - + // builder.getMutableInt32ToBytesField().put(1, TestUtil.toBytes("111")); builder.getMutableInt32ToBytesField().remove(2); builder.getMutableInt32ToBytesField().put(4, TestUtil.toBytes("44")); - + // builder.getMutableInt32ToEnumField().put(1, TestMap.EnumValue.BAR); builder.getMutableInt32ToEnumField().remove(2); builder.getMutableInt32ToEnumField().put(4, TestMap.EnumValue.QUX); - + // builder.getMutableInt32ToMessageField().put( 1, MessageValue.newBuilder().setValue(111).build()); builder.getMutableInt32ToMessageField().remove(2); builder.getMutableInt32ToMessageField().put( 4, MessageValue.newBuilder().setValue(44).build()); - + // builder.getMutableStringToInt32Field().put("1", 111); builder.getMutableStringToInt32Field().remove("2"); builder.getMutableStringToInt32Field().put("4", 44); @@ -232,8 +233,9 @@ public class MapTest extends TestCase { setMapValuesUsingAccessors(usingAccessorsBuilder); TestMap usingAccessors = usingAccessorsBuilder.build(); assertMapValuesSet(usingAccessors); - assertEquals(usingAccessors, usingMutableMap); + assertEquals(usingAccessors, usingMutableMap); + // usingMutableMapBuilder = usingMutableMap.toBuilder(); updateMapValuesUsingMutableMap(usingMutableMapBuilder); usingMutableMap = usingMutableMapBuilder.build(); @@ -337,7 +339,7 @@ public class MapTest extends TestCase { assertEquals(newMap(1, 2), builder.getInt32ToInt32Field()); builder.getMutableInt32ToInt32Field().put(2, 3); assertEquals(newMap(1, 2, 2, 3), builder.getInt32ToInt32Field()); - + // Map<Integer, TestMap.EnumValue> enumMap = builder.getMutableInt32ToEnumField(); enumMap.put(1, TestMap.EnumValue.BAR); assertEquals(newMap(1, TestMap.EnumValue.BAR), builder.build().getInt32ToEnumField()); @@ -352,7 +354,7 @@ public class MapTest extends TestCase { assertEquals( newMap(1, TestMap.EnumValue.BAR, 2, TestMap.EnumValue.FOO), builder.getInt32ToEnumField()); - + // Map<Integer, String> stringMap = builder.getMutableInt32ToStringField(); stringMap.put(1, "1"); assertEquals(newMap(1, "1"), builder.build().getInt32ToStringField()); @@ -363,11 +365,11 @@ public class MapTest extends TestCase { // expected } assertEquals(newMap(1, "1"), builder.getInt32ToStringField()); - builder.getMutableInt32ToStringField().put(2, "2"); + builder.putInt32ToStringField(2, "2"); assertEquals( newMap(1, "1", 2, "2"), builder.getInt32ToStringField()); - + // Map<Integer, TestMap.MessageValue> messageMap = builder.getMutableInt32ToMessageField(); messageMap.put(1, TestMap.MessageValue.getDefaultInstance()); assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()), @@ -380,13 +382,13 @@ public class MapTest extends TestCase { } assertEquals(newMap(1, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageField()); - builder.getMutableInt32ToMessageField().put(2, TestMap.MessageValue.getDefaultInstance()); + builder.putInt32ToMessageField(2, TestMap.MessageValue.getDefaultInstance()); assertEquals( newMap(1, TestMap.MessageValue.getDefaultInstance(), 2, TestMap.MessageValue.getDefaultInstance()), builder.getInt32ToMessageField()); } - + // public void testMutableMapLifecycle_collections() { TestMap.Builder builder = TestMap.newBuilder(); Map<Integer, Integer> intMap = builder.getMutableInt32ToInt32Field(); @@ -433,18 +435,19 @@ public class MapTest extends TestCase { assertEquals(newMap(1, 2), builder.build().getInt32ToInt32Field()); } + public void testGettersAndSetters() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); TestMap message = builder.build(); assertMapValuesCleared(message); builder = message.toBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); message = builder.build(); assertMapValuesSet(message); builder = message.toBuilder(); - updateMapValuesUsingMutableMap(builder); + updateMapValuesUsingAccessors(builder); message = builder.build(); assertMapValuesUpdated(message); @@ -457,7 +460,7 @@ public class MapTest extends TestCase { public void testPutAll() throws Exception { TestMap.Builder sourceBuilder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(sourceBuilder); + setMapValuesUsingAccessors(sourceBuilder); TestMap source = sourceBuilder.build(); assertMapValuesSet(source); @@ -467,15 +470,16 @@ public class MapTest extends TestCase { } public void testPutAllForUnknownEnumValues() throws Exception { - TestMap.Builder sourceBuilder = TestMap.newBuilder(); - sourceBuilder.getMutableInt32ToEnumFieldValue().put(0, 0); - sourceBuilder.getMutableInt32ToEnumFieldValue().put(1, 1); - sourceBuilder.getMutableInt32ToEnumFieldValue().put(2, 1000); // unknown value. - TestMap source = sourceBuilder.build(); + TestMap source = TestMap.newBuilder() + .putAllInt32ToEnumFieldValue(newMap( + 0, 0, + 1, 1, + 2, 1000)) // unknown value. + .build(); - TestMap.Builder destinationBuilder = TestMap.newBuilder(); - destinationBuilder.putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue()); - TestMap destination = destinationBuilder.build(); + TestMap destination = TestMap.newBuilder() + .putAllInt32ToEnumFieldValue(source.getInt32ToEnumFieldValue()) + .build(); assertEquals(0, destination.getInt32ToEnumFieldValue().get(0).intValue()); assertEquals(1, destination.getInt32ToEnumFieldValue().get(1).intValue()); @@ -542,14 +546,14 @@ public class MapTest extends TestCase { public void testSerializeAndParse() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); assertEquals(message.getSerializedSize(), message.toByteString().size()); message = TestMap.parser().parseFrom(message.toByteString()); assertMapValuesSet(message); builder = message.toBuilder(); - updateMapValuesUsingMutableMap(builder); + updateMapValuesUsingAccessors(builder); message = builder.build(); assertEquals(message.getSerializedSize(), message.toByteString().size()); message = TestMap.parser().parseFrom(message.toByteString()); @@ -614,7 +618,7 @@ public class MapTest extends TestCase { public void testMergeFrom() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); TestMap.Builder other = TestMap.newBuilder(); @@ -628,23 +632,23 @@ public class MapTest extends TestCase { // We can't control the order of elements in a HashMap. The best we can do // here is to add elements in different order. - TestMap.Builder b1 = TestMap.newBuilder(); - b1.getMutableInt32ToInt32Field().put(1, 2); - b1.getMutableInt32ToInt32Field().put(3, 4); - b1.getMutableInt32ToInt32Field().put(5, 6); + TestMap.Builder b1 = TestMap.newBuilder() + .putInt32ToInt32Field(1, 2) + .putInt32ToInt32Field(3, 4) + .putInt32ToInt32Field(5, 6); TestMap m1 = b1.build(); - TestMap.Builder b2 = TestMap.newBuilder(); - b2.getMutableInt32ToInt32Field().put(5, 6); - b2.getMutableInt32ToInt32Field().put(1, 2); - b2.getMutableInt32ToInt32Field().put(3, 4); + TestMap.Builder b2 = TestMap.newBuilder() + .putInt32ToInt32Field(5, 6) + .putInt32ToInt32Field(1, 2) + .putInt32ToInt32Field(3, 4); TestMap m2 = b2.build(); assertEquals(m1, m2); assertEquals(m1.hashCode(), m2.hashCode()); // Make sure we did compare map fields. - b2.getMutableInt32ToInt32Field().put(1, 0); + b2.putInt32ToInt32Field(1, 0); m2 = b2.build(); assertFalse(m1.equals(m2)); // Don't check m1.hashCode() != m2.hashCode() because it's not guaranteed @@ -652,7 +656,7 @@ public class MapTest extends TestCase { // Regression test for b/18549190: if a map is a subset of the other map, // equals() should return false. - b2.getMutableInt32ToInt32Field().remove(1); + b2.removeInt32ToInt32Field(1); m2 = b2.build(); assertFalse(m1.equals(m2)); assertFalse(m2.equals(m1)); @@ -661,20 +665,19 @@ public class MapTest extends TestCase { public void testNestedBuilderOnChangeEventPropagation() { TestOnChangeEventPropagation.Builder parent = TestOnChangeEventPropagation.newBuilder(); - parent.getOptionalMessageBuilder().getMutableInt32ToInt32Field().put(1, 2); + parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 2); TestOnChangeEventPropagation message = parent.build(); assertEquals(2, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue()); // Make a change using nested builder. - parent.getOptionalMessageBuilder().getMutableInt32ToInt32Field().put(1, 3); + parent.getOptionalMessageBuilder().putInt32ToInt32Field(1, 3); // Should be able to observe the change. message = parent.build(); assertEquals(3, message.getOptionalMessage().getInt32ToInt32Field().get(1).intValue()); // Make another change using mergeFrom() - TestMap.Builder other = TestMap.newBuilder(); - other.getMutableInt32ToInt32Field().put(1, 4); + TestMap.Builder other = TestMap.newBuilder().putInt32ToInt32Field(1, 4); parent.getOptionalMessageBuilder().mergeFrom(other.build()); // Should be able to observe the change. @@ -697,8 +700,7 @@ public class MapTest extends TestCase { TestMap.Builder testMapBuilder = parentBuilder.getOptionalMessageBuilder(); // Create a map entry message. - TestMap.Builder entryBuilder = TestMap.newBuilder(); - entryBuilder.getMutableInt32ToInt32Field().put(1, 1); + TestMap.Builder entryBuilder = TestMap.newBuilder().putInt32ToInt32Field(1, 1); // Put the entry into the nested builder. testMapBuilder.addRepeatedField( @@ -709,7 +711,7 @@ public class MapTest extends TestCase { assertEquals(1, message.getOptionalMessage().getInt32ToInt32Field().size()); // Change the entry value. - entryBuilder.getMutableInt32ToInt32Field().put(1, 4); + entryBuilder.putInt32ToInt32Field(1, 4); testMapBuilder = parentBuilder.getOptionalMessageBuilder(); testMapBuilder.setRepeatedField( intMapField, 0, entryBuilder.getRepeatedField(intMapField, 0)); @@ -796,13 +798,11 @@ public class MapTest extends TestCase { public void testReflectionApi() throws Exception { // In reflection API, map fields are just repeated message fields. - TestMap.Builder builder = TestMap.newBuilder(); - builder.getMutableInt32ToInt32Field().put(1, 2); - builder.getMutableInt32ToInt32Field().put(3, 4); - builder.getMutableInt32ToMessageField().put( - 11, MessageValue.newBuilder().setValue(22).build()); - builder.getMutableInt32ToMessageField().put( - 33, MessageValue.newBuilder().setValue(44).build()); + TestMap.Builder builder = TestMap.newBuilder() + .putInt32ToInt32Field(1, 2) + .putInt32ToInt32Field(3, 4) + .putInt32ToMessageField(11, MessageValue.newBuilder().setValue(22).build()) + .putInt32ToMessageField(33, MessageValue.newBuilder().setValue(44).build()); TestMap message = builder.build(); // Test getField(), getRepeatedFieldCount(), getRepeatedField(). @@ -872,7 +872,7 @@ public class MapTest extends TestCase { public void testTextFormat() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); String textData = TextFormat.printToString(message); @@ -886,7 +886,7 @@ public class MapTest extends TestCase { public void testDynamicMessage() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); Message dynamicDefaultInstance = @@ -931,10 +931,11 @@ public class MapTest extends TestCase { } public void testUnknownEnumValues() throws Exception { - TestMap.Builder builder = TestMap.newBuilder(); - builder.getMutableInt32ToEnumFieldValue().put(0, 0); - builder.getMutableInt32ToEnumFieldValue().put(1, 1); - builder.getMutableInt32ToEnumFieldValue().put(2, 1000); // unknown value. + TestMap.Builder builder = TestMap.newBuilder() + .putAllInt32ToEnumFieldValue(newMap( + 0, 0, + 1, 1, + 2, 1000)); // unknown value. TestMap message = builder.build(); assertEquals(TestMap.EnumValue.FOO, @@ -957,7 +958,7 @@ public class MapTest extends TestCase { assertEquals(1000, builder.getInt32ToEnumFieldValue().get(2).intValue()); // hashCode()/equals() should take unknown enum values into account. - builder.getMutableInt32ToEnumFieldValue().put(2, 1001); + builder.putAllInt32ToEnumFieldValue(newMap(2, 1001)); TestMap message2 = builder.build(); assertFalse(message.hashCode() == message2.hashCode()); assertFalse(message.equals(message2)); @@ -971,15 +972,13 @@ public class MapTest extends TestCase { EnumDescriptor enumDescriptor = TestMap.EnumValue.getDescriptor(); FieldDescriptor field = descriptor.findFieldByName("int32_to_enum_field"); - Map<Integer, Integer> data = new HashMap<Integer, Integer>(); - data.put(0, 0); - data.put(1, 1); - data.put(2, 1000); // unknown value. + Map<Integer, Integer> data = newMap( + 0, 0, + 1, 1, + 2, 1000); // unknown value - TestMap.Builder builder = TestMap.newBuilder(); - for (Map.Entry<Integer, Integer> entry : data.entrySet()) { - builder.getMutableInt32ToEnumFieldValue().put(entry.getKey(), entry.getValue()); - } + TestMap.Builder builder = TestMap.newBuilder() + .putAllInt32ToEnumFieldValue(data); // Try to read unknown enum values using reflection API. for (int i = 0; i < builder.getRepeatedFieldCount(field); i++) { @@ -1003,7 +1002,7 @@ public class MapTest extends TestCase { public void testIterationOrder() throws Exception { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); assertEquals(Arrays.asList("1", "2", "3"), @@ -1012,7 +1011,7 @@ public class MapTest extends TestCase { public void testGetMap() { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); TestMap message = builder.build(); assertEquals( message.getStringToInt32Field(), @@ -1033,7 +1032,7 @@ public class MapTest extends TestCase { public void testContains() { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertMapContainsSetValues(builder); assertMapContainsSetValues(builder.build()); } @@ -1074,7 +1073,7 @@ public class MapTest extends TestCase { TestMap.Builder builder = TestMap.newBuilder(); assertMapCounts(0, builder); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertMapCounts(3, builder); TestMap message = builder.build(); @@ -1269,7 +1268,7 @@ public class MapTest extends TestCase { public void testRemove() { TestMap.Builder builder = TestMap.newBuilder(); - setMapValuesUsingMutableMap(builder); + setMapValuesUsingAccessors(builder); assertEquals(11, builder.getInt32ToInt32FieldOrThrow(1)); for (int times = 0; times < 2; times++) { builder.removeInt32ToInt32Field(1); @@ -1485,4 +1484,12 @@ public class MapTest extends TestCase { map.put(key2, value2); return map; } + + private static <K, V> Map<K, V> newMap(K key1, V value1, K key2, V value2, K key3, V value3) { + Map<K, V> map = new HashMap<K, V>(); + map.put(key1, value1); + map.put(key2, value2); + map.put(key3, value3); + return map; + } } diff --git a/java/core/src/test/java/com/google/protobuf/ParserTest.java b/java/core/src/test/java/com/google/protobuf/ParserTest.java index 7086912b..8c2e4c26 100644 --- a/java/core/src/test/java/com/google/protobuf/ParserTest.java +++ b/java/core/src/test/java/com/google/protobuf/ParserTest.java @@ -46,6 +46,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InterruptedIOException; import junit.framework.TestCase; /** @@ -372,4 +373,43 @@ public class ParserTest extends TestCase { assertEquals(3, parsingMerge.getExtensionCount( TestParsingMergeLite.repeatedExt)); } + + public void testParseDelimitedFrom_firstByteInterrupted_preservesCause() { + try { + TestUtil.getAllSet().parseDelimitedFrom( + new InputStream() { + @Override + public int read() throws IOException { + throw new InterruptedIOException(); + } + }); + fail("Expected InterruptedIOException"); + } catch (Exception e) { + assertEquals(InterruptedIOException.class, e.getClass()); + } + } + + public void testParseDelimitedFrom_secondByteInterrupted_preservesCause() { + try { + TestUtil.getAllSet().parseDelimitedFrom( + new InputStream() { + private int i; + + @Override + public int read() throws IOException { + switch (i++) { + case 0: + return 1; + case 1: + throw new InterruptedIOException(); + default: + throw new AssertionError(); + } + } + }); + fail("Expected InterruptedIOException"); + } catch (Exception e) { + assertEquals(InterruptedIOException.class, e.getClass()); + } + } } diff --git a/java/util/src/main/java/com/google/protobuf/util/Durations.java b/java/util/src/main/java/com/google/protobuf/util/Durations.java index 9333168d..46b21828 100644 --- a/java/util/src/main/java/com/google/protobuf/util/Durations.java +++ b/java/util/src/main/java/com/google/protobuf/util/Durations.java @@ -42,7 +42,6 @@ import static com.google.protobuf.util.Timestamps.NANOS_PER_MICROSECOND; import static com.google.protobuf.util.Timestamps.NANOS_PER_MILLISECOND; import static com.google.protobuf.util.Timestamps.NANOS_PER_SECOND; -import com.google.common.collect.ComparisonChain; import com.google.protobuf.Duration; import java.text.ParseException; import java.util.Comparator; @@ -71,11 +70,8 @@ public final class Durations { public int compare(Duration d1, Duration d2) { checkValid(d1); checkValid(d2); - - return ComparisonChain.start() - .compare(d1.getSeconds(), d2.getSeconds()) - .compare(d1.getNanos(), d2.getNanos()) - .result(); + int secDiff = Long.compare(d1.getSeconds(), d2.getSeconds()); + return (secDiff != 0) ? secDiff : Integer.compare(d1.getNanos(), d2.getNanos()); } }; diff --git a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java index b577495d..b192b53e 100644 --- a/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java +++ b/java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java @@ -217,7 +217,12 @@ final class FieldMaskTree { Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options) { - assert source.getDescriptorForType() == destination.getDescriptorForType(); + if (source.getDescriptorForType() != destination.getDescriptorForType()) { + throw new IllegalArgumentException( + String.format( + "source (%s) and destination (%s) descriptor must be equal", + source.getDescriptorForType(), destination.getDescriptorForType())); + } Descriptor descriptor = source.getDescriptorForType(); for (Entry<String, Node> entry : node.children.entrySet()) { 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 f0a168e2..ac712c94 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 @@ -68,7 +68,6 @@ import com.google.protobuf.Timestamp; import com.google.protobuf.UInt32Value; import com.google.protobuf.UInt64Value; import com.google.protobuf.Value; - import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -225,7 +224,7 @@ public class JsonFormat { * Creates a {@link Parser} with default configuration. */ public static Parser parser() { - return new Parser(TypeRegistry.getEmptyTypeRegistry(), false); + return new Parser(TypeRegistry.getEmptyTypeRegistry(), false, Parser.DEFAULT_RECURSION_LIMIT); } /** @@ -234,10 +233,15 @@ public class JsonFormat { public static class Parser { private final TypeRegistry registry; private final boolean ignoringUnknownFields; + private final int recursionLimit; + + // The default parsing recursion limit is aligned with the proto binary parser. + private static final int DEFAULT_RECURSION_LIMIT = 100; - private Parser(TypeRegistry registry, boolean ignoreUnknownFields) { + private Parser(TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) { this.registry = registry; this.ignoringUnknownFields = ignoreUnknownFields; + this.recursionLimit = recursionLimit; } /** @@ -250,16 +254,15 @@ public class JsonFormat { if (this.registry != TypeRegistry.getEmptyTypeRegistry()) { throw new IllegalArgumentException("Only one registry is allowed."); } - return new Parser(registry, this.ignoringUnknownFields); + return new Parser(registry, ignoringUnknownFields, recursionLimit); } /** - * Creates a new {@link Parser} configured to not throw an exception - * when an unknown field is encountered. The new Parser clones all other - * configurations from this Parser. + * Creates a new {@link Parser} configured to not throw an exception when an unknown field is + * encountered. The new Parser clones all other configurations from this Parser. */ public Parser ignoringUnknownFields() { - return new Parser(this.registry, true); + return new Parser(this.registry, true, recursionLimit); } /** @@ -271,7 +274,7 @@ public class JsonFormat { public void merge(String json, Message.Builder builder) throws InvalidProtocolBufferException { // TODO(xiaofeng): Investigate the allocation overhead and optimize for // mobile. - new ParserImpl(registry, ignoringUnknownFields).merge(json, builder); + new ParserImpl(registry, ignoringUnknownFields, recursionLimit).merge(json, builder); } /** @@ -284,7 +287,12 @@ public class JsonFormat { public void merge(Reader json, Message.Builder builder) throws IOException { // TODO(xiaofeng): Investigate the allocation overhead and optimize for // mobile. - new ParserImpl(registry, ignoringUnknownFields).merge(json, builder); + new ParserImpl(registry, ignoringUnknownFields, recursionLimit).merge(json, builder); + } + + // For testing only. + Parser usingRecursionLimit(int recursionLimit) { + return new Parser(registry, ignoringUnknownFields, recursionLimit); } } @@ -1047,11 +1055,15 @@ public class JsonFormat { private final TypeRegistry registry; private final JsonParser jsonParser; private final boolean ignoringUnknownFields; + private final int recursionLimit; + private int currentDepth; - ParserImpl(TypeRegistry registry, boolean ignoreUnknownFields) { + ParserImpl(TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) { this.registry = registry; this.ignoringUnknownFields = ignoreUnknownFields; this.jsonParser = new JsonParser(); + this.recursionLimit = recursionLimit; + this.currentDepth = 0; } void merge(Reader json, Message.Builder builder) throws IOException { @@ -1722,8 +1734,13 @@ public class JsonFormat { case MESSAGE: case GROUP: + if (currentDepth >= recursionLimit) { + throw new InvalidProtocolBufferException("Hit recursion limit."); + } + ++currentDepth; Message.Builder subBuilder = builder.newBuilderForField(field); merge(json, subBuilder); + --currentDepth; return subBuilder.build(); default: 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 52b1ab98..2160e4d5 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 @@ -37,7 +37,6 @@ import static com.google.common.math.LongMath.checkedAdd; import static com.google.common.math.LongMath.checkedMultiply; import static com.google.common.math.LongMath.checkedSubtract; -import com.google.common.collect.ComparisonChain; import com.google.protobuf.Duration; import com.google.protobuf.Timestamp; import java.text.ParseException; @@ -101,11 +100,8 @@ public final class Timestamps { public int compare(Timestamp t1, Timestamp t2) { checkValid(t1); checkValid(t2); - - return ComparisonChain.start() - .compare(t1.getSeconds(), t2.getSeconds()) - .compare(t1.getNanos(), t2.getNanos()) - .result(); + int secDiff = Long.compare(t1.getSeconds(), t2.getSeconds()); + return (secDiff != 0) ? secDiff : Integer.compare(t1.getNanos(), t2.getNanos()); } }; 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 823ed971..dafd9bb5 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 @@ -57,12 +57,15 @@ import com.google.protobuf.util.JsonTestProto.TestDuration; import com.google.protobuf.util.JsonTestProto.TestFieldMask; import com.google.protobuf.util.JsonTestProto.TestMap; import com.google.protobuf.util.JsonTestProto.TestOneof; +import com.google.protobuf.util.JsonTestProto.TestRecursive; import com.google.protobuf.util.JsonTestProto.TestStruct; import com.google.protobuf.util.JsonTestProto.TestTimestamp; import com.google.protobuf.util.JsonTestProto.TestWrappers; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; import junit.framework.TestCase; public class JsonFormatTest extends TestCase { @@ -216,7 +219,9 @@ public class JsonFormatTest extends TestCase { TestMap.Builder mapBuilder = TestMap.newBuilder(); mapBuilder.putInt32ToEnumMapValue(1, 0); - mapBuilder.getMutableInt32ToEnumMapValue().put(2, 12345); + Map<Integer, Integer> mapWithInvalidValues = new HashMap<Integer, Integer>(); + mapWithInvalidValues.put(2, 12345); + mapBuilder.putAllInt32ToEnumMapValue(mapWithInvalidValues); TestMap mapMessage = mapBuilder.build(); assertEquals( "{\n" @@ -1140,6 +1145,7 @@ public class JsonFormatTest extends TestCase { // Expected. } } + public void testParserIgnoringUnknownFields() throws Exception { TestAllTypes.Builder builder = TestAllTypes.newBuilder(); String json = "{\n" + " \"unknownField\": \"XXX\"\n" + "}"; @@ -1375,4 +1381,34 @@ public class JsonFormatTest extends TestCase { Any any = builder.build(); assertEquals(0, any.getValue().size()); } + + public void testRecursionLimit() throws Exception { + String input = + "{\n" + + " \"nested\": {\n" + + " \"nested\": {\n" + + " \"nested\": {\n" + + " \"nested\": {\n" + + " \"value\": 1234\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n"; + + JsonFormat.Parser parser = JsonFormat.parser(); + TestRecursive.Builder builder = TestRecursive.newBuilder(); + parser.merge(input, builder); + TestRecursive message = builder.build(); + assertEquals(1234, message.getNested().getNested().getNested().getNested().getValue()); + + parser = JsonFormat.parser().usingRecursionLimit(3); + builder = TestRecursive.newBuilder(); + try { + parser.merge(input, builder); + fail("Exception is expected."); + } catch (InvalidProtocolBufferException e) { + // Expected. + } + } } diff --git a/java/util/src/test/proto/com/google/protobuf/util/json_test.proto b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto index bd22f65a..a75338ef 100644 --- a/java/util/src/test/proto/com/google/protobuf/util/json_test.proto +++ b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto @@ -201,3 +201,8 @@ message TestAny { message TestCustomJsonName { int32 value = 1 [json_name = "@value"]; } + +message TestRecursive { + int32 value = 1; + TestRecursive nested = 2; +} diff --git a/jenkins/docker/Dockerfile b/jenkins/docker/Dockerfile index 3f4725b2..ca56a7c0 100644 --- a/jenkins/docker/Dockerfile +++ b/jenkins/docker/Dockerfile @@ -148,7 +148,7 @@ RUN php composer-setup.php RUN mv composer.phar /usr/bin/composer RUN php -r "unlink('composer-setup.php');" RUN cd /tmp && \ - cd protobuf && \ + cd protobuf/php && \ ln -sfn /usr/bin/php5.5 /usr/bin/php && \ ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \ ln -sfn /usr/bin/phpize5.5 /usr/bin/phpize && \ diff --git a/jenkins/docker32/Dockerfile b/jenkins/docker32/Dockerfile index a36338b4..bf59503f 100644 --- a/jenkins/docker32/Dockerfile +++ b/jenkins/docker32/Dockerfile @@ -63,7 +63,7 @@ RUN mv composer.phar /usr/bin/composer RUN php -r "unlink('composer-setup.php');" RUN cd /tmp && \ git clone https://github.com/google/protobuf.git && \ - cd protobuf && \ + cd protobuf/php && \ git reset 734930f9197b7bc97c3c794c7a949fee2a08c280 && \ ln -sfn /usr/bin/php5.5 /usr/bin/php && \ ln -sfn /usr/bin/php-config5.5 /usr/bin/php-config && \ diff --git a/js/binary/decoder.js b/js/binary/decoder.js index 040cf715..36828a73 100644 --- a/js/binary/decoder.js +++ b/js/binary/decoder.js @@ -733,6 +733,24 @@ jspb.BinaryDecoder.prototype.readZigzagVarint64 = function() { /** + * Reads a signed, zigzag-encoded 64-bit varint from the binary stream and + * returns its valud as a string. + * + * Zigzag encoding is a modification of varint encoding that reduces the + * storage overhead for small negative integers - for more details on the + * format, see https://developers.google.com/protocol-buffers/docs/encoding + * + * @return {string} The decoded signed, zigzag-encoded 64-bit varint as a + * string. + */ +jspb.BinaryDecoder.prototype.readZigzagVarint64String = function() { + // TODO(haberman): write lossless 64-bit zig-zag math. + var value = this.readZigzagVarint64(); + return value.toString(); +}; + + +/** * Reads a raw unsigned 8-bit integer from the binary stream. * * @return {number} The unsigned 8-bit integer read from the binary stream. @@ -791,6 +809,20 @@ jspb.BinaryDecoder.prototype.readUint64 = function() { /** + * Reads a raw unsigned 64-bit integer from the binary stream. Note that since + * Javascript represents all numbers as double-precision floats, there will be + * precision lost if the absolute value of the integer is larger than 2^53. + * + * @return {string} The unsigned 64-bit integer read from the binary stream. + */ +jspb.BinaryDecoder.prototype.readUint64String = function() { + var bitsLow = this.readUint32(); + var bitsHigh = this.readUint32(); + return jspb.utils.joinUnsignedDecimalString(bitsLow, bitsHigh); +}; + + +/** * Reads a raw signed 8-bit integer from the binary stream. * * @return {number} The signed 8-bit integer read from the binary stream. @@ -849,6 +881,20 @@ jspb.BinaryDecoder.prototype.readInt64 = function() { /** + * Reads a raw signed 64-bit integer from the binary stream and returns it as a + * string. + * + * @return {string} The signed 64-bit integer read from the binary stream. + * Precision will be lost if the integer exceeds 2^53. + */ +jspb.BinaryDecoder.prototype.readInt64String = function() { + var bitsLow = this.readUint32(); + var bitsHigh = this.readUint32(); + return jspb.utils.joinSignedDecimalString(bitsLow, bitsHigh); +}; + + +/** * Reads a 32-bit floating-point number from the binary stream, using the * temporary buffer to realign the data. * diff --git a/js/binary/encoder.js b/js/binary/encoder.js index d952d714..1663bbd4 100644 --- a/js/binary/encoder.js +++ b/js/binary/encoder.js @@ -100,6 +100,24 @@ jspb.BinaryEncoder.prototype.writeSplitVarint64 = function(lowBits, highBits) { /** + * Encodes a 64-bit integer in 32:32 split representation into its wire-format + * fixed representation and stores it in the buffer. + * @param {number} lowBits The low 32 bits of the int. + * @param {number} highBits The high 32 bits of the int. + */ +jspb.BinaryEncoder.prototype.writeSplitFixed64 = function(lowBits, highBits) { + goog.asserts.assert(lowBits == Math.floor(lowBits)); + goog.asserts.assert(highBits == Math.floor(highBits)); + goog.asserts.assert((lowBits >= 0) && + (lowBits < jspb.BinaryConstants.TWO_TO_32)); + goog.asserts.assert((highBits >= 0) && + (highBits < jspb.BinaryConstants.TWO_TO_32)); + this.writeUint32(lowBits); + this.writeUint32(highBits); +}; + + +/** * Encodes a 32-bit unsigned integer into its wire-format varint representation * and stores it in the buffer. * @param {number} value The integer to convert. @@ -208,6 +226,18 @@ jspb.BinaryEncoder.prototype.writeZigzagVarint64 = function(value) { /** + * Encodes a JavaScript decimal string into its wire-format, zigzag-encoded + * varint representation and stores it in the buffer. Integers not representable + * in 64 bits will be truncated. + * @param {string} value The integer to convert. + */ +jspb.BinaryEncoder.prototype.writeZigzagVarint64String = function(value) { + // TODO(haberman): write lossless 64-bit zig-zag math. + this.writeZigzagVarint64(parseInt(value, 10)); +}; + + +/** * Writes a 8-bit unsigned integer to the buffer. Numbers outside the range * [0,2^8) will be truncated. * @param {number} value The value to write. @@ -314,8 +344,21 @@ jspb.BinaryEncoder.prototype.writeInt64 = function(value) { goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) && (value < jspb.BinaryConstants.TWO_TO_63)); jspb.utils.splitInt64(value); - this.writeUint32(jspb.utils.split64Low); - this.writeUint32(jspb.utils.split64High); + this.writeSplitFixed64(jspb.utils.split64Low, jspb.utils.split64High); +}; + + +/** + * Writes a 64-bit integer decimal strings to the buffer. Numbers outside the + * range [-2^63,2^63) will be truncated. + * @param {string} value The value to write. + */ +jspb.BinaryEncoder.prototype.writeInt64String = function(value) { + goog.asserts.assert(value == Math.floor(value)); + goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) && + (value < jspb.BinaryConstants.TWO_TO_63)); + jspb.utils.splitHash64(jspb.utils.decimalStringToHash64(value)); + this.writeSplitFixed64(jspb.utils.split64Low, jspb.utils.split64High); }; diff --git a/js/binary/proto_test.js b/js/binary/proto_test.js index 26e1d30f..f86dc645 100644 --- a/js/binary/proto_test.js +++ b/js/binary/proto_test.js @@ -32,6 +32,7 @@ goog.require('goog.crypt.base64'); goog.require('goog.testing.asserts'); +goog.require('jspb.BinaryWriter'); goog.require('jspb.Message'); // CommonJS-LoadFromFile: ../testbinary_pb proto.jspb.test @@ -87,6 +88,9 @@ goog.require('proto.jspb.test.extendRepeatedStringList'); goog.require('proto.jspb.test.extendRepeatedUint32List'); goog.require('proto.jspb.test.extendRepeatedUint64List'); +// CommonJS-LoadFromFile: ../node_modules/google-protobuf/google/protobuf/any_pb proto.google.protobuf +goog.require('proto.google.protobuf.Any'); + var suite = {}; @@ -194,8 +198,6 @@ function bytesCompare(arr, expected) { * @param {proto.jspb.test.TestAllTypes} copy */ function checkAllFields(original, copy) { - assertTrue(jspb.Message.equals(original, copy)); - assertEquals(copy.getOptionalInt32(), -42); assertEquals(copy.getOptionalInt64(), -0x7fffffff00000000); assertEquals(copy.getOptionalUint32(), 0x80000000); @@ -270,6 +272,9 @@ function checkAllFields(original, copy) { assertElementsEquals(copy.getPackedRepeatedFloatList(), [1.5]); assertElementsEquals(copy.getPackedRepeatedDoubleList(), [-1.5]); + + // Check last so we get more granular errors first. + assertTrue(jspb.Message.equals(original, copy)); } @@ -625,4 +630,36 @@ describe('protoBinaryTest', function() { var decoded = proto.jspb.test.TestExtendable.deserializeBinary(encoded); checkExtensions(decoded); }); + + /** + * Tests that unknown extensions don't cause deserialization failure. + */ + it('testUnknownExtension', function() { + var msg = new proto.jspb.test.TestExtendable(); + fillExtensions(msg); + var writer = new jspb.BinaryWriter(); + writer.writeBool((1 << 29) - 1, true); + proto.jspb.test.TestExtendable.serializeBinaryToWriter(msg, writer); + var encoded = writer.getResultBuffer(); + var decoded = proto.jspb.test.TestExtendable.deserializeBinary(encoded); + checkExtensions(decoded); + }); + + it('testAnyWellKnownType', function() { + var any = new proto.google.protobuf.Any(); + var msg = new proto.jspb.test.TestAllTypes(); + + fillAllFields(msg); + + any.pack(msg.serializeBinary(), 'jspb.test.TestAllTypes'); + + assertEquals('type.googleapis.com/jspb.test.TestAllTypes', + any.getTypeUrl()); + + var msg2 = any.unpack( + proto.jspb.test.TestAllTypes.deserializeBinary, + 'jspb.test.TestAllTypes'); + + checkAllFields(msg, msg2); + }); }); diff --git a/js/binary/reader.js b/js/binary/reader.js index 15f90432..8c5a4e88 100644 --- a/js/binary/reader.js +++ b/js/binary/reader.js @@ -744,6 +744,20 @@ jspb.BinaryReader.prototype.readSint64 = function() { /** + * Reads a signed zigzag-encoded 64-bit integer field from the binary stream, + * or throws an error if the next field in the stream is not of the correct + * wire type. + * + * @return {string} The value of the signed 64-bit integer field as a decimal string. + */ +jspb.BinaryReader.prototype.readSint64String = function() { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT); + return this.decoder_.readZigzagVarint64String(); +}; + + +/** * Reads an unsigned 32-bit fixed-length integer fiield from the binary stream, * or throws an error if the next field in the stream is not of the correct * wire type. @@ -772,11 +786,28 @@ jspb.BinaryReader.prototype.readFixed64 = function() { /** + * Reads a signed 64-bit integer field from the binary stream as a string, or + * throws an error if the next field in the stream is not of the correct wire + * type. + * + * Returns the value as a string. + * + * @return {string} The value of the unsigned 64-bit integer field as a decimal + * string. + */ +jspb.BinaryReader.prototype.readFixed64String = function() { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64); + return this.decoder_.readUint64String(); +}; + + +/** * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or * throws an error if the next field in the stream is not of the correct wire * type. * - * @return {number} The value of the double field. + * @return {number} The value of the signed 32-bit integer field. */ jspb.BinaryReader.prototype.readSfixed32 = function() { goog.asserts.assert( @@ -786,11 +817,26 @@ jspb.BinaryReader.prototype.readSfixed32 = function() { /** + * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or + * throws an error if the next field in the stream is not of the correct wire + * type. + * + * @return {string} The value of the signed 32-bit integer field as a decimal + * string. + */ +jspb.BinaryReader.prototype.readSfixed32String = function() { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32); + return this.decoder_.readInt32().toString(); +}; + + +/** * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or * throws an error if the next field in the stream is not of the correct wire * type. * - * @return {number} The value of the float field. + * @return {number} The value of the sfixed64 field. */ jspb.BinaryReader.prototype.readSfixed64 = function() { goog.asserts.assert( @@ -800,6 +846,22 @@ jspb.BinaryReader.prototype.readSfixed64 = function() { /** + * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or + * throws an error if the next field in the stream is not of the correct wire + * type. + * + * Returns the value as a string. + * + * @return {string} The value of the sfixed64 field as a decimal string. + */ +jspb.BinaryReader.prototype.readSfixed64String = function() { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64); + return this.decoder_.readInt64String(); +}; + + +/** * Reads a 32-bit floating-point field from the binary stream, or throws an * error if the next field in the stream is not of the correct wire type. * @@ -1028,6 +1090,16 @@ 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>} + */ +jspb.BinaryReader.prototype.readPackedSint64String = function() { + return this.readPackedField_(this.decoder_.readZigzagVarint64String); +}; + + +/** * Reads a packed fixed32 field, which consists of a length header and a list * of unsigned 32-bit ints. * @return {!Array.<number>} @@ -1048,6 +1120,16 @@ 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>} + */ +jspb.BinaryReader.prototype.readPackedFixed64String = function() { + return this.readPackedField_(this.decoder_.readUint64String); +}; + + +/** * Reads a packed sfixed32 field, which consists of a length header and a list * of 32-bit ints. * @return {!Array.<number>} @@ -1068,6 +1150,16 @@ 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>} + */ +jspb.BinaryReader.prototype.readPackedSfixed64String = function() { + return this.readPackedField_(this.decoder_.readInt64String); +}; + + +/** * Reads a packed float field, which consists of a length header and a list of * floats. * @return {!Array.<number>} diff --git a/js/binary/utils.js b/js/binary/utils.js index 51405553..bbf99cdf 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js @@ -618,6 +618,16 @@ jspb.utils.decimalStringToHash64 = function(dec) { /** + * Converts a signed or unsigned decimal string into two 32-bit halves, and + * stores them in the temp variables listed above. + * @param {string} value The decimal string to convert. + */ +jspb.utils.splitDecimalString = function(value) { + jspb.utils.splitHash64(jspb.utils.decimalStringToHash64(value)); +}; + + +/** * Converts an 8-character hash string into its hexadecimal representation. * @param {string} hash * @return {string} diff --git a/js/binary/writer.js b/js/binary/writer.js index 3eb2f1bd..c3009dbb 100644 --- a/js/binary/writer.js +++ b/js/binary/writer.js @@ -435,6 +435,20 @@ jspb.BinaryWriter.prototype.writeZigzagVarint64_ = function(field, value) { /** + * Writes a zigzag varint field to the buffer without range checking. + * @param {number} field The field number. + * @param {string?} value The value to write. + * @private + */ +jspb.BinaryWriter.prototype.writeZigzagVarint64String_ = function( + field, value) { + if (value == null) return; + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.VARINT); + this.encoder_.writeZigzagVarint64String(value); +}; + + +/** * Writes an int32 field to the buffer. Numbers outside the range [-2^31,2^31) * will be truncated. * @param {number} field The field number. @@ -575,6 +589,20 @@ jspb.BinaryWriter.prototype.writeSint64 = function(field, value) { /** + * Writes a sint64 field to the buffer. Numbers outside the range [-2^63,2^63) + * will be truncated. + * @param {number} field The field number. + * @param {string?} value The decimal string to write. + */ +jspb.BinaryWriter.prototype.writeSint64String = function(field, value) { + if (value == null) return; + goog.asserts.assert((value >= -jspb.BinaryConstants.TWO_TO_63) && + (value < jspb.BinaryConstants.TWO_TO_63)); + this.writeZigzagVarint64String_(field, value); +}; + + +/** * Writes a fixed32 field to the buffer. Numbers outside the range [0,2^32) * will be truncated. * @param {number} field The field number. @@ -605,6 +633,19 @@ jspb.BinaryWriter.prototype.writeFixed64 = function(field, value) { /** + * Writes a fixed64 field (with value as a string) to the buffer. + * @param {number} field The field number. + * @param {string?} value The value to write. + */ +jspb.BinaryWriter.prototype.writeFixed64String = function(field, value) { + if (value == null) return; + var num = jspb.arith.UInt64.fromString(value); + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.FIXED64); + this.encoder_.writeSplitFixed64(num.lo, num.hi); +}; + + +/** * Writes a sfixed32 field to the buffer. Numbers outside the range * [-2^31,2^31) will be truncated. * @param {number} field The field number. @@ -635,6 +676,20 @@ jspb.BinaryWriter.prototype.writeSfixed64 = function(field, value) { /** + * Writes a sfixed64 string field to the buffer. Numbers outside the range + * [-2^63,2^63) will be truncated. + * @param {number} field The field number. + * @param {string?} value The value to write. + */ +jspb.BinaryWriter.prototype.writeSfixed64String = function(field, value) { + if (value == null) return; + var num = jspb.arith.Int64.fromString(value); + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.FIXED64); + this.encoder_.writeSplitFixed64(num.lo, num.hi); +}; + + +/** * Writes a single-precision floating point field to the buffer. Numbers * requiring more than 32 bits of precision will be truncated. * @param {number} field The field number. @@ -796,28 +851,11 @@ jspb.BinaryWriter.prototype.writeVarintHash64 = function(field, value) { /** - * Writes an array of numbers to the buffer as a repeated varint field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint32_ = - function(field, value) { - if (value == null) return; - for (var i = 0; i < value.length; i++) { - this.writeUnsignedVarint32_(field, value[i]); - } -}; - - -/** - * Writes an array of numbers to the buffer as a repeated varint field. - * @param {number} field The field number. - * @param {?Array.<number>} value The array of ints to write. - * @private - */ -jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_ = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedInt32 = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { this.writeSignedVarint32_(field, value[i]); @@ -826,28 +864,25 @@ jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_ = /** - * Writes an array of numbers to the buffer as a repeated varint field. + * 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.<number>} value The array of ints to write. - * @private + * @param {?Array.<string>} value The array of ints to write. */ -jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint64_ = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedInt32String = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeUnsignedVarint64_(field, value[i]); + this.writeInt32String(field, value[i]); } }; /** - * Writes an array of numbers to the buffer as a repeated varint field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_ = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedInt64 = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { this.writeSignedVarint64_(field, value[i]); @@ -856,147 +891,112 @@ jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_ = /** - * Writes an array of numbers to the buffer as a repeated zigzag field. + * 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.<number>} value The array of ints to write. - * @private + * @param {?Array.<string>} value The array of ints to write. */ -jspb.BinaryWriter.prototype.writeRepeatedZigzag32_ = function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedInt64String = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeZigzagVarint32_(field, value[i]); + this.writeInt64String(field, value[i]); } }; /** - * Writes an array of numbers to the buffer as a repeated zigzag field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writeRepeatedZigzag_ = function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedUint32 = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeZigzagVarint64_(field, value[i]); + this.writeUnsignedVarint32_(field, value[i]); } }; /** - * 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. - */ -jspb.BinaryWriter.prototype.writeRepeatedInt32 = - jspb.BinaryWriter.prototype.writeRepeatedSignedVarint32_; - - -/** * Writes an array of numbers formatted as strings to the buffer as a repeated - * 32-bit int field. + * unsigned 32-bit int field. * @param {number} field The field number. * @param {?Array.<string>} value The array of ints to write. */ -jspb.BinaryWriter.prototype.writeRepeatedInt32String = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedUint32String = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeInt32String(field, value[i]); + this.writeUint32String(field, value[i]); } }; /** - * Writes an array of numbers to the buffer as a repeated 64-bit int field. + * 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. */ -jspb.BinaryWriter.prototype.writeRepeatedInt64 = - jspb.BinaryWriter.prototype.writeRepeatedSignedVarint64_; - - -/** - * 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. - */ -jspb.BinaryWriter.prototype.writeRepeatedInt64String = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedUint64 = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeInt64String(field, value[i]); + this.writeUnsignedVarint64_(field, value[i]); } }; /** - * 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. - */ -jspb.BinaryWriter.prototype.writeRepeatedUint32 = - jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint32_; - - -/** * Writes an array of numbers formatted as strings to the buffer as a repeated - * unsigned 32-bit int field. + * unsigned 64-bit int field. * @param {number} field The field number. * @param {?Array.<string>} value The array of ints to write. */ -jspb.BinaryWriter.prototype.writeRepeatedUint32String = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedUint64String = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeUint32String(field, value[i]); + this.writeUint64String(field, value[i]); } }; /** - * Writes an array numbers to the buffer as a repeated unsigned 64-bit int - * field. + * 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. */ -jspb.BinaryWriter.prototype.writeRepeatedUint64 = - jspb.BinaryWriter.prototype.writeRepeatedUnsignedVarint64_; - - -/** - * 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. - */ -jspb.BinaryWriter.prototype.writeRepeatedUint64String = - function(field, value) { +jspb.BinaryWriter.prototype.writeRepeatedSint32 = function(field, value) { if (value == null) return; for (var i = 0; i < value.length; i++) { - this.writeUint64String(field, value[i]); + this.writeZigzagVarint32_(field, value[i]); } }; /** - * Writes an array numbers to the buffer as a repeated signed 32-bit int field. + * 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. */ -jspb.BinaryWriter.prototype.writeRepeatedSint32 = - jspb.BinaryWriter.prototype.writeRepeatedZigzag32_; +jspb.BinaryWriter.prototype.writeRepeatedSint64 = function(field, value) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeZigzagVarint64_(field, value[i]); + } +}; /** * 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.<string>} value The array of ints to write. */ -jspb.BinaryWriter.prototype.writeRepeatedSint64 = - jspb.BinaryWriter.prototype.writeRepeatedZigzag_; +jspb.BinaryWriter.prototype.writeRepeatedSint64String = function(field, value) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeZigzagVarint64String_(field, value[i]); + } +}; /** @@ -1028,6 +1028,21 @@ 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. + */ +jspb.BinaryWriter.prototype.writeRepeatedFixed64String = function( + field, value) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeFixed64String(field, value[i]); + } +}; + + +/** * 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. @@ -1054,6 +1069,20 @@ 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. + */ +jspb.BinaryWriter.prototype.writeRepeatedSfixed64String = function(field, value) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeSfixed64String(field, value[i]); + } +}; + + +/** * 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. @@ -1203,151 +1232,127 @@ jspb.BinaryWriter.prototype.writeRepeatedVarintHash64 = /** - * Writes an array of numbers to the buffer as a packed varint field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writePackedUnsignedVarint32_ = function( - field, value) { +jspb.BinaryWriter.prototype.writePackedInt32 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeUnsignedVarint32(value[i]); + this.encoder_.writeSignedVarint32(value[i]); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed varint field. - * @param {number} field The field number. - * @param {?Array.<number>} value The array of ints to write. - * @private + * 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 */ -jspb.BinaryWriter.prototype.writePackedSignedVarint32_ = function( - field, value) { +jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeSignedVarint32(value[i]); + this.encoder_.writeSignedVarint32(parseInt(value[i], 10)); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed varint field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writePackedUnsignedVarint64_ = function( - field, value) { +jspb.BinaryWriter.prototype.writePackedInt64 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeUnsignedVarint64(value[i]); + this.encoder_.writeSignedVarint64(value[i]); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed varint field. - * @param {number} field The field number. - * @param {?Array.<number>} value The array of ints to write. - * @private + * 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 */ -jspb.BinaryWriter.prototype.writePackedSignedVarint64_ = function( - field, value) { +jspb.BinaryWriter.prototype.writePackedInt64String = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeSignedVarint64(value[i]); + var num = jspb.arith.Int64.fromString(value[i]); + this.encoder_.writeSplitVarint64(num.lo, num.hi); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed zigzag field. + * 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. - * @private */ -jspb.BinaryWriter.prototype.writePackedZigzag32_ = function(field, value) { +jspb.BinaryWriter.prototype.writePackedUint32 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeZigzagVarint32(value[i]); + this.encoder_.writeUnsignedVarint32(value[i]); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed zigzag field. - * @param {number} field The field number. - * @param {?Array.<number>} value The array of ints to write. - * @private + * 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 */ -jspb.BinaryWriter.prototype.writePackedZigzag64_ = function(field, value) { +jspb.BinaryWriter.prototype.writePackedUint32String = + function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeZigzagVarint64(value[i]); + this.encoder_.writeUnsignedVarint32(parseInt(value[i], 10)); } this.endDelimited_(bookmark); }; /** - * Writes an array of numbers to the buffer as a packed 32-bit int field. + * 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. */ -jspb.BinaryWriter.prototype.writePackedInt32 = - jspb.BinaryWriter.prototype.writePackedSignedVarint32_; - - -/** - * 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 - */ -jspb.BinaryWriter.prototype.writePackedInt32String = function(field, value) { +jspb.BinaryWriter.prototype.writePackedUint64 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeSignedVarint32(parseInt(value[i], 10)); + this.encoder_.writeUnsignedVarint64(value[i]); } this.endDelimited_(bookmark); }; /** - * 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. - */ -jspb.BinaryWriter.prototype.writePackedInt64 = - jspb.BinaryWriter.prototype.writePackedSignedVarint64_; - - -/** * Writes an array of numbers represented as strings to the buffer as a packed - * 64-bit int field. + * unsigned 64-bit int field. * @param {number} field * @param {?Array.<string>} value */ -jspb.BinaryWriter.prototype.writePackedInt64String = +jspb.BinaryWriter.prototype.writePackedUint64String = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - var num = jspb.arith.Int64.fromString(value[i]); + var num = jspb.arith.UInt64.fromString(value[i]); this.encoder_.writeSplitVarint64(num.lo, num.hi); } this.endDelimited_(bookmark); @@ -1355,74 +1360,50 @@ jspb.BinaryWriter.prototype.writePackedInt64String = /** - * Writes an array numbers to the buffer as a packed unsigned 32-bit int field. + * 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. */ -jspb.BinaryWriter.prototype.writePackedUint32 = - jspb.BinaryWriter.prototype.writePackedUnsignedVarint32_; - - -/** - * 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 - */ -jspb.BinaryWriter.prototype.writePackedUint32String = - function(field, value) { +jspb.BinaryWriter.prototype.writePackedSint32 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - this.encoder_.writeUnsignedVarint32(parseInt(value[i], 10)); + this.encoder_.writeZigzagVarint32(value[i]); } this.endDelimited_(bookmark); }; /** - * Writes an array numbers to the buffer as a packed unsigned 64-bit int field. + * 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. */ -jspb.BinaryWriter.prototype.writePackedUint64 = - jspb.BinaryWriter.prototype.writePackedUnsignedVarint64_; - - -/** - * 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 - */ -jspb.BinaryWriter.prototype.writePackedUint64String = - function(field, value) { +jspb.BinaryWriter.prototype.writePackedSint64 = function(field, value) { if (value == null || !value.length) return; var bookmark = this.beginDelimited_(field); for (var i = 0; i < value.length; i++) { - var num = jspb.arith.UInt64.fromString(value[i]); - this.encoder_.writeSplitVarint64(num.lo, num.hi); + this.encoder_.writeZigzagVarint64(value[i]); } this.endDelimited_(bookmark); }; /** - * Writes an array numbers to the buffer as a packed signed 32-bit int field. + * 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.<number>} value The array of ints to write. + * @param {?Array.<string>} value The array of decimal strings to write. */ -jspb.BinaryWriter.prototype.writePackedSint32 = - jspb.BinaryWriter.prototype.writePackedZigzag32_; - - -/** - * Writes an array 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. - */ -jspb.BinaryWriter.prototype.writePackedSint64 = - jspb.BinaryWriter.prototype.writePackedZigzag64_; +jspb.BinaryWriter.prototype.writePackedSint64String = function(field, value) { + if (value == null || !value.length) return; + var bookmark = this.beginDelimited_(field); + for (var i = 0; i < value.length; i++) { + // TODO(haberman): make lossless + this.encoder_.writeZigzagVarint64(parseInt(value[i], 10)); + } + this.endDelimited_(bookmark); +}; /** @@ -1456,6 +1437,23 @@ 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. + */ +jspb.BinaryWriter.prototype.writePackedFixed64String = function(field, value) { + if (value == null || !value.length) return; + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.DELIMITED); + this.encoder_.writeUnsignedVarint32(value.length * 8); + for (var i = 0; i < value.length; i++) { + var num = jspb.arith.UInt64.fromString(value[i]); + this.encoder_.writeSplitFixed64(num.lo, num.hi); + } +}; + + +/** * 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. @@ -1486,6 +1484,21 @@ 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. + */ +jspb.BinaryWriter.prototype.writePackedSfixed64String = function(field, value) { + if (value == null || !value.length) return; + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.DELIMITED); + this.encoder_.writeUnsignedVarint32(value.length * 8); + for (var i = 0; i < value.length; i++) { + this.encoder_.writeInt64String(value[i]); + } +}; + + +/** * 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. diff --git a/js/commonjs/export.js b/js/commonjs/export.js index 2403b1a4..1eaab5d5 100644 --- a/js/commonjs/export.js +++ b/js/commonjs/export.js @@ -24,3 +24,4 @@ exports.ExtensionFieldBinaryInfo = jspb.ExtensionFieldBinaryInfo; exports.exportSymbol = goog.exportSymbol; exports.inherits = goog.inherits; exports.object = {extend: goog.object.extend}; +exports.typeOf = goog.typeOf; diff --git a/js/commonjs/export_testdeps.js b/js/commonjs/export_testdeps.js index 59c77ca2..174c61e6 100644 --- a/js/commonjs/export_testdeps.js +++ b/js/commonjs/export_testdeps.js @@ -12,6 +12,7 @@ goog.require('jspb.arith.Int64'); goog.require('jspb.arith.UInt64'); goog.require('jspb.BinaryEncoder'); goog.require('jspb.BinaryDecoder'); +goog.require('jspb.BinaryWriter'); goog.require('jspb.utils'); exports.goog = goog; diff --git a/js/gulpfile.js b/js/gulpfile.js index cca99131..5f1b1d93 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -24,7 +24,7 @@ var wellKnownTypes = [ ]; gulp.task('genproto_closure', function (cb) { - exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto', + exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto && ' + protoc + ' --js_out=one_output_file_per_input_file,binary:. -I ../src -I . ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -33,7 +33,7 @@ gulp.task('genproto_closure', function (cb) { }); gulp.task('genproto_commonjs', function (cb) { - exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto', + exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -42,7 +42,7 @@ gulp.task('genproto_commonjs', function (cb) { }); gulp.task('genproto_commonjs_wellknowntypes', function (cb) { - exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ../src/google/protobuf/descriptor.proto', + exec('mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ../src ' + wellKnownTypes.join(' '), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); diff --git a/js/jasmine.json b/js/jasmine.json index f83c54c0..093f1579 100644 --- a/js/jasmine.json +++ b/js/jasmine.json @@ -7,6 +7,9 @@ "helpers": [ "node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js", "node_loader.js", - "deps.js" + "deps.js", + "google/protobuf/any.js", + "google/protobuf/struct.js", + "google/protobuf/timestamp.js" ] } @@ -131,6 +131,58 @@ jspb.Map.prototype.toArray = function() { /** + * Returns the map formatted as an array of key-value pairs, suitable for the + * toObject() form of a message. + * + * @param {boolean=} includeInstance Whether to include the JSPB instance for + * transitional soy proto support: http://goto/soy-param-migration + * @param {!function((boolean|undefined),!V):!Object=} valueToObject + * The static toObject() method, if V is a message type. + * @return {!Array<!Array<!Object>>} + */ +jspb.Map.prototype.toObject = function(includeInstance, valueToObject) { + var rawArray = this.toArray(); + var entries = []; + for (var i = 0; i < rawArray.length; i++) { + var entry = this.map_[rawArray[i][0].toString()]; + this.wrapEntry_(entry); + var valueWrapper = /** @type {!V|undefined} */ (entry.valueWrapper); + if (valueWrapper) { + goog.asserts.assert(valueToObject); + entries.push([entry.key, valueToObject(includeInstance, valueWrapper)]); + } else { + entries.push([entry.key, entry.value]); + } + } + return entries; +}; + + +/** + * Returns a Map from the given array of key-value pairs when the values are of + * message type. The values in the array must match the format returned by their + * message type's toObject() method. + * + * @template K, V + * @param {!Array<!Array<!Object>>} entries + * @param {!function(new:V)|function(new:V,?)} valueCtor + * The constructor for type V. + * @param {!function(!Object):V} valueFromObject + * The fromObject function for type V. + * @return {!jspb.Map<K, V>} + */ +jspb.Map.fromObject = function(entries, valueCtor, valueFromObject) { + var result = new jspb.Map([], valueCtor); + for (var i = 0; i < entries.length; i++) { + var key = entries[i][0]; + var value = valueFromObject(entries[i][1]); + result.set(key, value); + } + return result; +}; + + +/** * Helper: return an iterator over an array. * @template T * @param {!Array<T>} arr the array @@ -193,7 +245,7 @@ jspb.Map.prototype.del = function(key) { * to help out Angular 1.x users. Still evaluating whether this is the best * option. * - * @return {!Array<K|V>} + * @return {!Array<!Array<K|V>>} */ jspb.Map.prototype.getEntryList = function() { var entries = []; diff --git a/js/maps_test.js b/js/maps_test.js index 0d442f4f..6e6ddc29 100755 --- a/js/maps_test.js +++ b/js/maps_test.js @@ -262,6 +262,7 @@ function makeTests(msgInfo, submessageCtor, suffix) { }); } + /** * Exercises the lazy map<->underlying array sync. */ @@ -290,12 +291,16 @@ function makeTests(msgInfo, submessageCtor, suffix) { } describe('mapsTest', function() { - makeTests({ - constructor: proto.jspb.test.TestMapFields, - deserializeBinary: proto.jspb.test.TestMapFields.deserializeBinary - }, proto.jspb.test.MapValueMessage, "_Binary"); - makeTests({ - constructor: proto.jspb.test.TestMapFieldsNoBinary, - deserializeBinary: null - }, proto.jspb.test.MapValueMessageNoBinary, "_NoBinary"); + makeTests( + { + constructor: proto.jspb.test.TestMapFields, + deserializeBinary: proto.jspb.test.TestMapFields.deserializeBinary + }, + proto.jspb.test.MapValueMessage, '_Binary'); + makeTests( + { + constructor: proto.jspb.test.TestMapFieldsNoBinary, + deserializeBinary: null + }, + proto.jspb.test.MapValueMessageNoBinary, '_NoBinary'); }); diff --git a/js/message.js b/js/message.js index 8def763e..1eb88aef 100644 --- a/js/message.js +++ b/js/message.js @@ -550,11 +550,11 @@ jspb.Message.serializeBinaryExtensions = function(proto, writer, extensions, jspb.Message.readBinaryExtension = function(msg, reader, extensions, getExtensionFn, setExtensionFn) { var binaryFieldInfo = extensions[reader.getFieldNumber()]; - var fieldInfo = binaryFieldInfo.fieldInfo; if (!binaryFieldInfo) { reader.skipField(); return; } + var fieldInfo = binaryFieldInfo.fieldInfo; if (!binaryFieldInfo.binaryReaderFn) { throw new Error('Deserializing extension whose generated code does not ' + 'support binary format'); @@ -972,7 +972,8 @@ jspb.Message.wrapRepeatedField_ = function(msg, ctor, fieldNumber) { * Sets a proto field and syncs it to the backing array. * @param {!jspb.Message} msg A jspb proto. * @param {number} fieldNumber The field number. - * @param {jspb.Message|undefined} value A new value for this proto field. + * @param {?jspb.Message|?jspb.Map|undefined} value A new value for this proto + * field. * @protected */ jspb.Message.setWrapperField = function(msg, fieldNumber, value) { diff --git a/js/message_test.js b/js/message_test.js index b0a0a72e..082da944 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -73,10 +73,12 @@ goog.require('proto.jspb.test.TestGroup1'); goog.require('proto.jspb.test.TestMessageWithOneof'); goog.require('proto.jspb.test.TestReservedNames'); goog.require('proto.jspb.test.TestReservedNamesExtension'); +goog.require('proto.jspb.test.Deeply.Nested.Message'); // CommonJS-LoadFromFile: test2_pb proto.jspb.test goog.require('proto.jspb.test.ExtensionMessage'); goog.require('proto.jspb.test.TestExtensionsMessage'); +goog.require('proto.jspb.test.ForeignNestedFieldMessage'); @@ -1047,11 +1049,14 @@ describe('Message test suite', function() { var nested = new proto.jspb.test.Deeply.Nested.Message(); nested.setCount(5); msg.setDeeplyNestedMessage(nested); + assertEquals(5, msg.getDeeplyNestedMessage().getCount()); // After a serialization-deserialization round trip we should get back the // same data we started with. var serialized = msg.serializeBinary(); - var deserialized = proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized); + var deserialized = + proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary(serialized); assertEquals(5, deserialized.getDeeplyNestedMessage().getCount()); }); + }); diff --git a/js/proto3_test.js b/js/proto3_test.js index 3c929eff..81d6de2f 100644 --- a/js/proto3_test.js +++ b/js/proto3_test.js @@ -38,6 +38,12 @@ goog.require('proto.jspb.test.ForeignMessage'); goog.require('proto.jspb.test.Proto3Enum'); goog.require('proto.jspb.test.TestProto3'); +// CommonJS-LoadFromFile: google/protobuf/timestamp_pb proto.google.protobuf +goog.require('proto.google.protobuf.Timestamp'); + +// CommonJS-LoadFromFile: google/protobuf/struct_pb proto.google.protobuf +goog.require('proto.google.protobuf.Struct'); + var BYTES = new Uint8Array([1, 2, 8, 9]); var BYTES_B64 = goog.crypt.base64.encodeByteArray(BYTES); @@ -326,4 +332,36 @@ describe('proto3Test', function() { assertTrue(bytesCompare(msg.getOptionalBytes(), BYTES)); }); + + it('testTimestampWellKnownType', function() { + var msg = new proto.google.protobuf.Timestamp(); + msg.fromDate(new Date(123456789)); + assertEquals(123456, msg.getSeconds()); + assertEquals(789000000, msg.getNanos()); + var date = msg.toDate(); + assertEquals(123456789, date.getTime()); + }); + + it('testStructWellKnownType', function() { + var jsObj = { + abc: "def", + number: 12345.678, + nullKey: null, + boolKey: true, + listKey: [1, null, true, false, "abc"], + structKey: {foo: "bar", somenum: 123}, + complicatedKey: [{xyz: {abc: [3, 4, null, false]}}, "zzz"] + }; + + var struct = proto.google.protobuf.Struct.fromJavaScript(jsObj); + var jsObj2 = struct.toJavaScript(); + + assertEquals("def", jsObj2.abc); + assertEquals(12345.678, jsObj2.number); + assertEquals(null, jsObj2.nullKey); + assertEquals(true, jsObj2.boolKey); + assertEquals("abc", jsObj2.listKey[4]); + assertEquals("bar", jsObj2.structKey.foo); + assertEquals(4, jsObj2.complicatedKey[0].xyz.abc[1]); + }); }); diff --git a/js/test.proto b/js/test.proto index db238e1a..2be5b8c1 100644 --- a/js/test.proto +++ b/js/test.proto @@ -234,7 +234,9 @@ message TestEndsWithBytes { optional bytes data = 2; } + message TestMapFieldsNoBinary { + map<string, string> map_string_string = 1; map<string, int32> map_string_int32 = 2; map<string, int64> map_string_int64 = 3; @@ -258,6 +260,7 @@ enum MapValueEnumNoBinary { } message MapValueMessageNoBinary { + optional int32 foo = 1; } diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 new file mode 100644 index 00000000..b61fcb63 --- /dev/null +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -0,0 +1,982 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the specified +# version of the C++ standard. If necessary, add switches to CXX and +# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) +# or '14' (for the C++14 standard). +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> +# Copyright (c) 2012 Zack Weinberg <zackw@panix.com> +# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> +# Copyright (c) 2015 Paul Norman <penorman@mac.com> +# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> +# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro +dnl (serial version number 13). + +AX_REQUIRE_DEFINED([AC_MSG_WARN]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], + [$3], [optional], [ax_cxx_compile_cxx$1_required=false], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi + + m4_if([$2], [noext], [], [dnl + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success = xno; then + dnl HP's aCC needs +std=c++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=c++11" + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) + fi + fi + if test x$ac_success = xno; then + HAVE_CXX$1=0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1=1 + AC_DEFINE(HAVE_CXX$1,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1) + m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])]) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + +]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus <= 201402L + +#error "This is not a C++17 compiler" + +#else + +#if defined(__clang__) + #define REALLY_CLANG +#else + #if defined(__GNUC__) + #define REALLY_GCC + #endif +#endif + +#include <initializer_list> +#include <utility> +#include <type_traits> + +namespace cxx17 +{ + +#if !defined(REALLY_CLANG) + namespace test_constexpr_lambdas + { + + // TODO: test it with clang++ from git + + constexpr int foo = [](){return 42;}(); + + } +#endif // !defined(REALLY_CLANG) + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template<typename... Args> + int multiply(Args... args) + { + return (args * ... * 1); + } + + template<typename... Args> + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value); + static_assert(std::is_same<int, decltype(bar)>::value); + } + + namespace test_typename_in_template_template_parameter + { + + template<template<typename> typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template <bool cond> + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + +#if !defined(REALLY_CLANG) + namespace test_template_argument_deduction_for_class_templates + { + + // TODO: test it with clang++ from git + + template <typename T1, typename T2> + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } +#endif // !defined(REALLY_CLANG) + + namespace test_non_type_auto_template_parameters + { + + template <auto n> + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + +#if !defined(REALLY_CLANG) + namespace test_structured_bindings + { + + // TODO: test it with clang++ from git + + int arr[2] = { 1, 2 }; + std::pair<int, int> pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair<int, int>& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } +#endif // !defined(REALLY_CLANG) + +#if !defined(REALLY_CLANG) + namespace test_exception_spec_type_system + { + + // TODO: test it with clang++ from git + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template<typename T> + Bad + f(T*, T*); + + template<typename T1, typename T2> + Good + f(T1*, T2*); + + static_assert (std::is_same_v<Good, decltype(f(g1, g2))>); + + } +#endif // !defined(REALLY_CLANG) + + namespace test_inline_variables + { + + template<class T> void f(T) + {} + + template<class T> inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus <= 201402L + +]]) diff --git a/objectivec/DevTools/compile_testing_protos.sh b/objectivec/DevTools/compile_testing_protos.sh index 6cc32da9..d7f3f605 100755 --- a/objectivec/DevTools/compile_testing_protos.sh +++ b/objectivec/DevTools/compile_testing_protos.sh @@ -134,6 +134,8 @@ done compile_protos \ --proto_path="objectivec/Tests" \ objectivec/Tests/unittest_cycle.proto \ + objectivec/Tests/unittest_deprecated.proto \ + objectivec/Tests/unittest_deprecated_file.proto \ objectivec/Tests/unittest_extension_chain_a.proto \ objectivec/Tests/unittest_extension_chain_b.proto \ objectivec/Tests/unittest_extension_chain_c.proto \ diff --git a/objectivec/Tests/GPBARCUnittestProtos.m b/objectivec/Tests/GPBARCUnittestProtos.m index 28d2396c..29f6ccf6 100644 --- a/objectivec/Tests/GPBARCUnittestProtos.m +++ b/objectivec/Tests/GPBARCUnittestProtos.m @@ -42,6 +42,8 @@ #import "google/protobuf/Unittest.pbobjc.h" #import "google/protobuf/UnittestCustomOptions.pbobjc.h" #import "google/protobuf/UnittestCycle.pbobjc.h" +#import "google/protobuf/UnittestDeprecated.pbobjc.h" +#import "google/protobuf/UnittestDeprecatedFile.pbobjc.h" #import "google/protobuf/UnittestDropUnknownFields.pbobjc.h" #import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.h" #import "google/protobuf/UnittestEmpty.pbobjc.h" diff --git a/objectivec/Tests/GPBUnittestProtos.m b/objectivec/Tests/GPBUnittestProtos.m index 8d2948bf..756bd99e 100644 --- a/objectivec/Tests/GPBUnittestProtos.m +++ b/objectivec/Tests/GPBUnittestProtos.m @@ -43,6 +43,8 @@ #import "google/protobuf/UnittestArena.pbobjc.m" #import "google/protobuf/UnittestCustomOptions.pbobjc.m" #import "google/protobuf/UnittestCycle.pbobjc.m" +#import "google/protobuf/UnittestDeprecated.pbobjc.m" +#import "google/protobuf/UnittestDeprecatedFile.pbobjc.m" #import "google/protobuf/UnittestDropUnknownFields.pbobjc.m" #import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.m" #import "google/protobuf/UnittestEmpty.pbobjc.m" diff --git a/objectivec/Tests/unittest_deprecated.proto b/objectivec/Tests/unittest_deprecated.proto new file mode 100644 index 00000000..96a52bbb --- /dev/null +++ b/objectivec/Tests/unittest_deprecated.proto @@ -0,0 +1,95 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// +// 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. + +syntax = "proto2"; + +package protobuf_deprecated; +option objc_class_prefix = "Dep"; + +// +// This file is like unittest_deprecated_file.proto, but uses message, enum, +// enum value, and field level deprecation. +// +// The source generated from this file needs to be inspect to confirm it has +// all of the expected annotations. It also will be compiled into the unittest +// and that compile should be clean without errors. +// + +// Mix of field types marked as deprecated. +message Msg1 { + extensions 100 to max; + + optional string string_field = 1 [deprecated=true]; + required int32 int_field = 2 [deprecated=true]; + repeated fixed32 fixed_field = 3 [deprecated=true]; + optional Msg1 msg_field = 4 [deprecated=true]; +} + +// Mix of extension field types marked as deprecated. +extend Msg1 { + optional string string_ext_field = 101 [deprecated=true]; + optional int32 int_ext_field = 102 [deprecated=true]; + repeated fixed32 fixed_ext_field = 103 [deprecated=true]; + optional Msg1 msg_ext_field = 104 [deprecated=true]; +} + +// Mix of extension field types (scoped to a message) marked as deprecated. +message Msg1A { + extend Msg1 { + optional string string_ext2_field = 201 [deprecated=true]; + optional int32 int_ext2_field = 202 [deprecated=true]; + repeated fixed32 fixed_ext2_field = 203 [deprecated=true]; + optional Msg1 msg_ext2_field = 204 [deprecated=true]; + } +} + +// Enum value marked as deprecated. +enum Enum1 { + ENUM1_ONE = 1; + ENUM1_TWO = 2; + ENUM1_THREE = 3 [deprecated=true]; +} + +// Message marked as deprecated. +message Msg2 { + option deprecated = true; + + optional string string_field = 1; + required int32 int_field = 2; + repeated fixed32 fixed_field = 3; +} + +// Enum marked as deprecated. +enum Enum2 { + option deprecated = true; + + ENUM2_ONE = 1; + ENUM2_TWO = 2; + ENUM2_THREE = 3; +} diff --git a/objectivec/Tests/unittest_deprecated_file.proto b/objectivec/Tests/unittest_deprecated_file.proto new file mode 100644 index 00000000..ef92e7de --- /dev/null +++ b/objectivec/Tests/unittest_deprecated_file.proto @@ -0,0 +1,76 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2016 Google Inc. All rights reserved. +// +// 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. + +syntax = "proto2"; + +package protobuf_deprecated_file; +option objc_class_prefix = "FileDep"; + +// +// This file is like unittest_deprecated.proto, but does NOT use message, enum, +// enum value, or field level deprecation; instead it uses the file level option +// to mark everything. +// +// The source generated from this file needs to be inspect to confirm it has +// all of the expected annotations. It also will be compiled into the unittest +// and that compile should be clean without errors. +// +option deprecated = true; + +// Message to catch the deprecation. +message Msg1 { + extensions 100 to max; + + optional string string_field = 1; +} + +// Mix of extension field types to catch the deprecation. +extend Msg1 { + optional string string_ext_field = 101; + optional int32 int_ext_field = 102; + repeated fixed32 fixed_ext_field = 103; + optional Msg1 msg_ext_field = 104; +} + +// Mix of extension field types (scoped to a message) to catch the deprecation. +message Msg1A { + extend Msg1 { + optional string string_ext2_field = 201; + optional int32 int_ext2_field = 202; + repeated fixed32 fixed_ext2_field = 203; + optional Msg1 msg_ext2_field = 204; + } +} + +// Enum to catch the deprecation. +enum Enum1 { + ENUM1_ONE = 1; + ENUM1_TWO = 2; + ENUM1_THREE = 3; +} diff --git a/php/composer.json b/php/composer.json new file mode 100644 index 00000000..3dae2865 --- /dev/null +++ b/php/composer.json @@ -0,0 +1,27 @@ +{ + "name": "google/protobuf", + "type": "library", + "description": "proto library for PHP", + "keywords": ["proto"], + "homepage": "https://developers.google.com/protocol-buffers/", + "license": "BSD-3-Clause", + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.8.0" + }, + "autoload": { + "psr-4": { + "Foo\\": "tests/generated/Foo", + "Bar\\": "tests/generated/Bar", + "Google\\Protobuf\\": "tests/generated/Google/Protobuf", + "Google\\Protobuf\\Internal\\": "src/Google/Protobuf/Internal", + "GPBMetadata\\": "tests/generated/GPBMetadata", + "GPBMetadata\\Google\\Protobuf\\Internal\\": "src/GPBMetadata/Google/Protobuf/Internal" + }, + "files": [ + "src/Google/Protobuf/descriptor.php" + ] + } +} diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index d8fbbe11..16e397f5 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -41,6 +41,7 @@ static zend_function_entry message_methods[] = { PHP_ME(Message, decode, NULL, ZEND_ACC_PUBLIC) PHP_ME(Message, readOneof, NULL, ZEND_ACC_PROTECTED) PHP_ME(Message, writeOneof, NULL, ZEND_ACC_PROTECTED) + PHP_ME(Message, __construct, NULL, ZEND_ACC_PROTECTED) {NULL, NULL, NULL} }; @@ -210,6 +211,17 @@ void build_class_from_descriptor(zval* php_descriptor TSRMLS_DC) { // PHP Methods // ----------------------------------------------------------------------------- +// At the first time the message is created, the class entry hasn't been +// modified. As a result, the first created instance will be a normal zend +// object. Here, we manually modify it to our message in such a case. +PHP_METHOD(Message, __construct) { + if (Z_OBJVAL_P(getThis()).handlers != message_handlers) { + zend_class_entry* ce = Z_OBJCE_P(getThis()); + zval_dtor(getThis()); + Z_OBJVAL_P(getThis()) = message_create(ce TSRMLS_CC); + } +} + PHP_METHOD(Message, readOneof) { long index; diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index fb5879dc..8022a9aa 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -231,8 +231,8 @@ struct MessageHeader { }; MessageLayout* create_layout(const upb_msgdef* msgdef); -void layout_init(MessageLayout* layout, void* storage, zval** properties_table - TSRMLS_DC); +void layout_init(MessageLayout* layout, void* storage, + zval** properties_table TSRMLS_DC); zval* layout_get(MessageLayout* layout, const void* storage, const upb_fielddef* field, zval** cache TSRMLS_DC); void layout_set(MessageLayout* layout, MessageHeader* header, @@ -241,6 +241,7 @@ void free_layout(MessageLayout* layout); PHP_METHOD(Message, readOneof); PHP_METHOD(Message, writeOneof); +PHP_METHOD(Message, __construct); // ----------------------------------------------------------------------------- // Encode / Decode. diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 1d25a91b..8a2b3a22 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -458,8 +458,8 @@ void free_layout(MessageLayout* layout) { FREE(layout); } -void layout_init(MessageLayout* layout, void* storage, zval** properties_table - TSRMLS_DC) { +void layout_init(MessageLayout* layout, void* storage, + zval** properties_table TSRMLS_DC) { int i; upb_msg_field_iter it; for (upb_msg_field_begin(&it, layout->msgdef), i = 0; !upb_msg_field_done(&it); @@ -479,8 +479,8 @@ void layout_init(MessageLayout* layout, void* storage, zval** properties_table DEREF(memory, zval**) = property_ptr; } else if (upb_fielddef_label(field) == UPB_LABEL_REPEATED) { zval_ptr_dtor(property_ptr); - repeated_field_create_with_type(repeated_field_type, field, property_ptr - TSRMLS_CC); + repeated_field_create_with_type(repeated_field_type, field, + property_ptr TSRMLS_CC); DEREF(memory, zval**) = property_ptr; } else { native_slot_init(upb_fielddef_type(field), memory, property_ptr); diff --git a/php/phpunit.xml b/php/phpunit.xml new file mode 100644 index 00000000..0191a601 --- /dev/null +++ b/php/phpunit.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit bootstrap="./vendor/autoload.php" + colors="true"> + <testsuites> + <testsuite name="protobuf-tests"> + <file>tests/php_implementation_test.php</file> + <file>tests/array_test.php</file> + <file>tests/encode_decode_test.php</file> + <file>tests/generated_class_test.php</file> + <file>tests/map_field_test.php</file> + <file>tests/well_known_test.php</file> + </testsuite> + </testsuites> +</phpunit> diff --git a/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php new file mode 100644 index 00000000..7c5c8df4 --- /dev/null +++ b/php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php @@ -0,0 +1,260 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace GPBMetadata\Google\Protobuf\Internal; + +class Descriptor +{ + public static $is_initialized = false; + + public static function initOnce() { + $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); + + if (static::$is_initialized == true) { + return; + } + $pool->addMessage('google.protobuf.internal.FileDescriptorSet', \Google\Protobuf\Internal\FileDescriptorSet::class) + ->repeated('file', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.FileDescriptorProto') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.FileDescriptorProto', \Google\Protobuf\Internal\FileDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('package', \Google\Protobuf\Internal\GPBType::STRING, 2) + ->repeated('dependency', \Google\Protobuf\Internal\GPBType::STRING, 3) + ->repeated('public_dependency', \Google\Protobuf\Internal\GPBType::INT32, 10) + ->repeated('weak_dependency', \Google\Protobuf\Internal\GPBType::INT32, 11) + ->repeated('message_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.DescriptorProto') + ->repeated('enum_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 5, 'google.protobuf.internal.EnumDescriptorProto') + ->repeated('service', \Google\Protobuf\Internal\GPBType::MESSAGE, 6, 'google.protobuf.internal.ServiceDescriptorProto') + ->repeated('extension', \Google\Protobuf\Internal\GPBType::MESSAGE, 7, 'google.protobuf.internal.FieldDescriptorProto') + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.FileOptions') + ->optional('source_code_info', \Google\Protobuf\Internal\GPBType::MESSAGE, 9, 'google.protobuf.internal.SourceCodeInfo') + ->optional('syntax', \Google\Protobuf\Internal\GPBType::STRING, 12) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.DescriptorProto', \Google\Protobuf\Internal\DescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->repeated('field', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.FieldDescriptorProto') + ->repeated('extension', \Google\Protobuf\Internal\GPBType::MESSAGE, 6, 'google.protobuf.internal.FieldDescriptorProto') + ->repeated('nested_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.DescriptorProto') + ->repeated('enum_type', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.EnumDescriptorProto') + ->repeated('extension_range', \Google\Protobuf\Internal\GPBType::MESSAGE, 5, 'google.protobuf.internal.DescriptorProto.ExtensionRange') + ->repeated('oneof_decl', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.OneofDescriptorProto') + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 7, 'google.protobuf.internal.MessageOptions') + ->repeated('reserved_range', \Google\Protobuf\Internal\GPBType::MESSAGE, 9, 'google.protobuf.internal.DescriptorProto.ReservedRange') + ->repeated('reserved_name', \Google\Protobuf\Internal\GPBType::STRING, 10) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.DescriptorProto.ExtensionRange', \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class) + ->optional('start', \Google\Protobuf\Internal\GPBType::INT32, 1) + ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 2) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.DescriptorProto.ReservedRange', \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class) + ->optional('start', \Google\Protobuf\Internal\GPBType::INT32, 1) + ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 2) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.FieldDescriptorProto', \Google\Protobuf\Internal\FieldDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('number', \Google\Protobuf\Internal\GPBType::INT32, 3) + ->optional('label', \Google\Protobuf\Internal\GPBType::ENUM, 4, 'google.protobuf.internal.FieldDescriptorProto.Label') + ->optional('type', \Google\Protobuf\Internal\GPBType::ENUM, 5, 'google.protobuf.internal.FieldDescriptorProto.Type') + ->optional('type_name', \Google\Protobuf\Internal\GPBType::STRING, 6) + ->optional('extendee', \Google\Protobuf\Internal\GPBType::STRING, 2) + ->optional('default_value', \Google\Protobuf\Internal\GPBType::STRING, 7) + ->optional('oneof_index', \Google\Protobuf\Internal\GPBType::INT32, 9) + ->optional('json_name', \Google\Protobuf\Internal\GPBType::STRING, 10) + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions') + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', \Google\Protobuf\Internal\Type::class) + ->value("TYPE_DOUBLE", 1) + ->value("TYPE_FLOAT", 2) + ->value("TYPE_INT64", 3) + ->value("TYPE_UINT64", 4) + ->value("TYPE_INT32", 5) + ->value("TYPE_FIXED64", 6) + ->value("TYPE_FIXED32", 7) + ->value("TYPE_BOOL", 8) + ->value("TYPE_STRING", 9) + ->value("TYPE_GROUP", 10) + ->value("TYPE_MESSAGE", 11) + ->value("TYPE_BYTES", 12) + ->value("TYPE_UINT32", 13) + ->value("TYPE_ENUM", 14) + ->value("TYPE_SFIXED32", 15) + ->value("TYPE_SFIXED64", 16) + ->value("TYPE_SINT32", 17) + ->value("TYPE_SINT64", 18) + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Label', \Google\Protobuf\Internal\Label::class) + ->value("LABEL_OPTIONAL", 1) + ->value("LABEL_REQUIRED", 2) + ->value("LABEL_REPEATED", 3) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.OneofDescriptorProto', \Google\Protobuf\Internal\OneofDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.OneofOptions') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.EnumDescriptorProto', \Google\Protobuf\Internal\EnumDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->repeated('value', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.EnumValueDescriptorProto') + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumOptions') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.EnumValueDescriptorProto', \Google\Protobuf\Internal\EnumValueDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('number', \Google\Protobuf\Internal\GPBType::INT32, 2) + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumValueOptions') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.ServiceDescriptorProto', \Google\Protobuf\Internal\ServiceDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->repeated('method', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.MethodDescriptorProto') + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 3, 'google.protobuf.internal.ServiceOptions') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.MethodDescriptorProto', \Google\Protobuf\Internal\MethodDescriptorProto::class) + ->optional('name', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('input_type', \Google\Protobuf\Internal\GPBType::STRING, 2) + ->optional('output_type', \Google\Protobuf\Internal\GPBType::STRING, 3) + ->optional('options', \Google\Protobuf\Internal\GPBType::MESSAGE, 4, 'google.protobuf.internal.MethodOptions') + ->optional('client_streaming', \Google\Protobuf\Internal\GPBType::BOOL, 5) + ->optional('server_streaming', \Google\Protobuf\Internal\GPBType::BOOL, 6) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.FileOptions', \Google\Protobuf\Internal\FileOptions::class) + ->optional('java_package', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->optional('java_outer_classname', \Google\Protobuf\Internal\GPBType::STRING, 8) + ->optional('java_multiple_files', \Google\Protobuf\Internal\GPBType::BOOL, 10) + ->optional('java_generate_equals_and_hash', \Google\Protobuf\Internal\GPBType::BOOL, 20) + ->optional('java_string_check_utf8', \Google\Protobuf\Internal\GPBType::BOOL, 27) + ->optional('optimize_for', \Google\Protobuf\Internal\GPBType::ENUM, 9, 'google.protobuf.internal.FileOptions.OptimizeMode') + ->optional('go_package', \Google\Protobuf\Internal\GPBType::STRING, 11) + ->optional('cc_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 16) + ->optional('java_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 17) + ->optional('py_generic_services', \Google\Protobuf\Internal\GPBType::BOOL, 18) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 23) + ->optional('cc_enable_arenas', \Google\Protobuf\Internal\GPBType::BOOL, 31) + ->optional('objc_class_prefix', \Google\Protobuf\Internal\GPBType::STRING, 36) + ->optional('csharp_namespace', \Google\Protobuf\Internal\GPBType::STRING, 37) + ->optional('swift_prefix', \Google\Protobuf\Internal\GPBType::STRING, 39) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.FileOptions.OptimizeMode', \Google\Protobuf\Internal\OptimizeMode::class) + ->value("SPEED", 1) + ->value("CODE_SIZE", 2) + ->value("LITE_RUNTIME", 3) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.MessageOptions', \Google\Protobuf\Internal\MessageOptions::class) + ->optional('message_set_wire_format', \Google\Protobuf\Internal\GPBType::BOOL, 1) + ->optional('no_standard_descriptor_accessor', \Google\Protobuf\Internal\GPBType::BOOL, 2) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3) + ->optional('map_entry', \Google\Protobuf\Internal\GPBType::BOOL, 7) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.FieldOptions', \Google\Protobuf\Internal\FieldOptions::class) + ->optional('ctype', \Google\Protobuf\Internal\GPBType::ENUM, 1, 'google.protobuf.internal.FieldOptions.CType') + ->optional('packed', \Google\Protobuf\Internal\GPBType::BOOL, 2) + ->optional('jstype', \Google\Protobuf\Internal\GPBType::ENUM, 6, 'google.protobuf.internal.FieldOptions.JSType') + ->optional('lazy', \Google\Protobuf\Internal\GPBType::BOOL, 5) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3) + ->optional('weak', \Google\Protobuf\Internal\GPBType::BOOL, 10) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.FieldOptions.CType', \Google\Protobuf\Internal\CType::class) + ->value("STRING", 0) + ->value("CORD", 1) + ->value("STRING_PIECE", 2) + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.FieldOptions.JSType', \Google\Protobuf\Internal\JSType::class) + ->value("JS_NORMAL", 0) + ->value("JS_STRING", 1) + ->value("JS_NUMBER", 2) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.OneofOptions', \Google\Protobuf\Internal\OneofOptions::class) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.EnumOptions', \Google\Protobuf\Internal\EnumOptions::class) + ->optional('allow_alias', \Google\Protobuf\Internal\GPBType::BOOL, 2) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 3) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.EnumValueOptions', \Google\Protobuf\Internal\EnumValueOptions::class) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 1) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.ServiceOptions', \Google\Protobuf\Internal\ServiceOptions::class) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 33) + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.MethodOptions', \Google\Protobuf\Internal\MethodOptions::class) + ->optional('deprecated', \Google\Protobuf\Internal\GPBType::BOOL, 33) + ->optional('idempotency_level', \Google\Protobuf\Internal\GPBType::ENUM, 34, 'google.protobuf.internal.MethodOptions.IdempotencyLevel') + ->repeated('uninterpreted_option', \Google\Protobuf\Internal\GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') + ->finalizeToPool(); + + $pool->addEnum('google.protobuf.internal.MethodOptions.IdempotencyLevel', \Google\Protobuf\Internal\IdempotencyLevel::class) + ->value("IDEMPOTENCY_UNKNOWN", 0) + ->value("NO_SIDE_EFFECTS", 1) + ->value("IDEMPOTENT", 2) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.UninterpretedOption', \Google\Protobuf\Internal\UninterpretedOption::class) + ->repeated('name', \Google\Protobuf\Internal\GPBType::MESSAGE, 2, 'google.protobuf.internal.UninterpretedOption.NamePart') + ->optional('identifier_value', \Google\Protobuf\Internal\GPBType::STRING, 3) + ->optional('positive_int_value', \Google\Protobuf\Internal\GPBType::UINT64, 4) + ->optional('negative_int_value', \Google\Protobuf\Internal\GPBType::INT64, 5) + ->optional('double_value', \Google\Protobuf\Internal\GPBType::DOUBLE, 6) + ->optional('string_value', \Google\Protobuf\Internal\GPBType::BYTES, 7) + ->optional('aggregate_value', \Google\Protobuf\Internal\GPBType::STRING, 8) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.UninterpretedOption.NamePart', \Google\Protobuf\Internal\UninterpretedOption_NamePart::class) + ->required('name_part', \Google\Protobuf\Internal\GPBType::STRING, 1) + ->required('is_extension', \Google\Protobuf\Internal\GPBType::BOOL, 2) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.SourceCodeInfo', \Google\Protobuf\Internal\SourceCodeInfo::class) + ->repeated('location', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.SourceCodeInfo.Location') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.SourceCodeInfo.Location', \Google\Protobuf\Internal\SourceCodeInfo_Location::class) + ->repeated('path', \Google\Protobuf\Internal\GPBType::INT32, 1) + ->repeated('span', \Google\Protobuf\Internal\GPBType::INT32, 2) + ->optional('leading_comments', \Google\Protobuf\Internal\GPBType::STRING, 3) + ->optional('trailing_comments', \Google\Protobuf\Internal\GPBType::STRING, 4) + ->repeated('leading_detached_comments', \Google\Protobuf\Internal\GPBType::STRING, 6) + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo', \Google\Protobuf\Internal\GeneratedCodeInfo::class) + ->repeated('annotation', \Google\Protobuf\Internal\GPBType::MESSAGE, 1, 'google.protobuf.internal.GeneratedCodeInfo.Annotation') + ->finalizeToPool(); + + $pool->addMessage('google.protobuf.internal.GeneratedCodeInfo.Annotation', \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class) + ->repeated('path', \Google\Protobuf\Internal\GPBType::INT32, 1) + ->optional('source_file', \Google\Protobuf\Internal\GPBType::STRING, 2) + ->optional('begin', \Google\Protobuf\Internal\GPBType::INT32, 3) + ->optional('end', \Google\Protobuf\Internal\GPBType::INT32, 4) + ->finalizeToPool(); + + $pool->finish(); + static::$is_initialized = true; + } +} + diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php new file mode 100644 index 00000000..f076f6be --- /dev/null +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -0,0 +1,325 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a message type. + * </pre> + * + * Protobuf type <code>google.protobuf.DescriptorProto</code> + */ +class DescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code> + */ + private $field; + private $has_field = false; + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code> + */ + private $extension; + private $has_extension = false; + /** + * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code> + */ + private $nested_type; + private $has_nested_type = false; + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code> + */ + private $enum_type; + private $has_enum_type = false; + /** + * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code> + */ + private $extension_range; + private $has_extension_range = false; + /** + * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code> + */ + private $oneof_decl; + private $has_oneof_decl = false; + /** + * <code>optional .google.protobuf.MessageOptions options = 7;</code> + */ + private $options = null; + private $has_options = false; + /** + * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code> + */ + private $reserved_range; + private $has_reserved_range = false; + /** + * <pre> + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + * </pre> + * + * <code>repeated string reserved_name = 10;</code> + */ + private $reserved_name; + private $has_reserved_name = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code> + */ + public function getField() + { + return $this->field; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto field = 2;</code> + */ + public function setField(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); + $this->field = $var; + $this->has_field = true; + } + + public function hasField() + { + return $this->has_field; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code> + */ + public function getExtension() + { + return $this->extension; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 6;</code> + */ + public function setExtension(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); + $this->extension = $var; + $this->has_extension = true; + } + + public function hasExtension() + { + return $this->has_extension; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code> + */ + public function getNestedType() + { + return $this->nested_type; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto nested_type = 3;</code> + */ + public function setNestedType(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); + $this->nested_type = $var; + $this->has_nested_type = true; + } + + public function hasNestedType() + { + return $this->has_nested_type; + } + + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code> + */ + public function getEnumType() + { + return $this->enum_type; + } + + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 4;</code> + */ + public function setEnumType(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); + $this->enum_type = $var; + $this->has_enum_type = true; + } + + public function hasEnumType() + { + return $this->has_enum_type; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code> + */ + public function getExtensionRange() + { + return $this->extension_range; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;</code> + */ + public function setExtensionRange(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class); + $this->extension_range = $var; + $this->has_extension_range = true; + } + + public function hasExtensionRange() + { + return $this->has_extension_range; + } + + /** + * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code> + */ + public function getOneofDecl() + { + return $this->oneof_decl; + } + + /** + * <code>repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;</code> + */ + public function setOneofDecl(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); + $this->oneof_decl = $var; + $this->has_oneof_decl = true; + } + + public function hasOneofDecl() + { + return $this->has_oneof_decl; + } + + /** + * <code>optional .google.protobuf.MessageOptions options = 7;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.MessageOptions options = 7;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code> + */ + public function getReservedRange() + { + return $this->reserved_range; + } + + /** + * <code>repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;</code> + */ + public function setReservedRange(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class); + $this->reserved_range = $var; + $this->has_reserved_range = true; + } + + public function hasReservedRange() + { + return $this->has_reserved_range; + } + + /** + * <pre> + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + * </pre> + * + * <code>repeated string reserved_name = 10;</code> + */ + public function getReservedName() + { + return $this->reserved_name; + } + + /** + * <pre> + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + * </pre> + * + * <code>repeated string reserved_name = 10;</code> + */ + public function setReservedName(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->reserved_name = $var; + $this->has_reserved_name = true; + } + + public function hasReservedName() + { + return $this->has_reserved_name; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php new file mode 100644 index 00000000..738a1738 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php @@ -0,0 +1,82 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.DescriptorProto.ExtensionRange</code> + */ +class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional int32 start = 1;</code> + */ + private $start = 0; + private $has_start = false; + /** + * <code>optional int32 end = 2;</code> + */ + private $end = 0; + private $has_end = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional int32 start = 1;</code> + */ + public function getStart() + { + return $this->start; + } + + /** + * <code>optional int32 start = 1;</code> + */ + public function setStart($var) + { + GPBUtil::checkInt32($var); + $this->start = $var; + $this->has_start = true; + } + + public function hasStart() + { + return $this->has_start; + } + + /** + * <code>optional int32 end = 2;</code> + */ + public function getEnd() + { + return $this->end; + } + + /** + * <code>optional int32 end = 2;</code> + */ + public function setEnd($var) + { + GPBUtil::checkInt32($var); + $this->end = $var; + $this->has_end = true; + } + + public function hasEnd() + { + return $this->has_end; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php new file mode 100644 index 00000000..be36b8aa --- /dev/null +++ b/php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php @@ -0,0 +1,112 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + * </pre> + * + * Protobuf type <code>google.protobuf.DescriptorProto.ReservedRange</code> + */ +class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Inclusive. + * </pre> + * + * <code>optional int32 start = 1;</code> + */ + private $start = 0; + private $has_start = false; + /** + * <pre> + * Exclusive. + * </pre> + * + * <code>optional int32 end = 2;</code> + */ + private $end = 0; + private $has_end = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Inclusive. + * </pre> + * + * <code>optional int32 start = 1;</code> + */ + public function getStart() + { + return $this->start; + } + + /** + * <pre> + * Inclusive. + * </pre> + * + * <code>optional int32 start = 1;</code> + */ + public function setStart($var) + { + GPBUtil::checkInt32($var); + $this->start = $var; + $this->has_start = true; + } + + public function hasStart() + { + return $this->has_start; + } + + /** + * <pre> + * Exclusive. + * </pre> + * + * <code>optional int32 end = 2;</code> + */ + public function getEnd() + { + return $this->end; + } + + /** + * <pre> + * Exclusive. + * </pre> + * + * <code>optional int32 end = 2;</code> + */ + public function setEnd($var) + { + GPBUtil::checkInt32($var); + $this->end = $var; + $this->has_end = true; + } + + public function hasEnd() + { + return $this->has_end; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php new file mode 100644 index 00000000..9c5f245b --- /dev/null +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -0,0 +1,114 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes an enum type. + * </pre> + * + * Protobuf type <code>google.protobuf.EnumDescriptorProto</code> + */ +class EnumDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code> + */ + private $value; + private $has_value = false; + /** + * <code>optional .google.protobuf.EnumOptions options = 3;</code> + */ + private $options = null; + private $has_options = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code> + */ + public function getValue() + { + return $this->value; + } + + /** + * <code>repeated .google.protobuf.EnumValueDescriptorProto value = 2;</code> + */ + public function setValue(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); + $this->value = $var; + $this->has_value = true; + } + + public function hasValue() + { + return $this->has_value; + } + + /** + * <code>optional .google.protobuf.EnumOptions options = 3;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.EnumOptions options = 3;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php new file mode 100644 index 00000000..a9c4e0d7 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -0,0 +1,158 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.EnumOptions</code> + */ +class EnumOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Set this option to true to allow mapping different tag names to the same + * value. + * </pre> + * + * <code>optional bool allow_alias = 2;</code> + */ + private $allow_alias = false; + private $has_allow_alias = false; + /** + * <pre> + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Set this option to true to allow mapping different tag names to the same + * value. + * </pre> + * + * <code>optional bool allow_alias = 2;</code> + */ + public function getAllowAlias() + { + return $this->allow_alias; + } + + /** + * <pre> + * Set this option to true to allow mapping different tag names to the same + * value. + * </pre> + * + * <code>optional bool allow_alias = 2;</code> + */ + public function setAllowAlias($var) + { + GPBUtil::checkBool($var); + $this->allow_alias = $var; + $this->has_allow_alias = true; + } + + public function hasAllowAlias() + { + return $this->has_allow_alias; + } + + /** + * <pre> + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php new file mode 100644 index 00000000..94dc36ec --- /dev/null +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -0,0 +1,114 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a value within an enum. + * </pre> + * + * Protobuf type <code>google.protobuf.EnumValueDescriptorProto</code> + */ +class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>optional int32 number = 2;</code> + */ + private $number = 0; + private $has_number = false; + /** + * <code>optional .google.protobuf.EnumValueOptions options = 3;</code> + */ + private $options = null; + private $has_options = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>optional int32 number = 2;</code> + */ + public function getNumber() + { + return $this->number; + } + + /** + * <code>optional int32 number = 2;</code> + */ + public function setNumber($var) + { + GPBUtil::checkInt32($var); + $this->number = $var; + $this->has_number = true; + } + + public function hasNumber() + { + return $this->has_number; + } + + /** + * <code>optional .google.protobuf.EnumValueOptions options = 3;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.EnumValueOptions options = 3;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php new file mode 100644 index 00000000..6446ecd4 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -0,0 +1,115 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.EnumValueOptions</code> + */ +class EnumValueOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + * </pre> + * + * <code>optional bool deprecated = 1 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + * </pre> + * + * <code>optional bool deprecated = 1 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + * </pre> + * + * <code>optional bool deprecated = 1 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php new file mode 100644 index 00000000..6ae2cd41 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -0,0 +1,424 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a field within a message. + * </pre> + * + * Protobuf type <code>google.protobuf.FieldDescriptorProto</code> + */ +class FieldDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>optional int32 number = 3;</code> + */ + private $number = 0; + private $has_number = false; + /** + * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code> + */ + private $label = 0; + private $has_label = false; + /** + * <pre> + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + * </pre> + * + * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code> + */ + private $type = 0; + private $has_type = false; + /** + * <pre> + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + * </pre> + * + * <code>optional string type_name = 6;</code> + */ + private $type_name = ''; + private $has_type_name = false; + /** + * <pre> + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + * </pre> + * + * <code>optional string extendee = 2;</code> + */ + private $extendee = ''; + private $has_extendee = false; + /** + * <pre> + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + * </pre> + * + * <code>optional string default_value = 7;</code> + */ + private $default_value = ''; + private $has_default_value = false; + /** + * <pre> + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + * </pre> + * + * <code>optional int32 oneof_index = 9;</code> + */ + private $oneof_index = 0; + private $has_oneof_index = false; + /** + * <pre> + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + * </pre> + * + * <code>optional string json_name = 10;</code> + */ + private $json_name = ''; + private $has_json_name = false; + /** + * <code>optional .google.protobuf.FieldOptions options = 8;</code> + */ + private $options = null; + private $has_options = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>optional int32 number = 3;</code> + */ + public function getNumber() + { + return $this->number; + } + + /** + * <code>optional int32 number = 3;</code> + */ + public function setNumber($var) + { + GPBUtil::checkInt32($var); + $this->number = $var; + $this->has_number = true; + } + + public function hasNumber() + { + return $this->has_number; + } + + /** + * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code> + */ + public function getLabel() + { + return $this->label; + } + + /** + * <code>optional .google.protobuf.FieldDescriptorProto.Label label = 4;</code> + */ + public function setLabel($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class); + $this->label = $var; + $this->has_label = true; + } + + public function hasLabel() + { + return $this->has_label; + } + + /** + * <pre> + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + * </pre> + * + * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code> + */ + public function getType() + { + return $this->type; + } + + /** + * <pre> + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + * </pre> + * + * <code>optional .google.protobuf.FieldDescriptorProto.Type type = 5;</code> + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class); + $this->type = $var; + $this->has_type = true; + } + + public function hasType() + { + return $this->has_type; + } + + /** + * <pre> + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + * </pre> + * + * <code>optional string type_name = 6;</code> + */ + public function getTypeName() + { + return $this->type_name; + } + + /** + * <pre> + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + * </pre> + * + * <code>optional string type_name = 6;</code> + */ + public function setTypeName($var) + { + GPBUtil::checkString($var, True); + $this->type_name = $var; + $this->has_type_name = true; + } + + public function hasTypeName() + { + return $this->has_type_name; + } + + /** + * <pre> + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + * </pre> + * + * <code>optional string extendee = 2;</code> + */ + public function getExtendee() + { + return $this->extendee; + } + + /** + * <pre> + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + * </pre> + * + * <code>optional string extendee = 2;</code> + */ + public function setExtendee($var) + { + GPBUtil::checkString($var, True); + $this->extendee = $var; + $this->has_extendee = true; + } + + public function hasExtendee() + { + return $this->has_extendee; + } + + /** + * <pre> + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + * </pre> + * + * <code>optional string default_value = 7;</code> + */ + public function getDefaultValue() + { + return $this->default_value; + } + + /** + * <pre> + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + * </pre> + * + * <code>optional string default_value = 7;</code> + */ + public function setDefaultValue($var) + { + GPBUtil::checkString($var, True); + $this->default_value = $var; + $this->has_default_value = true; + } + + public function hasDefaultValue() + { + return $this->has_default_value; + } + + /** + * <pre> + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + * </pre> + * + * <code>optional int32 oneof_index = 9;</code> + */ + public function getOneofIndex() + { + return $this->oneof_index; + } + + /** + * <pre> + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + * </pre> + * + * <code>optional int32 oneof_index = 9;</code> + */ + public function setOneofIndex($var) + { + GPBUtil::checkInt32($var); + $this->oneof_index = $var; + $this->has_oneof_index = true; + } + + public function hasOneofIndex() + { + return $this->has_oneof_index; + } + + /** + * <pre> + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + * </pre> + * + * <code>optional string json_name = 10;</code> + */ + public function getJsonName() + { + return $this->json_name; + } + + /** + * <pre> + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + * </pre> + * + * <code>optional string json_name = 10;</code> + */ + public function setJsonName($var) + { + GPBUtil::checkString($var, True); + $this->json_name = $var; + $this->has_json_name = true; + } + + public function hasJsonName() + { + return $this->has_json_name; + } + + /** + * <code>optional .google.protobuf.FieldOptions options = 8;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.FieldOptions options = 8;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php new file mode 100644 index 00000000..06f26015 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php @@ -0,0 +1,29 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * Protobuf enum <code>google.protobuf.FieldDescriptorProto.Label</code> + */ +namespace Google\Protobuf\Internal; + +class FieldDescriptorProto_Label +{ + /** + * <pre> + * 0 is reserved for errors + * </pre> + * + * <code>LABEL_OPTIONAL = 1;</code> + */ + const LABEL_OPTIONAL = 1; + /** + * <code>LABEL_REQUIRED = 2;</code> + */ + const LABEL_REQUIRED = 2; + /** + * <code>LABEL_REPEATED = 3;</code> + */ + const LABEL_REPEATED = 3; +} + diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php new file mode 100644 index 00000000..9bda76c2 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php @@ -0,0 +1,120 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * Protobuf enum <code>google.protobuf.FieldDescriptorProto.Type</code> + */ +namespace Google\Protobuf\Internal; + +class FieldDescriptorProto_Type +{ + /** + * <pre> + * 0 is reserved for errors. + * Order is weird for historical reasons. + * </pre> + * + * <code>TYPE_DOUBLE = 1;</code> + */ + const TYPE_DOUBLE = 1; + /** + * <code>TYPE_FLOAT = 2;</code> + */ + const TYPE_FLOAT = 2; + /** + * <pre> + * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + * </pre> + * + * <code>TYPE_INT64 = 3;</code> + */ + const TYPE_INT64 = 3; + /** + * <code>TYPE_UINT64 = 4;</code> + */ + const TYPE_UINT64 = 4; + /** + * <pre> + * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + * </pre> + * + * <code>TYPE_INT32 = 5;</code> + */ + const TYPE_INT32 = 5; + /** + * <code>TYPE_FIXED64 = 6;</code> + */ + const TYPE_FIXED64 = 6; + /** + * <code>TYPE_FIXED32 = 7;</code> + */ + const TYPE_FIXED32 = 7; + /** + * <code>TYPE_BOOL = 8;</code> + */ + const TYPE_BOOL = 8; + /** + * <code>TYPE_STRING = 9;</code> + */ + const TYPE_STRING = 9; + /** + * <pre> + * Tag-delimited aggregate. + * </pre> + * + * <code>TYPE_GROUP = 10;</code> + */ + const TYPE_GROUP = 10; + /** + * <pre> + * Length-delimited aggregate. + * </pre> + * + * <code>TYPE_MESSAGE = 11;</code> + */ + const TYPE_MESSAGE = 11; + /** + * <pre> + * New in version 2. + * </pre> + * + * <code>TYPE_BYTES = 12;</code> + */ + const TYPE_BYTES = 12; + /** + * <code>TYPE_UINT32 = 13;</code> + */ + const TYPE_UINT32 = 13; + /** + * <code>TYPE_ENUM = 14;</code> + */ + const TYPE_ENUM = 14; + /** + * <code>TYPE_SFIXED32 = 15;</code> + */ + const TYPE_SFIXED32 = 15; + /** + * <code>TYPE_SFIXED64 = 16;</code> + */ + const TYPE_SFIXED64 = 16; + /** + * <pre> + * Uses ZigZag encoding. + * </pre> + * + * <code>TYPE_SINT32 = 17;</code> + */ + const TYPE_SINT32 = 17; + /** + * <pre> + * Uses ZigZag encoding. + * </pre> + * + * <code>TYPE_SINT64 = 18;</code> + */ + const TYPE_SINT64 = 18; +} + diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php new file mode 100644 index 00000000..af1393a5 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -0,0 +1,429 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.FieldOptions</code> + */ +class FieldOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code> + */ + private $ctype = 0; + private $has_ctype = false; + /** + * <pre> + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + * </pre> + * + * <code>optional bool packed = 2;</code> + */ + private $packed = false; + private $has_packed = false; + /** + * <pre> + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). By default these types are + * represented as JavaScript strings. This avoids loss of precision that can + * happen when a large value is converted to a floating point JavaScript + * numbers. Specifying JS_NUMBER for the jstype causes the generated + * JavaScript code to use the JavaScript "number" type instead of strings. + * This option is an enum to permit additional types to be added, + * e.g. goog.math.Integer. + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code> + */ + private $jstype = 0; + private $has_jstype = false; + /** + * <pre> + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + * </pre> + * + * <code>optional bool lazy = 5 [default = false];</code> + */ + private $lazy = false; + private $has_lazy = false; + /** + * <pre> + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>optional bool weak = 10 [default = false];</code> + */ + private $weak = false; + private $has_weak = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code> + */ + public function getCtype() + { + return $this->ctype; + } + + /** + * <pre> + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];</code> + */ + public function setCtype($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class); + $this->ctype = $var; + $this->has_ctype = true; + } + + public function hasCtype() + { + return $this->has_ctype; + } + + /** + * <pre> + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + * </pre> + * + * <code>optional bool packed = 2;</code> + */ + public function getPacked() + { + return $this->packed; + } + + /** + * <pre> + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + * </pre> + * + * <code>optional bool packed = 2;</code> + */ + public function setPacked($var) + { + GPBUtil::checkBool($var); + $this->packed = $var; + $this->has_packed = true; + } + + public function hasPacked() + { + return $this->has_packed; + } + + /** + * <pre> + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). By default these types are + * represented as JavaScript strings. This avoids loss of precision that can + * happen when a large value is converted to a floating point JavaScript + * numbers. Specifying JS_NUMBER for the jstype causes the generated + * JavaScript code to use the JavaScript "number" type instead of strings. + * This option is an enum to permit additional types to be added, + * e.g. goog.math.Integer. + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code> + */ + public function getJstype() + { + return $this->jstype; + } + + /** + * <pre> + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). By default these types are + * represented as JavaScript strings. This avoids loss of precision that can + * happen when a large value is converted to a floating point JavaScript + * numbers. Specifying JS_NUMBER for the jstype causes the generated + * JavaScript code to use the JavaScript "number" type instead of strings. + * This option is an enum to permit additional types to be added, + * e.g. goog.math.Integer. + * </pre> + * + * <code>optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];</code> + */ + public function setJstype($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class); + $this->jstype = $var; + $this->has_jstype = true; + } + + public function hasJstype() + { + return $this->has_jstype; + } + + /** + * <pre> + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + * </pre> + * + * <code>optional bool lazy = 5 [default = false];</code> + */ + public function getLazy() + { + return $this->lazy; + } + + /** + * <pre> + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + * </pre> + * + * <code>optional bool lazy = 5 [default = false];</code> + */ + public function setLazy($var) + { + GPBUtil::checkBool($var); + $this->lazy = $var; + $this->has_lazy = true; + } + + public function hasLazy() + { + return $this->has_lazy; + } + + /** + * <pre> + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>optional bool weak = 10 [default = false];</code> + */ + public function getWeak() + { + return $this->weak; + } + + /** + * <pre> + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>optional bool weak = 10 [default = false];</code> + */ + public function setWeak($var) + { + GPBUtil::checkBool($var); + $this->weak = $var; + $this->has_weak = true; + } + + public function hasWeak() + { + return $this->has_weak; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_CType.php b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php new file mode 100644 index 00000000..2ff2a478 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldOptions_CType.php @@ -0,0 +1,29 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * Protobuf enum <code>google.protobuf.FieldOptions.CType</code> + */ +namespace Google\Protobuf\Internal; + +class FieldOptions_CType +{ + /** + * <pre> + * Default mode. + * </pre> + * + * <code>STRING = 0;</code> + */ + const STRING = 0; + /** + * <code>CORD = 1;</code> + */ + const CORD = 1; + /** + * <code>STRING_PIECE = 2;</code> + */ + const STRING_PIECE = 2; +} + diff --git a/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php new file mode 100644 index 00000000..541c8ae5 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FieldOptions_JSType.php @@ -0,0 +1,37 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * Protobuf enum <code>google.protobuf.FieldOptions.JSType</code> + */ +namespace Google\Protobuf\Internal; + +class FieldOptions_JSType +{ + /** + * <pre> + * Use the default type. + * </pre> + * + * <code>JS_NORMAL = 0;</code> + */ + const JS_NORMAL = 0; + /** + * <pre> + * Use JavaScript strings. + * </pre> + * + * <code>JS_STRING = 1;</code> + */ + const JS_STRING = 1; + /** + * <pre> + * Use JavaScript numbers. + * </pre> + * + * <code>JS_NUMBER = 2;</code> + */ + const JS_NUMBER = 2; +} + diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php new file mode 100644 index 00000000..39f67768 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -0,0 +1,477 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a complete .proto file. + * </pre> + * + * Protobuf type <code>google.protobuf.FileDescriptorProto</code> + */ +class FileDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * file name, relative to root of source tree + * </pre> + * + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <pre> + * e.g. "foo", "foo.bar", etc. + * </pre> + * + * <code>optional string package = 2;</code> + */ + private $package = ''; + private $has_package = false; + /** + * <pre> + * Names of files imported by this file. + * </pre> + * + * <code>repeated string dependency = 3;</code> + */ + private $dependency; + private $has_dependency = false; + /** + * <pre> + * Indexes of the public imported files in the dependency list above. + * </pre> + * + * <code>repeated int32 public_dependency = 10;</code> + */ + private $public_dependency; + private $has_public_dependency = false; + /** + * <pre> + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>repeated int32 weak_dependency = 11;</code> + */ + private $weak_dependency; + private $has_weak_dependency = false; + /** + * <pre> + * All top-level definitions in this file. + * </pre> + * + * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code> + */ + private $message_type; + private $has_message_type = false; + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code> + */ + private $enum_type; + private $has_enum_type = false; + /** + * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code> + */ + private $service; + private $has_service = false; + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code> + */ + private $extension; + private $has_extension = false; + /** + * <code>optional .google.protobuf.FileOptions options = 8;</code> + */ + private $options = null; + private $has_options = false; + /** + * <pre> + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + * </pre> + * + * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code> + */ + private $source_code_info = null; + private $has_source_code_info = false; + /** + * <pre> + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + * </pre> + * + * <code>optional string syntax = 12;</code> + */ + private $syntax = ''; + private $has_syntax = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * file name, relative to root of source tree + * </pre> + * + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <pre> + * file name, relative to root of source tree + * </pre> + * + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <pre> + * e.g. "foo", "foo.bar", etc. + * </pre> + * + * <code>optional string package = 2;</code> + */ + public function getPackage() + { + return $this->package; + } + + /** + * <pre> + * e.g. "foo", "foo.bar", etc. + * </pre> + * + * <code>optional string package = 2;</code> + */ + public function setPackage($var) + { + GPBUtil::checkString($var, True); + $this->package = $var; + $this->has_package = true; + } + + public function hasPackage() + { + return $this->has_package; + } + + /** + * <pre> + * Names of files imported by this file. + * </pre> + * + * <code>repeated string dependency = 3;</code> + */ + public function getDependency() + { + return $this->dependency; + } + + /** + * <pre> + * Names of files imported by this file. + * </pre> + * + * <code>repeated string dependency = 3;</code> + */ + public function setDependency(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->dependency = $var; + $this->has_dependency = true; + } + + public function hasDependency() + { + return $this->has_dependency; + } + + /** + * <pre> + * Indexes of the public imported files in the dependency list above. + * </pre> + * + * <code>repeated int32 public_dependency = 10;</code> + */ + public function getPublicDependency() + { + return $this->public_dependency; + } + + /** + * <pre> + * Indexes of the public imported files in the dependency list above. + * </pre> + * + * <code>repeated int32 public_dependency = 10;</code> + */ + public function setPublicDependency(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->public_dependency = $var; + $this->has_public_dependency = true; + } + + public function hasPublicDependency() + { + return $this->has_public_dependency; + } + + /** + * <pre> + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>repeated int32 weak_dependency = 11;</code> + */ + public function getWeakDependency() + { + return $this->weak_dependency; + } + + /** + * <pre> + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + * </pre> + * + * <code>repeated int32 weak_dependency = 11;</code> + */ + public function setWeakDependency(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->weak_dependency = $var; + $this->has_weak_dependency = true; + } + + public function hasWeakDependency() + { + return $this->has_weak_dependency; + } + + /** + * <pre> + * All top-level definitions in this file. + * </pre> + * + * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code> + */ + public function getMessageType() + { + return $this->message_type; + } + + /** + * <pre> + * All top-level definitions in this file. + * </pre> + * + * <code>repeated .google.protobuf.DescriptorProto message_type = 4;</code> + */ + public function setMessageType(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); + $this->message_type = $var; + $this->has_message_type = true; + } + + public function hasMessageType() + { + return $this->has_message_type; + } + + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code> + */ + public function getEnumType() + { + return $this->enum_type; + } + + /** + * <code>repeated .google.protobuf.EnumDescriptorProto enum_type = 5;</code> + */ + public function setEnumType(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); + $this->enum_type = $var; + $this->has_enum_type = true; + } + + public function hasEnumType() + { + return $this->has_enum_type; + } + + /** + * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code> + */ + public function getService() + { + return $this->service; + } + + /** + * <code>repeated .google.protobuf.ServiceDescriptorProto service = 6;</code> + */ + public function setService(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); + $this->service = $var; + $this->has_service = true; + } + + public function hasService() + { + return $this->has_service; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code> + */ + public function getExtension() + { + return $this->extension; + } + + /** + * <code>repeated .google.protobuf.FieldDescriptorProto extension = 7;</code> + */ + public function setExtension(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); + $this->extension = $var; + $this->has_extension = true; + } + + public function hasExtension() + { + return $this->has_extension; + } + + /** + * <code>optional .google.protobuf.FileOptions options = 8;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.FileOptions options = 8;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + + /** + * <pre> + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + * </pre> + * + * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code> + */ + public function getSourceCodeInfo() + { + return $this->source_code_info; + } + + /** + * <pre> + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + * </pre> + * + * <code>optional .google.protobuf.SourceCodeInfo source_code_info = 9;</code> + */ + public function setSourceCodeInfo(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); + $this->source_code_info = $var; + $this->has_source_code_info = true; + } + + public function hasSourceCodeInfo() + { + return $this->has_source_code_info; + } + + /** + * <pre> + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + * </pre> + * + * <code>optional string syntax = 12;</code> + */ + public function getSyntax() + { + return $this->syntax; + } + + /** + * <pre> + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + * </pre> + * + * <code>optional string syntax = 12;</code> + */ + public function setSyntax($var) + { + GPBUtil::checkString($var, True); + $this->syntax = $var; + $this->has_syntax = true; + } + + public function hasSyntax() + { + return $this->has_syntax; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php new file mode 100644 index 00000000..20a165c4 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php @@ -0,0 +1,59 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + * </pre> + * + * Protobuf type <code>google.protobuf.FileDescriptorSet</code> + */ +class FileDescriptorSet extends \Google\Protobuf\Internal\Message +{ + /** + * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code> + */ + private $file; + private $has_file = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code> + */ + public function getFile() + { + return $this->file; + } + + /** + * <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code> + */ + public function setFile(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); + $this->file = $var; + $this->has_file = true; + } + + public function hasFile() + { + return $this->has_file; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php new file mode 100644 index 00000000..2422f3ee --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -0,0 +1,741 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.FileOptions</code> + */ +class FileOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + * </pre> + * + * <code>optional string java_package = 1;</code> + */ + private $java_package = ''; + private $has_java_package = false; + /** + * <pre> + * If set, all the classes from the .proto file are wrapped in a single + * outer class with the given name. This applies to both Proto1 + * (equivalent to the old "--one_java_file" option) and Proto2 (where + * a .proto always translates to a single class, but you may want to + * explicitly choose the class name). + * </pre> + * + * <code>optional string java_outer_classname = 8;</code> + */ + private $java_outer_classname = ''; + private $has_java_outer_classname = false; + /** + * <pre> + * If set true, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the outer class + * named by java_outer_classname. However, the outer class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + * </pre> + * + * <code>optional bool java_multiple_files = 10 [default = false];</code> + */ + private $java_multiple_files = false; + private $has_java_multiple_files = false; + /** + * <pre> + * This option does nothing. + * </pre> + * + * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code> + */ + private $java_generate_equals_and_hash = false; + private $has_java_generate_equals_and_hash = false; + /** + * <pre> + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + * </pre> + * + * <code>optional bool java_string_check_utf8 = 27 [default = false];</code> + */ + private $java_string_check_utf8 = false; + private $has_java_string_check_utf8 = false; + /** + * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code> + */ + private $optimize_for = 0; + private $has_optimize_for = false; + /** + * <pre> + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + * </pre> + * + * <code>optional string go_package = 11;</code> + */ + private $go_package = ''; + private $has_go_package = false; + /** + * <pre> + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + * </pre> + * + * <code>optional bool cc_generic_services = 16 [default = false];</code> + */ + private $cc_generic_services = false; + private $has_cc_generic_services = false; + /** + * <code>optional bool java_generic_services = 17 [default = false];</code> + */ + private $java_generic_services = false; + private $has_java_generic_services = false; + /** + * <code>optional bool py_generic_services = 18 [default = false];</code> + */ + private $py_generic_services = false; + private $has_py_generic_services = false; + /** + * <pre> + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + * </pre> + * + * <code>optional bool deprecated = 23 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + * </pre> + * + * <code>optional bool cc_enable_arenas = 31 [default = false];</code> + */ + private $cc_enable_arenas = false; + private $has_cc_enable_arenas = false; + /** + * <pre> + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + * </pre> + * + * <code>optional string objc_class_prefix = 36;</code> + */ + private $objc_class_prefix = ''; + private $has_objc_class_prefix = false; + /** + * <pre> + * Namespace for generated classes; defaults to the package. + * </pre> + * + * <code>optional string csharp_namespace = 37;</code> + */ + private $csharp_namespace = ''; + private $has_csharp_namespace = false; + /** + * <pre> + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + * </pre> + * + * <code>optional string swift_prefix = 39;</code> + */ + private $swift_prefix = ''; + private $has_swift_prefix = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + * </pre> + * + * <code>optional string java_package = 1;</code> + */ + public function getJavaPackage() + { + return $this->java_package; + } + + /** + * <pre> + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + * </pre> + * + * <code>optional string java_package = 1;</code> + */ + public function setJavaPackage($var) + { + GPBUtil::checkString($var, True); + $this->java_package = $var; + $this->has_java_package = true; + } + + public function hasJavaPackage() + { + return $this->has_java_package; + } + + /** + * <pre> + * If set, all the classes from the .proto file are wrapped in a single + * outer class with the given name. This applies to both Proto1 + * (equivalent to the old "--one_java_file" option) and Proto2 (where + * a .proto always translates to a single class, but you may want to + * explicitly choose the class name). + * </pre> + * + * <code>optional string java_outer_classname = 8;</code> + */ + public function getJavaOuterClassname() + { + return $this->java_outer_classname; + } + + /** + * <pre> + * If set, all the classes from the .proto file are wrapped in a single + * outer class with the given name. This applies to both Proto1 + * (equivalent to the old "--one_java_file" option) and Proto2 (where + * a .proto always translates to a single class, but you may want to + * explicitly choose the class name). + * </pre> + * + * <code>optional string java_outer_classname = 8;</code> + */ + public function setJavaOuterClassname($var) + { + GPBUtil::checkString($var, True); + $this->java_outer_classname = $var; + $this->has_java_outer_classname = true; + } + + public function hasJavaOuterClassname() + { + return $this->has_java_outer_classname; + } + + /** + * <pre> + * If set true, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the outer class + * named by java_outer_classname. However, the outer class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + * </pre> + * + * <code>optional bool java_multiple_files = 10 [default = false];</code> + */ + public function getJavaMultipleFiles() + { + return $this->java_multiple_files; + } + + /** + * <pre> + * If set true, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the outer class + * named by java_outer_classname. However, the outer class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + * </pre> + * + * <code>optional bool java_multiple_files = 10 [default = false];</code> + */ + public function setJavaMultipleFiles($var) + { + GPBUtil::checkBool($var); + $this->java_multiple_files = $var; + $this->has_java_multiple_files = true; + } + + public function hasJavaMultipleFiles() + { + return $this->has_java_multiple_files; + } + + /** + * <pre> + * This option does nothing. + * </pre> + * + * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code> + */ + public function getJavaGenerateEqualsAndHash() + { + return $this->java_generate_equals_and_hash; + } + + /** + * <pre> + * This option does nothing. + * </pre> + * + * <code>optional bool java_generate_equals_and_hash = 20 [deprecated = true];</code> + */ + public function setJavaGenerateEqualsAndHash($var) + { + GPBUtil::checkBool($var); + $this->java_generate_equals_and_hash = $var; + $this->has_java_generate_equals_and_hash = true; + } + + public function hasJavaGenerateEqualsAndHash() + { + return $this->has_java_generate_equals_and_hash; + } + + /** + * <pre> + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + * </pre> + * + * <code>optional bool java_string_check_utf8 = 27 [default = false];</code> + */ + public function getJavaStringCheckUtf8() + { + return $this->java_string_check_utf8; + } + + /** + * <pre> + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + * </pre> + * + * <code>optional bool java_string_check_utf8 = 27 [default = false];</code> + */ + public function setJavaStringCheckUtf8($var) + { + GPBUtil::checkBool($var); + $this->java_string_check_utf8 = $var; + $this->has_java_string_check_utf8 = true; + } + + public function hasJavaStringCheckUtf8() + { + return $this->has_java_string_check_utf8; + } + + /** + * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code> + */ + public function getOptimizeFor() + { + return $this->optimize_for; + } + + /** + * <code>optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];</code> + */ + public function setOptimizeFor($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class); + $this->optimize_for = $var; + $this->has_optimize_for = true; + } + + public function hasOptimizeFor() + { + return $this->has_optimize_for; + } + + /** + * <pre> + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + * </pre> + * + * <code>optional string go_package = 11;</code> + */ + public function getGoPackage() + { + return $this->go_package; + } + + /** + * <pre> + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + * </pre> + * + * <code>optional string go_package = 11;</code> + */ + public function setGoPackage($var) + { + GPBUtil::checkString($var, True); + $this->go_package = $var; + $this->has_go_package = true; + } + + public function hasGoPackage() + { + return $this->has_go_package; + } + + /** + * <pre> + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + * </pre> + * + * <code>optional bool cc_generic_services = 16 [default = false];</code> + */ + public function getCcGenericServices() + { + return $this->cc_generic_services; + } + + /** + * <pre> + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + * </pre> + * + * <code>optional bool cc_generic_services = 16 [default = false];</code> + */ + public function setCcGenericServices($var) + { + GPBUtil::checkBool($var); + $this->cc_generic_services = $var; + $this->has_cc_generic_services = true; + } + + public function hasCcGenericServices() + { + return $this->has_cc_generic_services; + } + + /** + * <code>optional bool java_generic_services = 17 [default = false];</code> + */ + public function getJavaGenericServices() + { + return $this->java_generic_services; + } + + /** + * <code>optional bool java_generic_services = 17 [default = false];</code> + */ + public function setJavaGenericServices($var) + { + GPBUtil::checkBool($var); + $this->java_generic_services = $var; + $this->has_java_generic_services = true; + } + + public function hasJavaGenericServices() + { + return $this->has_java_generic_services; + } + + /** + * <code>optional bool py_generic_services = 18 [default = false];</code> + */ + public function getPyGenericServices() + { + return $this->py_generic_services; + } + + /** + * <code>optional bool py_generic_services = 18 [default = false];</code> + */ + public function setPyGenericServices($var) + { + GPBUtil::checkBool($var); + $this->py_generic_services = $var; + $this->has_py_generic_services = true; + } + + public function hasPyGenericServices() + { + return $this->has_py_generic_services; + } + + /** + * <pre> + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + * </pre> + * + * <code>optional bool deprecated = 23 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + * </pre> + * + * <code>optional bool deprecated = 23 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + * </pre> + * + * <code>optional bool cc_enable_arenas = 31 [default = false];</code> + */ + public function getCcEnableArenas() + { + return $this->cc_enable_arenas; + } + + /** + * <pre> + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + * </pre> + * + * <code>optional bool cc_enable_arenas = 31 [default = false];</code> + */ + public function setCcEnableArenas($var) + { + GPBUtil::checkBool($var); + $this->cc_enable_arenas = $var; + $this->has_cc_enable_arenas = true; + } + + public function hasCcEnableArenas() + { + return $this->has_cc_enable_arenas; + } + + /** + * <pre> + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + * </pre> + * + * <code>optional string objc_class_prefix = 36;</code> + */ + public function getObjcClassPrefix() + { + return $this->objc_class_prefix; + } + + /** + * <pre> + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + * </pre> + * + * <code>optional string objc_class_prefix = 36;</code> + */ + public function setObjcClassPrefix($var) + { + GPBUtil::checkString($var, True); + $this->objc_class_prefix = $var; + $this->has_objc_class_prefix = true; + } + + public function hasObjcClassPrefix() + { + return $this->has_objc_class_prefix; + } + + /** + * <pre> + * Namespace for generated classes; defaults to the package. + * </pre> + * + * <code>optional string csharp_namespace = 37;</code> + */ + public function getCsharpNamespace() + { + return $this->csharp_namespace; + } + + /** + * <pre> + * Namespace for generated classes; defaults to the package. + * </pre> + * + * <code>optional string csharp_namespace = 37;</code> + */ + public function setCsharpNamespace($var) + { + GPBUtil::checkString($var, True); + $this->csharp_namespace = $var; + $this->has_csharp_namespace = true; + } + + public function hasCsharpNamespace() + { + return $this->has_csharp_namespace; + } + + /** + * <pre> + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + * </pre> + * + * <code>optional string swift_prefix = 39;</code> + */ + public function getSwiftPrefix() + { + return $this->swift_prefix; + } + + /** + * <pre> + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + * </pre> + * + * <code>optional string swift_prefix = 39;</code> + */ + public function setSwiftPrefix($var) + { + GPBUtil::checkString($var, True); + $this->swift_prefix = $var; + $this->has_swift_prefix = true; + } + + public function hasSwiftPrefix() + { + return $this->has_swift_prefix; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php new file mode 100644 index 00000000..7fd488eb --- /dev/null +++ b/php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php @@ -0,0 +1,41 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * <pre> + * Generated classes can be optimized for speed or code size. + * </pre> + * + * Protobuf enum <code>google.protobuf.FileOptions.OptimizeMode</code> + */ +namespace Google\Protobuf\Internal; + +class FileOptions_OptimizeMode +{ + /** + * <pre> + * Generate complete code for parsing, serialization, + * </pre> + * + * <code>SPEED = 1;</code> + */ + const SPEED = 1; + /** + * <pre> + * etc. + * </pre> + * + * <code>CODE_SIZE = 2;</code> + */ + const CODE_SIZE = 2; + /** + * <pre> + * Generate code using MessageLite and the lite runtime. + * </pre> + * + * <code>LITE_RUNTIME = 3;</code> + */ + const LITE_RUNTIME = 3; +} + diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php new file mode 100644 index 00000000..8e493c2f --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php @@ -0,0 +1,75 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + * </pre> + * + * Protobuf type <code>google.protobuf.GeneratedCodeInfo</code> + */ +class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + * </pre> + * + * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code> + */ + private $annotation; + private $has_annotation = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + * </pre> + * + * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code> + */ + public function getAnnotation() + { + return $this->annotation; + } + + /** + * <pre> + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + * </pre> + * + * <code>repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;</code> + */ + public function setAnnotation(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class); + $this->annotation = $var; + $this->has_annotation = true; + } + + public function hasAnnotation() + { + return $this->has_annotation; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php new file mode 100644 index 00000000..dcc7edfe --- /dev/null +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php @@ -0,0 +1,198 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.GeneratedCodeInfo.Annotation</code> + */ +class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + private $path; + private $has_path = false; + /** + * <pre> + * Identifies the filesystem path to the original source .proto. + * </pre> + * + * <code>optional string source_file = 2;</code> + */ + private $source_file = ''; + private $has_source_file = false; + /** + * <pre> + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + * </pre> + * + * <code>optional int32 begin = 3;</code> + */ + private $begin = 0; + private $has_begin = false; + /** + * <pre> + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + * </pre> + * + * <code>optional int32 end = 4;</code> + */ + private $end = 0; + private $has_end = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + public function getPath() + { + return $this->path; + } + + /** + * <pre> + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + public function setPath(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->path = $var; + $this->has_path = true; + } + + public function hasPath() + { + return $this->has_path; + } + + /** + * <pre> + * Identifies the filesystem path to the original source .proto. + * </pre> + * + * <code>optional string source_file = 2;</code> + */ + public function getSourceFile() + { + return $this->source_file; + } + + /** + * <pre> + * Identifies the filesystem path to the original source .proto. + * </pre> + * + * <code>optional string source_file = 2;</code> + */ + public function setSourceFile($var) + { + GPBUtil::checkString($var, True); + $this->source_file = $var; + $this->has_source_file = true; + } + + public function hasSourceFile() + { + return $this->has_source_file; + } + + /** + * <pre> + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + * </pre> + * + * <code>optional int32 begin = 3;</code> + */ + public function getBegin() + { + return $this->begin; + } + + /** + * <pre> + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + * </pre> + * + * <code>optional int32 begin = 3;</code> + */ + public function setBegin($var) + { + GPBUtil::checkInt32($var); + $this->begin = $var; + $this->has_begin = true; + } + + public function hasBegin() + { + return $this->has_begin; + } + + /** + * <pre> + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + * </pre> + * + * <code>optional int32 end = 4;</code> + */ + public function getEnd() + { + return $this->end; + } + + /** + * <pre> + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + * </pre> + * + * <code>optional int32 end = 4;</code> + */ + public function setEnd($var) + { + GPBUtil::checkInt32($var); + $this->end = $var; + $this->has_end = true; + } + + public function hasEnd() + { + return $this->has_end; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php new file mode 100644 index 00000000..e4a214cb --- /dev/null +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -0,0 +1,334 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.MessageOptions</code> + */ +class MessageOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + * </pre> + * + * <code>optional bool message_set_wire_format = 1 [default = false];</code> + */ + private $message_set_wire_format = false; + private $has_message_set_wire_format = false; + /** + * <pre> + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + * </pre> + * + * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code> + */ + private $no_standard_descriptor_accessor = false; + private $has_no_standard_descriptor_accessor = false; + /** + * <pre> + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * Whether the message is an automatically generated map entry type for the + * maps field. + * For maps fields: + * map<KeyType, ValueType> map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementions still need to work as + * if the field is a repeated message field. + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * </pre> + * + * <code>optional bool map_entry = 7;</code> + */ + private $map_entry = false; + private $has_map_entry = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + * </pre> + * + * <code>optional bool message_set_wire_format = 1 [default = false];</code> + */ + public function getMessageSetWireFormat() + { + return $this->message_set_wire_format; + } + + /** + * <pre> + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + * </pre> + * + * <code>optional bool message_set_wire_format = 1 [default = false];</code> + */ + public function setMessageSetWireFormat($var) + { + GPBUtil::checkBool($var); + $this->message_set_wire_format = $var; + $this->has_message_set_wire_format = true; + } + + public function hasMessageSetWireFormat() + { + return $this->has_message_set_wire_format; + } + + /** + * <pre> + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + * </pre> + * + * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code> + */ + public function getNoStandardDescriptorAccessor() + { + return $this->no_standard_descriptor_accessor; + } + + /** + * <pre> + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + * </pre> + * + * <code>optional bool no_standard_descriptor_accessor = 2 [default = false];</code> + */ + public function setNoStandardDescriptorAccessor($var) + { + GPBUtil::checkBool($var); + $this->no_standard_descriptor_accessor = $var; + $this->has_no_standard_descriptor_accessor = true; + } + + public function hasNoStandardDescriptorAccessor() + { + return $this->has_no_standard_descriptor_accessor; + } + + /** + * <pre> + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + * </pre> + * + * <code>optional bool deprecated = 3 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * Whether the message is an automatically generated map entry type for the + * maps field. + * For maps fields: + * map<KeyType, ValueType> map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementions still need to work as + * if the field is a repeated message field. + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * </pre> + * + * <code>optional bool map_entry = 7;</code> + */ + public function getMapEntry() + { + return $this->map_entry; + } + + /** + * <pre> + * Whether the message is an automatically generated map entry type for the + * maps field. + * For maps fields: + * map<KeyType, ValueType> map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementions still need to work as + * if the field is a repeated message field. + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * </pre> + * + * <code>optional bool map_entry = 7;</code> + */ + public function setMapEntry($var) + { + GPBUtil::checkBool($var); + $this->map_entry = $var; + $this->has_map_entry = true; + } + + public function hasMapEntry() + { + return $this->has_map_entry; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php new file mode 100644 index 00000000..3d8df7af --- /dev/null +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -0,0 +1,237 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a method of a service. + * </pre> + * + * Protobuf type <code>google.protobuf.MethodDescriptorProto</code> + */ +class MethodDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <pre> + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + * </pre> + * + * <code>optional string input_type = 2;</code> + */ + private $input_type = ''; + private $has_input_type = false; + /** + * <code>optional string output_type = 3;</code> + */ + private $output_type = ''; + private $has_output_type = false; + /** + * <code>optional .google.protobuf.MethodOptions options = 4;</code> + */ + private $options = null; + private $has_options = false; + /** + * <pre> + * Identifies if client streams multiple client messages + * </pre> + * + * <code>optional bool client_streaming = 5 [default = false];</code> + */ + private $client_streaming = false; + private $has_client_streaming = false; + /** + * <pre> + * Identifies if server streams multiple server messages + * </pre> + * + * <code>optional bool server_streaming = 6 [default = false];</code> + */ + private $server_streaming = false; + private $has_server_streaming = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <pre> + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + * </pre> + * + * <code>optional string input_type = 2;</code> + */ + public function getInputType() + { + return $this->input_type; + } + + /** + * <pre> + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + * </pre> + * + * <code>optional string input_type = 2;</code> + */ + public function setInputType($var) + { + GPBUtil::checkString($var, True); + $this->input_type = $var; + $this->has_input_type = true; + } + + public function hasInputType() + { + return $this->has_input_type; + } + + /** + * <code>optional string output_type = 3;</code> + */ + public function getOutputType() + { + return $this->output_type; + } + + /** + * <code>optional string output_type = 3;</code> + */ + public function setOutputType($var) + { + GPBUtil::checkString($var, True); + $this->output_type = $var; + $this->has_output_type = true; + } + + public function hasOutputType() + { + return $this->has_output_type; + } + + /** + * <code>optional .google.protobuf.MethodOptions options = 4;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.MethodOptions options = 4;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + + /** + * <pre> + * Identifies if client streams multiple client messages + * </pre> + * + * <code>optional bool client_streaming = 5 [default = false];</code> + */ + public function getClientStreaming() + { + return $this->client_streaming; + } + + /** + * <pre> + * Identifies if client streams multiple client messages + * </pre> + * + * <code>optional bool client_streaming = 5 [default = false];</code> + */ + public function setClientStreaming($var) + { + GPBUtil::checkBool($var); + $this->client_streaming = $var; + $this->has_client_streaming = true; + } + + public function hasClientStreaming() + { + return $this->has_client_streaming; + } + + /** + * <pre> + * Identifies if server streams multiple server messages + * </pre> + * + * <code>optional bool server_streaming = 6 [default = false];</code> + */ + public function getServerStreaming() + { + return $this->server_streaming; + } + + /** + * <pre> + * Identifies if server streams multiple server messages + * </pre> + * + * <code>optional bool server_streaming = 6 [default = false];</code> + */ + public function setServerStreaming($var) + { + GPBUtil::checkBool($var); + $this->server_streaming = $var; + $this->has_server_streaming = true; + } + + public function hasServerStreaming() + { + return $this->has_server_streaming; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php new file mode 100644 index 00000000..3325e52b --- /dev/null +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -0,0 +1,143 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.MethodOptions</code> + */ +class MethodOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code> + */ + private $idempotency_level = 0; + private $has_idempotency_level = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code> + */ + public function getIdempotencyLevel() + { + return $this->idempotency_level; + } + + /** + * <code>optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN];</code> + */ + public function setIdempotencyLevel($var) + { + GPBUtil::checkEnum($var, \Google\Protobuf\Internal\MethodOptions_IdempotencyLevel::class); + $this->idempotency_level = $var; + $this->has_idempotency_level = true; + } + + public function hasIdempotencyLevel() + { + return $this->has_idempotency_level; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php new file mode 100644 index 00000000..62768b5c --- /dev/null +++ b/php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php @@ -0,0 +1,39 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +/** + * <pre> + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + * </pre> + * + * Protobuf enum <code>google.protobuf.MethodOptions.IdempotencyLevel</code> + */ +namespace Google\Protobuf\Internal; + +class MethodOptions_IdempotencyLevel +{ + /** + * <code>IDEMPOTENCY_UNKNOWN = 0;</code> + */ + const IDEMPOTENCY_UNKNOWN = 0; + /** + * <pre> + * implies idempotent + * </pre> + * + * <code>NO_SIDE_EFFECTS = 1;</code> + */ + const NO_SIDE_EFFECTS = 1; + /** + * <pre> + * idempotent, but may have side effects + * </pre> + * + * <code>IDEMPOTENT = 2;</code> + */ + const IDEMPOTENT = 2; +} + diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php new file mode 100644 index 00000000..e5fbe370 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -0,0 +1,86 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a oneof. + * </pre> + * + * Protobuf type <code>google.protobuf.OneofDescriptorProto</code> + */ +class OneofDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>optional .google.protobuf.OneofOptions options = 2;</code> + */ + private $options = null; + private $has_options = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>optional .google.protobuf.OneofOptions options = 2;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.OneofOptions options = 2;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php new file mode 100644 index 00000000..083d9929 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/OneofOptions.php @@ -0,0 +1,66 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.OneofOptions</code> + */ +class OneofOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php new file mode 100644 index 00000000..624bde84 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -0,0 +1,114 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Describes a service. + * </pre> + * + * Protobuf type <code>google.protobuf.ServiceDescriptorProto</code> + */ +class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message +{ + /** + * <code>optional string name = 1;</code> + */ + private $name = ''; + private $has_name = false; + /** + * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code> + */ + private $method; + private $has_method = false; + /** + * <code>optional .google.protobuf.ServiceOptions options = 3;</code> + */ + private $options = null; + private $has_options = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>optional string name = 1;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>optional string name = 1;</code> + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code> + */ + public function getMethod() + { + return $this->method; + } + + /** + * <code>repeated .google.protobuf.MethodDescriptorProto method = 2;</code> + */ + public function setMethod(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class); + $this->method = $var; + $this->has_method = true; + } + + public function hasMethod() + { + return $this->has_method; + } + + /** + * <code>optional .google.protobuf.ServiceOptions options = 3;</code> + */ + public function getOptions() + { + return $this->options; + } + + /** + * <code>optional .google.protobuf.ServiceOptions options = 3;</code> + */ + public function setOptions(&$var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class); + $this->options = $var; + $this->has_options = true; + } + + public function hasOptions() + { + return $this->has_options; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php new file mode 100644 index 00000000..5f3564e4 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -0,0 +1,115 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.ServiceOptions</code> + */ +class ServiceOptions extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + private $deprecated = false; + private $has_deprecated = false; + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + private $uninterpreted_option; + private $has_uninterpreted_option = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + public function getDeprecated() + { + return $this->deprecated; + } + + /** + * <pre> + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + * </pre> + * + * <code>optional bool deprecated = 33 [default = false];</code> + */ + public function setDeprecated($var) + { + GPBUtil::checkBool($var); + $this->deprecated = $var; + $this->has_deprecated = true; + } + + public function hasDeprecated() + { + return $this->has_deprecated; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function getUninterpretedOption() + { + return $this->uninterpreted_option; + } + + /** + * <pre> + * The parser stores options it doesn't recognize here. See above. + * </pre> + * + * <code>repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;</code> + */ + public function setUninterpretedOption(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); + $this->uninterpreted_option = $var; + $this->has_uninterpreted_option = true; + } + + public function hasUninterpretedOption() + { + return $this->has_uninterpreted_option; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php new file mode 100644 index 00000000..d2352ddd --- /dev/null +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php @@ -0,0 +1,191 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + * </pre> + * + * Protobuf type <code>google.protobuf.SourceCodeInfo</code> + */ +class SourceCodeInfo extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendent. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + * </pre> + * + * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code> + */ + private $location; + private $has_location = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendent. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + * </pre> + * + * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code> + */ + public function getLocation() + { + return $this->location; + } + + /** + * <pre> + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendent. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + * </pre> + * + * <code>repeated .google.protobuf.SourceCodeInfo.Location location = 1;</code> + */ + public function setLocation(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class); + $this->location = $var; + $this->has_location = true; + } + + public function hasLocation() + { + return $this->has_location; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php new file mode 100644 index 00000000..d1bdb166 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php @@ -0,0 +1,379 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * Protobuf type <code>google.protobuf.SourceCodeInfo.Location</code> + */ +class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message +{ + /** + * <pre> + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + private $path; + private $has_path = false; + /** + * <pre> + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + * </pre> + * + * <code>repeated int32 span = 2 [packed = true];</code> + */ + private $span; + private $has_span = false; + /** + * <pre> + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * Examples: + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * // Detached comment for corge paragraph 2. + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. */ + * /* Block comment attached to + * * grault. */ + * optional int32 grault = 6; + * // ignored detached comments. + * </pre> + * + * <code>optional string leading_comments = 3;</code> + */ + private $leading_comments = ''; + private $has_leading_comments = false; + /** + * <code>optional string trailing_comments = 4;</code> + */ + private $trailing_comments = ''; + private $has_trailing_comments = false; + /** + * <code>repeated string leading_detached_comments = 6;</code> + */ + private $leading_detached_comments; + private $has_leading_detached_comments = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <pre> + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + public function getPath() + { + return $this->path; + } + + /** + * <pre> + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + * </pre> + * + * <code>repeated int32 path = 1 [packed = true];</code> + */ + public function setPath(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->path = $var; + $this->has_path = true; + } + + public function hasPath() + { + return $this->has_path; + } + + /** + * <pre> + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + * </pre> + * + * <code>repeated int32 span = 2 [packed = true];</code> + */ + public function getSpan() + { + return $this->span; + } + + /** + * <pre> + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + * </pre> + * + * <code>repeated int32 span = 2 [packed = true];</code> + */ + public function setSpan(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->span = $var; + $this->has_span = true; + } + + public function hasSpan() + { + return $this->has_span; + } + + /** + * <pre> + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * Examples: + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * // Detached comment for corge paragraph 2. + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. */ + * /* Block comment attached to + * * grault. */ + * optional int32 grault = 6; + * // ignored detached comments. + * </pre> + * + * <code>optional string leading_comments = 3;</code> + */ + public function getLeadingComments() + { + return $this->leading_comments; + } + + /** + * <pre> + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * Examples: + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * // Detached comment for corge paragraph 2. + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. */ + * /* Block comment attached to + * * grault. */ + * optional int32 grault = 6; + * // ignored detached comments. + * </pre> + * + * <code>optional string leading_comments = 3;</code> + */ + public function setLeadingComments($var) + { + GPBUtil::checkString($var, True); + $this->leading_comments = $var; + $this->has_leading_comments = true; + } + + public function hasLeadingComments() + { + return $this->has_leading_comments; + } + + /** + * <code>optional string trailing_comments = 4;</code> + */ + public function getTrailingComments() + { + return $this->trailing_comments; + } + + /** + * <code>optional string trailing_comments = 4;</code> + */ + public function setTrailingComments($var) + { + GPBUtil::checkString($var, True); + $this->trailing_comments = $var; + $this->has_trailing_comments = true; + } + + public function hasTrailingComments() + { + return $this->has_trailing_comments; + } + + /** + * <code>repeated string leading_detached_comments = 6;</code> + */ + public function getLeadingDetachedComments() + { + return $this->leading_detached_comments; + } + + /** + * <code>repeated string leading_detached_comments = 6;</code> + */ + public function setLeadingDetachedComments(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->leading_detached_comments = $var; + $this->has_leading_detached_comments = true; + } + + public function hasLeadingDetachedComments() + { + return $this->has_leading_detached_comments; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php new file mode 100644 index 00000000..c0f48310 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -0,0 +1,246 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + * </pre> + * + * Protobuf type <code>google.protobuf.UninterpretedOption</code> + */ +class UninterpretedOption extends \Google\Protobuf\Internal\Message +{ + /** + * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code> + */ + private $name; + private $has_name = false; + /** + * <pre> + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + * </pre> + * + * <code>optional string identifier_value = 3;</code> + */ + private $identifier_value = ''; + private $has_identifier_value = false; + /** + * <code>optional uint64 positive_int_value = 4;</code> + */ + private $positive_int_value = 0; + private $has_positive_int_value = false; + /** + * <code>optional int64 negative_int_value = 5;</code> + */ + private $negative_int_value = 0; + private $has_negative_int_value = false; + /** + * <code>optional double double_value = 6;</code> + */ + private $double_value = 0.0; + private $has_double_value = false; + /** + * <code>optional bytes string_value = 7;</code> + */ + private $string_value = ''; + private $has_string_value = false; + /** + * <code>optional string aggregate_value = 8;</code> + */ + private $aggregate_value = ''; + private $has_aggregate_value = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code> + */ + public function getName() + { + return $this->name; + } + + /** + * <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code> + */ + public function setName(&$var) + { + GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class); + $this->name = $var; + $this->has_name = true; + } + + public function hasName() + { + return $this->has_name; + } + + /** + * <pre> + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + * </pre> + * + * <code>optional string identifier_value = 3;</code> + */ + public function getIdentifierValue() + { + return $this->identifier_value; + } + + /** + * <pre> + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + * </pre> + * + * <code>optional string identifier_value = 3;</code> + */ + public function setIdentifierValue($var) + { + GPBUtil::checkString($var, True); + $this->identifier_value = $var; + $this->has_identifier_value = true; + } + + public function hasIdentifierValue() + { + return $this->has_identifier_value; + } + + /** + * <code>optional uint64 positive_int_value = 4;</code> + */ + public function getPositiveIntValue() + { + return $this->positive_int_value; + } + + /** + * <code>optional uint64 positive_int_value = 4;</code> + */ + public function setPositiveIntValue($var) + { + GPBUtil::checkUint64($var); + $this->positive_int_value = $var; + $this->has_positive_int_value = true; + } + + public function hasPositiveIntValue() + { + return $this->has_positive_int_value; + } + + /** + * <code>optional int64 negative_int_value = 5;</code> + */ + public function getNegativeIntValue() + { + return $this->negative_int_value; + } + + /** + * <code>optional int64 negative_int_value = 5;</code> + */ + public function setNegativeIntValue($var) + { + GPBUtil::checkInt64($var); + $this->negative_int_value = $var; + $this->has_negative_int_value = true; + } + + public function hasNegativeIntValue() + { + return $this->has_negative_int_value; + } + + /** + * <code>optional double double_value = 6;</code> + */ + public function getDoubleValue() + { + return $this->double_value; + } + + /** + * <code>optional double double_value = 6;</code> + */ + public function setDoubleValue($var) + { + GPBUtil::checkDouble($var); + $this->double_value = $var; + $this->has_double_value = true; + } + + public function hasDoubleValue() + { + return $this->has_double_value; + } + + /** + * <code>optional bytes string_value = 7;</code> + */ + public function getStringValue() + { + return $this->string_value; + } + + /** + * <code>optional bytes string_value = 7;</code> + */ + public function setStringValue($var) + { + GPBUtil::checkString($var, False); + $this->string_value = $var; + $this->has_string_value = true; + } + + public function hasStringValue() + { + return $this->has_string_value; + } + + /** + * <code>optional string aggregate_value = 8;</code> + */ + public function getAggregateValue() + { + return $this->aggregate_value; + } + + /** + * <code>optional string aggregate_value = 8;</code> + */ + public function setAggregateValue($var) + { + GPBUtil::checkString($var, True); + $this->aggregate_value = $var; + $this->has_aggregate_value = true; + } + + public function hasAggregateValue() + { + return $this->has_aggregate_value; + } + +} + diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php new file mode 100644 index 00000000..86484d23 --- /dev/null +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php @@ -0,0 +1,90 @@ +<?php +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/protobuf/descriptor.proto + +namespace Google\Protobuf\Internal; + +use Google\Protobuf\Internal\GPBType; +use Google\Protobuf\Internal\GPBWire; +use Google\Protobuf\Internal\RepeatedField; +use Google\Protobuf\Internal\InputStream; + +use Google\Protobuf\Internal\GPBUtil; + +/** + * <pre> + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + * </pre> + * + * Protobuf type <code>google.protobuf.UninterpretedOption.NamePart</code> + */ +class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message +{ + /** + * <code>required string name_part = 1;</code> + */ + private $name_part = ''; + private $has_name_part = false; + /** + * <code>required bool is_extension = 2;</code> + */ + private $is_extension = false; + private $has_is_extension = false; + + public function __construct() { + \GPBMetadata\Google\Protobuf\Internal\Descriptor::initOnce(); + parent::__construct(); + } + + /** + * <code>required string name_part = 1;</code> + */ + public function getNamePart() + { + return $this->name_part; + } + + /** + * <code>required string name_part = 1;</code> + */ + public function setNamePart($var) + { + GPBUtil::checkString($var, True); + $this->name_part = $var; + $this->has_name_part = true; + } + + public function hasNamePart() + { + return $this->has_name_part; + } + + /** + * <code>required bool is_extension = 2;</code> + */ + public function getIsExtension() + { + return $this->is_extension; + } + + /** + * <code>required bool is_extension = 2;</code> + */ + public function setIsExtension($var) + { + GPBUtil::checkBool($var); + $this->is_extension = $var; + $this->has_is_extension = true; + } + + public function hasIsExtension() + { + return $this->has_is_extension; + } + +} + diff --git a/php/src/Google/Protobuf/descriptor_internal.pb.php b/php/src/Google/Protobuf/descriptor_internal.pb.php deleted file mode 100644 index 161a9f52..00000000 --- a/php/src/Google/Protobuf/descriptor_internal.pb.php +++ /dev/null @@ -1,2532 +0,0 @@ -<?php -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/protobuf/descriptor.proto - -namespace Google\Protobuf\Internal; - -use Google\Protobuf\Internal\DescriptorPool; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\GPBWire; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\InputStream; - -use Google\Protobuf\Internal\GPBUtil; - -class FileDescriptorSet extends \Google\Protobuf\Internal\Message -{ - private $file; - private $has_file = false; - - public function getFile() - { - return $this->file; - } - - public function setFile(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FileDescriptorProto::class); - $this->file = $var; - $this->has_file = true; - } - - public function hasFile() - { - return $this->has_file; - } - -} - -class FileDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $package = ''; - private $has_package = false; - private $dependency; - private $has_dependency = false; - private $public_dependency; - private $has_public_dependency = false; - private $weak_dependency; - private $has_weak_dependency = false; - private $message_type; - private $has_message_type = false; - private $enum_type; - private $has_enum_type = false; - private $service; - private $has_service = false; - private $extension; - private $has_extension = false; - private $options = null; - private $has_options = false; - private $source_code_info = null; - private $has_source_code_info = false; - private $syntax = ''; - private $has_syntax = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getPackage() - { - return $this->package; - } - - public function setPackage($var) - { - GPBUtil::checkString($var, True); - $this->package = $var; - $this->has_package = true; - } - - public function hasPackage() - { - return $this->has_package; - } - - public function getDependency() - { - return $this->dependency; - } - - public function setDependency(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::STRING); - $this->dependency = $var; - $this->has_dependency = true; - } - - public function hasDependency() - { - return $this->has_dependency; - } - - public function getPublicDependency() - { - return $this->public_dependency; - } - - public function setPublicDependency(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->public_dependency = $var; - $this->has_public_dependency = true; - } - - public function hasPublicDependency() - { - return $this->has_public_dependency; - } - - public function getWeakDependency() - { - return $this->weak_dependency; - } - - public function setWeakDependency(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->weak_dependency = $var; - $this->has_weak_dependency = true; - } - - public function hasWeakDependency() - { - return $this->has_weak_dependency; - } - - public function getMessageType() - { - return $this->message_type; - } - - public function setMessageType(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); - $this->message_type = $var; - $this->has_message_type = true; - } - - public function hasMessageType() - { - return $this->has_message_type; - } - - public function getEnumType() - { - return $this->enum_type; - } - - public function setEnumType(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); - $this->enum_type = $var; - $this->has_enum_type = true; - } - - public function hasEnumType() - { - return $this->has_enum_type; - } - - public function getService() - { - return $this->service; - } - - public function setService(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\ServiceDescriptorProto::class); - $this->service = $var; - $this->has_service = true; - } - - public function hasService() - { - return $this->has_service; - } - - public function getExtension() - { - return $this->extension; - } - - public function setExtension(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); - $this->extension = $var; - $this->has_extension = true; - } - - public function hasExtension() - { - return $this->has_extension; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FileOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - - public function getSourceCodeInfo() - { - return $this->source_code_info; - } - - public function setSourceCodeInfo(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\SourceCodeInfo::class); - $this->source_code_info = $var; - $this->has_source_code_info = true; - } - - public function hasSourceCodeInfo() - { - return $this->has_source_code_info; - } - - public function getSyntax() - { - return $this->syntax; - } - - public function setSyntax($var) - { - GPBUtil::checkString($var, True); - $this->syntax = $var; - $this->has_syntax = true; - } - - public function hasSyntax() - { - return $this->has_syntax; - } - -} - -class DescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $field; - private $has_field = false; - private $extension; - private $has_extension = false; - private $nested_type; - private $has_nested_type = false; - private $enum_type; - private $has_enum_type = false; - private $extension_range; - private $has_extension_range = false; - private $oneof_decl; - private $has_oneof_decl = false; - private $options = null; - private $has_options = false; - private $reserved_range; - private $has_reserved_range = false; - private $reserved_name; - private $has_reserved_name = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getField() - { - return $this->field; - } - - public function setField(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); - $this->field = $var; - $this->has_field = true; - } - - public function hasField() - { - return $this->has_field; - } - - public function getExtension() - { - return $this->extension; - } - - public function setExtension(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\FieldDescriptorProto::class); - $this->extension = $var; - $this->has_extension = true; - } - - public function hasExtension() - { - return $this->has_extension; - } - - public function getNestedType() - { - return $this->nested_type; - } - - public function setNestedType(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto::class); - $this->nested_type = $var; - $this->has_nested_type = true; - } - - public function hasNestedType() - { - return $this->has_nested_type; - } - - public function getEnumType() - { - return $this->enum_type; - } - - public function setEnumType(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumDescriptorProto::class); - $this->enum_type = $var; - $this->has_enum_type = true; - } - - public function hasEnumType() - { - return $this->has_enum_type; - } - - public function getExtensionRange() - { - return $this->extension_range; - } - - public function setExtensionRange(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ExtensionRange::class); - $this->extension_range = $var; - $this->has_extension_range = true; - } - - public function hasExtensionRange() - { - return $this->has_extension_range; - } - - public function getOneofDecl() - { - return $this->oneof_decl; - } - - public function setOneofDecl(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\OneofDescriptorProto::class); - $this->oneof_decl = $var; - $this->has_oneof_decl = true; - } - - public function hasOneofDecl() - { - return $this->has_oneof_decl; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MessageOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - - public function getReservedRange() - { - return $this->reserved_range; - } - - public function setReservedRange(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\DescriptorProto_ReservedRange::class); - $this->reserved_range = $var; - $this->has_reserved_range = true; - } - - public function hasReservedRange() - { - return $this->has_reserved_range; - } - - public function getReservedName() - { - return $this->reserved_name; - } - - public function setReservedName(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::STRING); - $this->reserved_name = $var; - $this->has_reserved_name = true; - } - - public function hasReservedName() - { - return $this->has_reserved_name; - } - -} - -class DescriptorProto_ExtensionRange extends \Google\Protobuf\Internal\Message -{ - private $start = 0; - private $has_start = false; - private $end = 0; - private $has_end = false; - - public function getStart() - { - return $this->start; - } - - public function setStart($var) - { - GPBUtil::checkInt32($var); - $this->start = $var; - $this->has_start = true; - } - - public function hasStart() - { - return $this->has_start; - } - - public function getEnd() - { - return $this->end; - } - - public function setEnd($var) - { - GPBUtil::checkInt32($var); - $this->end = $var; - $this->has_end = true; - } - - public function hasEnd() - { - return $this->has_end; - } - -} - -class DescriptorProto_ReservedRange extends \Google\Protobuf\Internal\Message -{ - private $start = 0; - private $has_start = false; - private $end = 0; - private $has_end = false; - - public function getStart() - { - return $this->start; - } - - public function setStart($var) - { - GPBUtil::checkInt32($var); - $this->start = $var; - $this->has_start = true; - } - - public function hasStart() - { - return $this->has_start; - } - - public function getEnd() - { - return $this->end; - } - - public function setEnd($var) - { - GPBUtil::checkInt32($var); - $this->end = $var; - $this->has_end = true; - } - - public function hasEnd() - { - return $this->has_end; - } - -} - -class FieldDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $number = 0; - private $has_number = false; - private $label = 0; - private $has_label = false; - private $type = 0; - private $has_type = false; - private $type_name = ''; - private $has_type_name = false; - private $extendee = ''; - private $has_extendee = false; - private $default_value = ''; - private $has_default_value = false; - private $oneof_index = 0; - private $has_oneof_index = false; - private $json_name = ''; - private $has_json_name = false; - private $options = null; - private $has_options = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getNumber() - { - return $this->number; - } - - public function setNumber($var) - { - GPBUtil::checkInt32($var); - $this->number = $var; - $this->has_number = true; - } - - public function hasNumber() - { - return $this->has_number; - } - - public function getLabel() - { - return $this->label; - } - - public function setLabel($var) - { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Label::class); - $this->label = $var; - $this->has_label = true; - } - - public function hasLabel() - { - return $this->has_label; - } - - public function getType() - { - return $this->type; - } - - public function setType($var) - { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldDescriptorProto_Type::class); - $this->type = $var; - $this->has_type = true; - } - - public function hasType() - { - return $this->has_type; - } - - public function getTypeName() - { - return $this->type_name; - } - - public function setTypeName($var) - { - GPBUtil::checkString($var, True); - $this->type_name = $var; - $this->has_type_name = true; - } - - public function hasTypeName() - { - return $this->has_type_name; - } - - public function getExtendee() - { - return $this->extendee; - } - - public function setExtendee($var) - { - GPBUtil::checkString($var, True); - $this->extendee = $var; - $this->has_extendee = true; - } - - public function hasExtendee() - { - return $this->has_extendee; - } - - public function getDefaultValue() - { - return $this->default_value; - } - - public function setDefaultValue($var) - { - GPBUtil::checkString($var, True); - $this->default_value = $var; - $this->has_default_value = true; - } - - public function hasDefaultValue() - { - return $this->has_default_value; - } - - public function getOneofIndex() - { - return $this->oneof_index; - } - - public function setOneofIndex($var) - { - GPBUtil::checkInt32($var); - $this->oneof_index = $var; - $this->has_oneof_index = true; - } - - public function hasOneofIndex() - { - return $this->has_oneof_index; - } - - public function getJsonName() - { - return $this->json_name; - } - - public function setJsonName($var) - { - GPBUtil::checkString($var, True); - $this->json_name = $var; - $this->has_json_name = true; - } - - public function hasJsonName() - { - return $this->has_json_name; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\FieldOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - -} - -class FieldDescriptorProto_Type -{ - const TYPE_DOUBLE = 1; - const TYPE_FLOAT = 2; - const TYPE_INT64 = 3; - const TYPE_UINT64 = 4; - const TYPE_INT32 = 5; - const TYPE_FIXED64 = 6; - const TYPE_FIXED32 = 7; - const TYPE_BOOL = 8; - const TYPE_STRING = 9; - const TYPE_GROUP = 10; - const TYPE_MESSAGE = 11; - const TYPE_BYTES = 12; - const TYPE_UINT32 = 13; - const TYPE_ENUM = 14; - const TYPE_SFIXED32 = 15; - const TYPE_SFIXED64 = 16; - const TYPE_SINT32 = 17; - const TYPE_SINT64 = 18; -} - -class FieldDescriptorProto_Label -{ - const LABEL_OPTIONAL = 1; - const LABEL_REQUIRED = 2; - const LABEL_REPEATED = 3; -} - -class OneofDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $options = null; - private $has_options = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\OneofOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - -} - -class EnumDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $value; - private $has_value = false; - private $options = null; - private $has_options = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getValue() - { - return $this->value; - } - - public function setValue(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class); - $this->value = $var; - $this->has_value = true; - } - - public function hasValue() - { - return $this->has_value; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - -} - -class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $number = 0; - private $has_number = false; - private $options = null; - private $has_options = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getNumber() - { - return $this->number; - } - - public function setNumber($var) - { - GPBUtil::checkInt32($var); - $this->number = $var; - $this->has_number = true; - } - - public function hasNumber() - { - return $this->has_number; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\EnumValueOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - -} - -class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $method; - private $has_method = false; - private $options = null; - private $has_options = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getMethod() - { - return $this->method; - } - - public function setMethod(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\MethodDescriptorProto::class); - $this->method = $var; - $this->has_method = true; - } - - public function hasMethod() - { - return $this->has_method; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\ServiceOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - -} - -class MethodDescriptorProto extends \Google\Protobuf\Internal\Message -{ - private $name = ''; - private $has_name = false; - private $input_type = ''; - private $has_input_type = false; - private $output_type = ''; - private $has_output_type = false; - private $options = null; - private $has_options = false; - private $client_streaming = false; - private $has_client_streaming = false; - private $server_streaming = false; - private $has_server_streaming = false; - - public function getName() - { - return $this->name; - } - - public function setName($var) - { - GPBUtil::checkString($var, True); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getInputType() - { - return $this->input_type; - } - - public function setInputType($var) - { - GPBUtil::checkString($var, True); - $this->input_type = $var; - $this->has_input_type = true; - } - - public function hasInputType() - { - return $this->has_input_type; - } - - public function getOutputType() - { - return $this->output_type; - } - - public function setOutputType($var) - { - GPBUtil::checkString($var, True); - $this->output_type = $var; - $this->has_output_type = true; - } - - public function hasOutputType() - { - return $this->has_output_type; - } - - public function getOptions() - { - return $this->options; - } - - public function setOptions(&$var) - { - GPBUtil::checkMessage($var, \Google\Protobuf\Internal\MethodOptions::class); - $this->options = $var; - $this->has_options = true; - } - - public function hasOptions() - { - return $this->has_options; - } - - public function getClientStreaming() - { - return $this->client_streaming; - } - - public function setClientStreaming($var) - { - GPBUtil::checkBool($var); - $this->client_streaming = $var; - $this->has_client_streaming = true; - } - - public function hasClientStreaming() - { - return $this->has_client_streaming; - } - - public function getServerStreaming() - { - return $this->server_streaming; - } - - public function setServerStreaming($var) - { - GPBUtil::checkBool($var); - $this->server_streaming = $var; - $this->has_server_streaming = true; - } - - public function hasServerStreaming() - { - return $this->has_server_streaming; - } - -} - -class FileOptions extends \Google\Protobuf\Internal\Message -{ - private $java_package = ''; - private $has_java_package = false; - private $java_outer_classname = ''; - private $has_java_outer_classname = false; - private $java_multiple_files = false; - private $has_java_multiple_files = false; - private $java_generate_equals_and_hash = false; - private $has_java_generate_equals_and_hash = false; - private $java_string_check_utf8 = false; - private $has_java_string_check_utf8 = false; - private $optimize_for = 0; - private $has_optimize_for = false; - private $go_package = ''; - private $has_go_package = false; - private $cc_generic_services = false; - private $has_cc_generic_services = false; - private $java_generic_services = false; - private $has_java_generic_services = false; - private $py_generic_services = false; - private $has_py_generic_services = false; - private $deprecated = false; - private $has_deprecated = false; - private $cc_enable_arenas = false; - private $has_cc_enable_arenas = false; - private $objc_class_prefix = ''; - private $has_objc_class_prefix = false; - private $csharp_namespace = ''; - private $has_csharp_namespace = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getJavaPackage() - { - return $this->java_package; - } - - public function setJavaPackage($var) - { - GPBUtil::checkString($var, True); - $this->java_package = $var; - $this->has_java_package = true; - } - - public function hasJavaPackage() - { - return $this->has_java_package; - } - - public function getJavaOuterClassname() - { - return $this->java_outer_classname; - } - - public function setJavaOuterClassname($var) - { - GPBUtil::checkString($var, True); - $this->java_outer_classname = $var; - $this->has_java_outer_classname = true; - } - - public function hasJavaOuterClassname() - { - return $this->has_java_outer_classname; - } - - public function getJavaMultipleFiles() - { - return $this->java_multiple_files; - } - - public function setJavaMultipleFiles($var) - { - GPBUtil::checkBool($var); - $this->java_multiple_files = $var; - $this->has_java_multiple_files = true; - } - - public function hasJavaMultipleFiles() - { - return $this->has_java_multiple_files; - } - - public function getJavaGenerateEqualsAndHash() - { - return $this->java_generate_equals_and_hash; - } - - public function setJavaGenerateEqualsAndHash($var) - { - GPBUtil::checkBool($var); - $this->java_generate_equals_and_hash = $var; - $this->has_java_generate_equals_and_hash = true; - } - - public function hasJavaGenerateEqualsAndHash() - { - return $this->has_java_generate_equals_and_hash; - } - - public function getJavaStringCheckUtf8() - { - return $this->java_string_check_utf8; - } - - public function setJavaStringCheckUtf8($var) - { - GPBUtil::checkBool($var); - $this->java_string_check_utf8 = $var; - $this->has_java_string_check_utf8 = true; - } - - public function hasJavaStringCheckUtf8() - { - return $this->has_java_string_check_utf8; - } - - public function getOptimizeFor() - { - return $this->optimize_for; - } - - public function setOptimizeFor($var) - { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FileOptions_OptimizeMode::class); - $this->optimize_for = $var; - $this->has_optimize_for = true; - } - - public function hasOptimizeFor() - { - return $this->has_optimize_for; - } - - public function getGoPackage() - { - return $this->go_package; - } - - public function setGoPackage($var) - { - GPBUtil::checkString($var, True); - $this->go_package = $var; - $this->has_go_package = true; - } - - public function hasGoPackage() - { - return $this->has_go_package; - } - - public function getCcGenericServices() - { - return $this->cc_generic_services; - } - - public function setCcGenericServices($var) - { - GPBUtil::checkBool($var); - $this->cc_generic_services = $var; - $this->has_cc_generic_services = true; - } - - public function hasCcGenericServices() - { - return $this->has_cc_generic_services; - } - - public function getJavaGenericServices() - { - return $this->java_generic_services; - } - - public function setJavaGenericServices($var) - { - GPBUtil::checkBool($var); - $this->java_generic_services = $var; - $this->has_java_generic_services = true; - } - - public function hasJavaGenericServices() - { - return $this->has_java_generic_services; - } - - public function getPyGenericServices() - { - return $this->py_generic_services; - } - - public function setPyGenericServices($var) - { - GPBUtil::checkBool($var); - $this->py_generic_services = $var; - $this->has_py_generic_services = true; - } - - public function hasPyGenericServices() - { - return $this->has_py_generic_services; - } - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getCcEnableArenas() - { - return $this->cc_enable_arenas; - } - - public function setCcEnableArenas($var) - { - GPBUtil::checkBool($var); - $this->cc_enable_arenas = $var; - $this->has_cc_enable_arenas = true; - } - - public function hasCcEnableArenas() - { - return $this->has_cc_enable_arenas; - } - - public function getObjcClassPrefix() - { - return $this->objc_class_prefix; - } - - public function setObjcClassPrefix($var) - { - GPBUtil::checkString($var, True); - $this->objc_class_prefix = $var; - $this->has_objc_class_prefix = true; - } - - public function hasObjcClassPrefix() - { - return $this->has_objc_class_prefix; - } - - public function getCsharpNamespace() - { - return $this->csharp_namespace; - } - - public function setCsharpNamespace($var) - { - GPBUtil::checkString($var, True); - $this->csharp_namespace = $var; - $this->has_csharp_namespace = true; - } - - public function hasCsharpNamespace() - { - return $this->has_csharp_namespace; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class FileOptions_OptimizeMode -{ - const SPEED = 1; - const CODE_SIZE = 2; - const LITE_RUNTIME = 3; -} - -class MessageOptions extends \Google\Protobuf\Internal\Message -{ - private $message_set_wire_format = false; - private $has_message_set_wire_format = false; - private $no_standard_descriptor_accessor = false; - private $has_no_standard_descriptor_accessor = false; - private $deprecated = false; - private $has_deprecated = false; - private $map_entry = false; - private $has_map_entry = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getMessageSetWireFormat() - { - return $this->message_set_wire_format; - } - - public function setMessageSetWireFormat($var) - { - GPBUtil::checkBool($var); - $this->message_set_wire_format = $var; - $this->has_message_set_wire_format = true; - } - - public function hasMessageSetWireFormat() - { - return $this->has_message_set_wire_format; - } - - public function getNoStandardDescriptorAccessor() - { - return $this->no_standard_descriptor_accessor; - } - - public function setNoStandardDescriptorAccessor($var) - { - GPBUtil::checkBool($var); - $this->no_standard_descriptor_accessor = $var; - $this->has_no_standard_descriptor_accessor = true; - } - - public function hasNoStandardDescriptorAccessor() - { - return $this->has_no_standard_descriptor_accessor; - } - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getMapEntry() - { - return $this->map_entry; - } - - public function setMapEntry($var) - { - GPBUtil::checkBool($var); - $this->map_entry = $var; - $this->has_map_entry = true; - } - - public function hasMapEntry() - { - return $this->has_map_entry; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class FieldOptions extends \Google\Protobuf\Internal\Message -{ - private $ctype = 0; - private $has_ctype = false; - private $packed = false; - private $has_packed = false; - private $jstype = 0; - private $has_jstype = false; - private $lazy = false; - private $has_lazy = false; - private $deprecated = false; - private $has_deprecated = false; - private $weak = false; - private $has_weak = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getCtype() - { - return $this->ctype; - } - - public function setCtype($var) - { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_CType::class); - $this->ctype = $var; - $this->has_ctype = true; - } - - public function hasCtype() - { - return $this->has_ctype; - } - - public function getPacked() - { - return $this->packed; - } - - public function setPacked($var) - { - GPBUtil::checkBool($var); - $this->packed = $var; - $this->has_packed = true; - } - - public function hasPacked() - { - return $this->has_packed; - } - - public function getJstype() - { - return $this->jstype; - } - - public function setJstype($var) - { - GPBUtil::checkEnum($var, \Google\Protobuf\Internal\FieldOptions_JSType::class); - $this->jstype = $var; - $this->has_jstype = true; - } - - public function hasJstype() - { - return $this->has_jstype; - } - - public function getLazy() - { - return $this->lazy; - } - - public function setLazy($var) - { - GPBUtil::checkBool($var); - $this->lazy = $var; - $this->has_lazy = true; - } - - public function hasLazy() - { - return $this->has_lazy; - } - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getWeak() - { - return $this->weak; - } - - public function setWeak($var) - { - GPBUtil::checkBool($var); - $this->weak = $var; - $this->has_weak = true; - } - - public function hasWeak() - { - return $this->has_weak; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class FieldOptions_CType -{ - const STRING = 0; - const CORD = 1; - const STRING_PIECE = 2; -} - -class FieldOptions_JSType -{ - const JS_NORMAL = 0; - const JS_STRING = 1; - const JS_NUMBER = 2; -} - -class OneofOptions extends \Google\Protobuf\Internal\Message -{ - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class EnumOptions extends \Google\Protobuf\Internal\Message -{ - private $allow_alias = false; - private $has_allow_alias = false; - private $deprecated = false; - private $has_deprecated = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getAllowAlias() - { - return $this->allow_alias; - } - - public function setAllowAlias($var) - { - GPBUtil::checkBool($var); - $this->allow_alias = $var; - $this->has_allow_alias = true; - } - - public function hasAllowAlias() - { - return $this->has_allow_alias; - } - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class EnumValueOptions extends \Google\Protobuf\Internal\Message -{ - private $deprecated = false; - private $has_deprecated = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class ServiceOptions extends \Google\Protobuf\Internal\Message -{ - private $deprecated = false; - private $has_deprecated = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class MethodOptions extends \Google\Protobuf\Internal\Message -{ - private $deprecated = false; - private $has_deprecated = false; - private $uninterpreted_option; - private $has_uninterpreted_option = false; - - public function getDeprecated() - { - return $this->deprecated; - } - - public function setDeprecated($var) - { - GPBUtil::checkBool($var); - $this->deprecated = $var; - $this->has_deprecated = true; - } - - public function hasDeprecated() - { - return $this->has_deprecated; - } - - public function getUninterpretedOption() - { - return $this->uninterpreted_option; - } - - public function setUninterpretedOption(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption::class); - $this->uninterpreted_option = $var; - $this->has_uninterpreted_option = true; - } - - public function hasUninterpretedOption() - { - return $this->has_uninterpreted_option; - } - -} - -class UninterpretedOption extends \Google\Protobuf\Internal\Message -{ - private $name; - private $has_name = false; - private $identifier_value = ''; - private $has_identifier_value = false; - private $positive_int_value = 0; - private $has_positive_int_value = false; - private $negative_int_value = 0; - private $has_negative_int_value = false; - private $double_value = 0.0; - private $has_double_value = false; - private $string_value = ''; - private $has_string_value = false; - private $aggregate_value = ''; - private $has_aggregate_value = false; - - public function getName() - { - return $this->name; - } - - public function setName(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\UninterpretedOption_NamePart::class); - $this->name = $var; - $this->has_name = true; - } - - public function hasName() - { - return $this->has_name; - } - - public function getIdentifierValue() - { - return $this->identifier_value; - } - - public function setIdentifierValue($var) - { - GPBUtil::checkString($var, True); - $this->identifier_value = $var; - $this->has_identifier_value = true; - } - - public function hasIdentifierValue() - { - return $this->has_identifier_value; - } - - public function getPositiveIntValue() - { - return $this->positive_int_value; - } - - public function setPositiveIntValue($var) - { - GPBUtil::checkUint64($var); - $this->positive_int_value = $var; - $this->has_positive_int_value = true; - } - - public function hasPositiveIntValue() - { - return $this->has_positive_int_value; - } - - public function getNegativeIntValue() - { - return $this->negative_int_value; - } - - public function setNegativeIntValue($var) - { - GPBUtil::checkInt64($var); - $this->negative_int_value = $var; - $this->has_negative_int_value = true; - } - - public function hasNegativeIntValue() - { - return $this->has_negative_int_value; - } - - public function getDoubleValue() - { - return $this->double_value; - } - - public function setDoubleValue($var) - { - GPBUtil::checkDouble($var); - $this->double_value = $var; - $this->has_double_value = true; - } - - public function hasDoubleValue() - { - return $this->has_double_value; - } - - public function getStringValue() - { - return $this->string_value; - } - - public function setStringValue($var) - { - GPBUtil::checkString($var, False); - $this->string_value = $var; - $this->has_string_value = true; - } - - public function hasStringValue() - { - return $this->has_string_value; - } - - public function getAggregateValue() - { - return $this->aggregate_value; - } - - public function setAggregateValue($var) - { - GPBUtil::checkString($var, True); - $this->aggregate_value = $var; - $this->has_aggregate_value = true; - } - - public function hasAggregateValue() - { - return $this->has_aggregate_value; - } - -} - -class UninterpretedOption_NamePart extends \Google\Protobuf\Internal\Message -{ - private $name_part = ''; - private $has_name_part = false; - private $is_extension = false; - private $has_is_extension = false; - - public function getNamePart() - { - return $this->name_part; - } - - public function setNamePart($var) - { - GPBUtil::checkString($var, True); - $this->name_part = $var; - $this->has_name_part = true; - } - - public function hasNamePart() - { - return $this->has_name_part; - } - - public function getIsExtension() - { - return $this->is_extension; - } - - public function setIsExtension($var) - { - GPBUtil::checkBool($var); - $this->is_extension = $var; - $this->has_is_extension = true; - } - - public function hasIsExtension() - { - return $this->has_is_extension; - } - -} - -class SourceCodeInfo extends \Google\Protobuf\Internal\Message -{ - private $location; - private $has_location = false; - - public function getLocation() - { - return $this->location; - } - - public function setLocation(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\SourceCodeInfo_Location::class); - $this->location = $var; - $this->has_location = true; - } - - public function hasLocation() - { - return $this->has_location; - } - -} - -class SourceCodeInfo_Location extends \Google\Protobuf\Internal\Message -{ - private $path; - private $has_path = false; - private $span; - private $has_span = false; - private $leading_comments = ''; - private $has_leading_comments = false; - private $trailing_comments = ''; - private $has_trailing_comments = false; - private $leading_detached_comments; - private $has_leading_detached_comments = false; - - public function getPath() - { - return $this->path; - } - - public function setPath(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->path = $var; - $this->has_path = true; - } - - public function hasPath() - { - return $this->has_path; - } - - public function getSpan() - { - return $this->span; - } - - public function setSpan(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->span = $var; - $this->has_span = true; - } - - public function hasSpan() - { - return $this->has_span; - } - - public function getLeadingComments() - { - return $this->leading_comments; - } - - public function setLeadingComments($var) - { - GPBUtil::checkString($var, True); - $this->leading_comments = $var; - $this->has_leading_comments = true; - } - - public function hasLeadingComments() - { - return $this->has_leading_comments; - } - - public function getTrailingComments() - { - return $this->trailing_comments; - } - - public function setTrailingComments($var) - { - GPBUtil::checkString($var, True); - $this->trailing_comments = $var; - $this->has_trailing_comments = true; - } - - public function hasTrailingComments() - { - return $this->has_trailing_comments; - } - - public function getLeadingDetachedComments() - { - return $this->leading_detached_comments; - } - - public function setLeadingDetachedComments(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::STRING); - $this->leading_detached_comments = $var; - $this->has_leading_detached_comments = true; - } - - public function hasLeadingDetachedComments() - { - return $this->has_leading_detached_comments; - } - -} - -class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message -{ - private $annotation; - private $has_annotation = false; - - public function getAnnotation() - { - return $this->annotation; - } - - public function setAnnotation(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Google\Protobuf\Internal\GeneratedCodeInfo_Annotation::class); - $this->annotation = $var; - $this->has_annotation = true; - } - - public function hasAnnotation() - { - return $this->has_annotation; - } - -} - -class GeneratedCodeInfo_Annotation extends \Google\Protobuf\Internal\Message -{ - private $path; - private $has_path = false; - private $source_file = ''; - private $has_source_file = false; - private $begin = 0; - private $has_begin = false; - private $end = 0; - private $has_end = false; - - public function getPath() - { - return $this->path; - } - - public function setPath(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->path = $var; - $this->has_path = true; - } - - public function hasPath() - { - return $this->has_path; - } - - public function getSourceFile() - { - return $this->source_file; - } - - public function setSourceFile($var) - { - GPBUtil::checkString($var, True); - $this->source_file = $var; - $this->has_source_file = true; - } - - public function hasSourceFile() - { - return $this->has_source_file; - } - - public function getBegin() - { - return $this->begin; - } - - public function setBegin($var) - { - GPBUtil::checkInt32($var); - $this->begin = $var; - $this->has_begin = true; - } - - public function hasBegin() - { - return $this->has_begin; - } - - public function getEnd() - { - return $this->end; - } - - public function setEnd($var) - { - GPBUtil::checkInt32($var); - $this->end = $var; - $this->has_end = true; - } - - public function hasEnd() - { - return $this->has_end; - } - -} - -$pool = DescriptorPool::getGeneratedPool(); - -$pool->addMessage('google.protobuf.internal.FileDescriptorSet', FileDescriptorSet::class) - ->repeated('file', GPBType::MESSAGE, 1, 'google.protobuf.internal.FileDescriptorProto') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.FileDescriptorProto', FileDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->optional('package', GPBType::STRING, 2) - ->repeated('dependency', GPBType::STRING, 3) - ->repeated('public_dependency', GPBType::INT32, 10) - ->repeated('weak_dependency', GPBType::INT32, 11) - ->repeated('message_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.DescriptorProto') - ->repeated('enum_type', GPBType::MESSAGE, 5, 'google.protobuf.internal.EnumDescriptorProto') - ->repeated('service', GPBType::MESSAGE, 6, 'google.protobuf.internal.ServiceDescriptorProto') - ->repeated('extension', GPBType::MESSAGE, 7, 'google.protobuf.internal.FieldDescriptorProto') - ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FileOptions') - ->optional('source_code_info', GPBType::MESSAGE, 9, 'google.protobuf.internal.SourceCodeInfo') - ->optional('syntax', GPBType::STRING, 12) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.DescriptorProto', DescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->repeated('field', GPBType::MESSAGE, 2, 'google.protobuf.internal.FieldDescriptorProto') - ->repeated('extension', GPBType::MESSAGE, 6, 'google.protobuf.internal.FieldDescriptorProto') - ->repeated('nested_type', GPBType::MESSAGE, 3, 'google.protobuf.internal.DescriptorProto') - ->repeated('enum_type', GPBType::MESSAGE, 4, 'google.protobuf.internal.EnumDescriptorProto') - ->repeated('extension_range', GPBType::MESSAGE, 5, 'google.protobuf.internal.DescriptorProto.ExtensionRange') - ->repeated('oneof_decl', GPBType::MESSAGE, 8, 'google.protobuf.internal.OneofDescriptorProto') - ->optional('options', GPBType::MESSAGE, 7, 'google.protobuf.internal.MessageOptions') - ->repeated('reserved_range', GPBType::MESSAGE, 9, 'google.protobuf.internal.DescriptorProto.ReservedRange') - ->repeated('reserved_name', GPBType::STRING, 10) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.DescriptorProto.ExtensionRange', DescriptorProto_ExtensionRange::class) - ->optional('start', GPBType::INT32, 1) - ->optional('end', GPBType::INT32, 2) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.DescriptorProto.ReservedRange', DescriptorProto_ReservedRange::class) - ->optional('start', GPBType::INT32, 1) - ->optional('end', GPBType::INT32, 2) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.FieldDescriptorProto', FieldDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->optional('number', GPBType::INT32, 3) - ->optional('label', GPBType::ENUM, 4, 'google.protobuf.internal.FieldDescriptorProto.Label') - ->optional('type', GPBType::ENUM, 5, 'google.protobuf.internal.FieldDescriptorProto.Type') - ->optional('type_name', GPBType::STRING, 6) - ->optional('extendee', GPBType::STRING, 2) - ->optional('default_value', GPBType::STRING, 7) - ->optional('oneof_index', GPBType::INT32, 9) - ->optional('json_name', GPBType::STRING, 10) - ->optional('options', GPBType::MESSAGE, 8, 'google.protobuf.internal.FieldOptions') - ->finalizeToPool(); - -$pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Type', Type::class) - ->value("TYPE_DOUBLE", 1) - ->value("TYPE_FLOAT", 2) - ->value("TYPE_INT64", 3) - ->value("TYPE_UINT64", 4) - ->value("TYPE_INT32", 5) - ->value("TYPE_FIXED64", 6) - ->value("TYPE_FIXED32", 7) - ->value("TYPE_BOOL", 8) - ->value("TYPE_STRING", 9) - ->value("TYPE_GROUP", 10) - ->value("TYPE_MESSAGE", 11) - ->value("TYPE_BYTES", 12) - ->value("TYPE_UINT32", 13) - ->value("TYPE_ENUM", 14) - ->value("TYPE_SFIXED32", 15) - ->value("TYPE_SFIXED64", 16) - ->value("TYPE_SINT32", 17) - ->value("TYPE_SINT64", 18) - ->finalizeToPool(); - -$pool->addEnum('google.protobuf.internal.FieldDescriptorProto.Label', Label::class) - ->value("LABEL_OPTIONAL", 1) - ->value("LABEL_REQUIRED", 2) - ->value("LABEL_REPEATED", 3) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.OneofDescriptorProto', OneofDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->optional('options', GPBType::MESSAGE, 2, 'google.protobuf.internal.OneofOptions') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.EnumDescriptorProto', EnumDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->repeated('value', GPBType::MESSAGE, 2, 'google.protobuf.internal.EnumValueDescriptorProto') - ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumOptions') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.EnumValueDescriptorProto', EnumValueDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->optional('number', GPBType::INT32, 2) - ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.EnumValueOptions') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.ServiceDescriptorProto', ServiceDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->repeated('method', GPBType::MESSAGE, 2, 'google.protobuf.internal.MethodDescriptorProto') - ->optional('options', GPBType::MESSAGE, 3, 'google.protobuf.internal.ServiceOptions') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.MethodDescriptorProto', MethodDescriptorProto::class) - ->optional('name', GPBType::STRING, 1) - ->optional('input_type', GPBType::STRING, 2) - ->optional('output_type', GPBType::STRING, 3) - ->optional('options', GPBType::MESSAGE, 4, 'google.protobuf.internal.MethodOptions') - ->optional('client_streaming', GPBType::BOOL, 5) - ->optional('server_streaming', GPBType::BOOL, 6) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.FileOptions', FileOptions::class) - ->optional('java_package', GPBType::STRING, 1) - ->optional('java_outer_classname', GPBType::STRING, 8) - ->optional('java_multiple_files', GPBType::BOOL, 10) - ->optional('java_generate_equals_and_hash', GPBType::BOOL, 20) - ->optional('java_string_check_utf8', GPBType::BOOL, 27) - ->optional('optimize_for', GPBType::ENUM, 9, 'google.protobuf.internal.FileOptions.OptimizeMode') - ->optional('go_package', GPBType::STRING, 11) - ->optional('cc_generic_services', GPBType::BOOL, 16) - ->optional('java_generic_services', GPBType::BOOL, 17) - ->optional('py_generic_services', GPBType::BOOL, 18) - ->optional('deprecated', GPBType::BOOL, 23) - ->optional('cc_enable_arenas', GPBType::BOOL, 31) - ->optional('objc_class_prefix', GPBType::STRING, 36) - ->optional('csharp_namespace', GPBType::STRING, 37) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addEnum('google.protobuf.internal.FileOptions.OptimizeMode', OptimizeMode::class) - ->value("SPEED", 1) - ->value("CODE_SIZE", 2) - ->value("LITE_RUNTIME", 3) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.MessageOptions', MessageOptions::class) - ->optional('message_set_wire_format', GPBType::BOOL, 1) - ->optional('no_standard_descriptor_accessor', GPBType::BOOL, 2) - ->optional('deprecated', GPBType::BOOL, 3) - ->optional('map_entry', GPBType::BOOL, 7) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.FieldOptions', FieldOptions::class) - ->optional('ctype', GPBType::ENUM, 1, 'google.protobuf.internal.FieldOptions.CType') - ->optional('packed', GPBType::BOOL, 2) - ->optional('jstype', GPBType::ENUM, 6, 'google.protobuf.internal.FieldOptions.JSType') - ->optional('lazy', GPBType::BOOL, 5) - ->optional('deprecated', GPBType::BOOL, 3) - ->optional('weak', GPBType::BOOL, 10) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addEnum('google.protobuf.internal.FieldOptions.CType', CType::class) - ->value("STRING", 0) - ->value("CORD", 1) - ->value("STRING_PIECE", 2) - ->finalizeToPool(); - -$pool->addEnum('google.protobuf.internal.FieldOptions.JSType', JSType::class) - ->value("JS_NORMAL", 0) - ->value("JS_STRING", 1) - ->value("JS_NUMBER", 2) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.OneofOptions', OneofOptions::class) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.EnumOptions', EnumOptions::class) - ->optional('allow_alias', GPBType::BOOL, 2) - ->optional('deprecated', GPBType::BOOL, 3) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.EnumValueOptions', EnumValueOptions::class) - ->optional('deprecated', GPBType::BOOL, 1) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.ServiceOptions', ServiceOptions::class) - ->optional('deprecated', GPBType::BOOL, 33) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.MethodOptions', MethodOptions::class) - ->optional('deprecated', GPBType::BOOL, 33) - ->repeated('uninterpreted_option', GPBType::MESSAGE, 999, 'google.protobuf.internal.UninterpretedOption') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.UninterpretedOption', UninterpretedOption::class) - ->repeated('name', GPBType::MESSAGE, 2, 'google.protobuf.internal.UninterpretedOption.NamePart') - ->optional('identifier_value', GPBType::STRING, 3) - ->optional('positive_int_value', GPBType::UINT64, 4) - ->optional('negative_int_value', GPBType::INT64, 5) - ->optional('double_value', GPBType::DOUBLE, 6) - ->optional('string_value', GPBType::BYTES, 7) - ->optional('aggregate_value', GPBType::STRING, 8) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.UninterpretedOption.NamePart', UninterpretedOption_NamePart::class) - ->required('name_part', GPBType::STRING, 1) - ->required('is_extension', GPBType::BOOL, 2) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.SourceCodeInfo', SourceCodeInfo::class) - ->repeated('location', GPBType::MESSAGE, 1, 'google.protobuf.internal.SourceCodeInfo.Location') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.SourceCodeInfo.Location', SourceCodeInfo_Location::class) - ->repeated('path', GPBType::INT32, 1) - ->repeated('span', GPBType::INT32, 2) - ->optional('leading_comments', GPBType::STRING, 3) - ->optional('trailing_comments', GPBType::STRING, 4) - ->repeated('leading_detached_comments', GPBType::STRING, 6) - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.GeneratedCodeInfo', GeneratedCodeInfo::class) - ->repeated('annotation', GPBType::MESSAGE, 1, 'google.protobuf.internal.GeneratedCodeInfo.Annotation') - ->finalizeToPool(); - -$pool->addMessage('google.protobuf.internal.GeneratedCodeInfo.Annotation', GeneratedCodeInfo_Annotation::class) - ->repeated('path', GPBType::INT32, 1) - ->optional('source_file', GPBType::STRING, 2) - ->optional('begin', GPBType::INT32, 3) - ->optional('end', GPBType::INT32, 4) - ->finalizeToPool(); - -$pool->finish(); diff --git a/php/tests/array_test.php b/php/tests/array_test.php index a79a08bc..a4cad719 100644 --- a/php/tests/array_test.php +++ b/php/tests/array_test.php @@ -1,6 +1,5 @@ <?php -require_once('test.pb.php'); require_once('test_util.php'); use Google\Protobuf\Internal\RepeatedField; diff --git a/php/tests/autoload.php b/php/tests/autoload.php new file mode 100755 index 00000000..0a917fc5 --- /dev/null +++ b/php/tests/autoload.php @@ -0,0 +1,25 @@ +<?php + +function getGeneratedFiles($dir, &$results = array()) +{ + $files = scandir($dir); + + foreach ($files as $key => $value) { + $path = realpath($dir.DIRECTORY_SEPARATOR.$value); + if (!is_dir($path)) { + $results[] = $path; + } else if ($value != "." && $value != "..") { + getGeneratedFiles($path, $results); + } + } + return $results; +} + +foreach (getGeneratedFiles("generated") as $filename) +{ + if (!is_dir($filename)) { + include_once $filename; + } + +} + diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index d07907c0..af9c0415 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -1,6 +1,5 @@ <?php -require_once('test.pb.php'); require_once('test_base.php'); require_once('test_util.php'); diff --git a/php/tests/gdb_test.sh b/php/tests/gdb_test.sh new file mode 100755 index 00000000..3c0d97a2 --- /dev/null +++ b/php/tests/gdb_test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which +# phpunit` --bootstrap autoload.php tmp_test.php +# +gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php encode_decode_test.php +# +# # gdb --args php -dextension=../ext/google/protobuf/modules/protobuf.so +# memory_leak_test.php +# +# # USE_ZEND_ALLOC=0 valgrind --leak-check=yes php +# -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php index b3ecd3a1..27912ecd 100644 --- a/php/tests/generated_class_test.php +++ b/php/tests/generated_class_test.php @@ -1,7 +1,6 @@ <?php -require_once('test.pb.php'); -require_once('test_no_namespace.pb.php'); +require_once('generated/NoNameSpace.php'); require_once('test_util.php'); use Google\Protobuf\Internal\RepeatedField; diff --git a/php/tests/google/protobuf/empty.pb.php b/php/tests/google/protobuf/empty.pb.php deleted file mode 100644 index fdd0fe4f..00000000 --- a/php/tests/google/protobuf/empty.pb.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/protobuf/empty.proto - -namespace Google\Protobuf; - -use Google\Protobuf\Internal\DescriptorPool; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBUtil; - -class GPBEmpty extends \Google\Protobuf\Internal\Message -{ - -} - -$pool = DescriptorPool::getGeneratedPool(); - -$pool->internalAddGeneratedFile(hex2bin( - "0ab7010a1b676f6f676c652f70726f746f6275662f656d7074792e70726f" . - "746f120f676f6f676c652e70726f746f62756622070a05456d7074794276" . - "0a13636f6d2e676f6f676c652e70726f746f627566420a456d7074795072" . - "6f746f50015a276769746875622e636f6d2f676f6c616e672f70726f746f" . - "6275662f7074797065732f656d707479f80101a20203475042aa021e476f" . - "6f676c652e50726f746f6275662e57656c6c4b6e6f776e54797065736206" . - "70726f746f33" -)); - diff --git a/php/tests/map_field_test.php b/php/tests/map_field_test.php index 4e42361d..d4ec44fc 100644 --- a/php/tests/map_field_test.php +++ b/php/tests/map_field_test.php @@ -1,6 +1,5 @@ <?php -require_once('test.pb.php'); require_once('test_util.php'); use Google\Protobuf\Internal\GPBType; diff --git a/php/tests/memory_leak_test.php b/php/tests/memory_leak_test.php index ec54597b..af327273 100644 --- a/php/tests/memory_leak_test.php +++ b/php/tests/memory_leak_test.php @@ -2,7 +2,15 @@ # phpunit has memory leak by itself. Thus, it cannot be used to test memory leak. -require_once('test.pb.php'); +require_once('generated/Bar/TestInclude.php'); +require_once('generated/Foo/TestEnum.php'); +require_once('generated/Foo/TestMessage.php'); +require_once('generated/Foo/TestMessage_Sub.php'); +require_once('generated/Foo/TestPackedMessage.php'); +require_once('generated/Foo/TestPhpDoc.php'); +require_once('generated/Foo/TestUnpackedMessage.php'); +require_once('generated/GPBMetadata/Proto/Test.php'); +require_once('generated/GPBMetadata/Proto/TestInclude.php'); require_once('test_util.php'); use Google\Protobuf\Internal\RepeatedField; diff --git a/php/tests/php_implementation_test.php b/php/tests/php_implementation_test.php index 485956cc..4f626f1c 100644 --- a/php/tests/php_implementation_test.php +++ b/php/tests/php_implementation_test.php @@ -1,6 +1,5 @@ <?php -require_once('test.pb.php'); require_once('test_base.php'); require_once('test_util.php'); diff --git a/php/tests/test.proto b/php/tests/proto/test.proto index 15709c83..fc283a05 100644 --- a/php/tests/test.proto +++ b/php/tests/proto/test.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -import 'test_include.proto'; +import 'proto/test_include.proto'; package foo; @@ -134,3 +134,8 @@ message TestUnpackedMessage { repeated bool repeated_bool = 102 [packed = false]; repeated TestEnum repeated_enum = 103 [packed = false]; } + +// /**/@<>&\{ +message TestPhpDoc { + int32 a = 1; +} diff --git a/php/tests/test_include.proto b/php/tests/proto/test_include.proto index 9844617f..9844617f 100644 --- a/php/tests/test_include.proto +++ b/php/tests/proto/test_include.proto diff --git a/php/tests/test_no_namespace.proto b/php/tests/proto/test_no_namespace.proto index 4331aeab..4331aeab 100644 --- a/php/tests/test_no_namespace.proto +++ b/php/tests/proto/test_no_namespace.proto diff --git a/php/tests/test.pb.php b/php/tests/test.pb.php deleted file mode 100644 index ed316b6e..00000000 --- a/php/tests/test.pb.php +++ /dev/null @@ -1,1385 +0,0 @@ -<?php -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: test.proto - -namespace Foo; - -require_once('test_include.pb.php'); -use Google\Protobuf\Internal\DescriptorPool; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBUtil; - -class TestMessage extends \Google\Protobuf\Internal\Message -{ - private $optional_int32 = 0; - private $optional_int64 = 0; - private $optional_uint32 = 0; - private $optional_uint64 = 0; - private $optional_sint32 = 0; - private $optional_sint64 = 0; - private $optional_fixed32 = 0; - private $optional_fixed64 = 0; - private $optional_sfixed32 = 0; - private $optional_sfixed64 = 0; - private $optional_float = 0.0; - private $optional_double = 0.0; - private $optional_bool = false; - private $optional_string = ''; - private $optional_bytes = ''; - private $optional_enum = 0; - private $optional_message = null; - private $optional_included_message = null; - private $recursive = null; - private $repeated_int32; - private $repeated_int64; - private $repeated_uint32; - private $repeated_uint64; - private $repeated_sint32; - private $repeated_sint64; - private $repeated_fixed32; - private $repeated_fixed64; - private $repeated_sfixed32; - private $repeated_sfixed64; - private $repeated_float; - private $repeated_double; - private $repeated_bool; - private $repeated_string; - private $repeated_bytes; - private $repeated_enum; - private $repeated_message; - private $repeated_recursive; - private $map_int32_int32; - private $map_int64_int64; - private $map_uint32_uint32; - private $map_uint64_uint64; - private $map_sint32_sint32; - private $map_sint64_sint64; - private $map_fixed32_fixed32; - private $map_fixed64_fixed64; - private $map_sfixed32_sfixed32; - private $map_sfixed64_sfixed64; - private $map_int32_float; - private $map_int32_double; - private $map_bool_bool; - private $map_string_string; - private $map_int32_bytes; - private $map_int32_enum; - private $map_int32_message; - private $map_recursive; - protected $my_oneof; - - public function getOptionalInt32() - { - return $this->optional_int32; - } - - public function setOptionalInt32($var) - { - GPBUtil::checkInt32($var); - $this->optional_int32 = $var; - } - - public function getOptionalInt64() - { - return $this->optional_int64; - } - - public function setOptionalInt64($var) - { - GPBUtil::checkInt64($var); - $this->optional_int64 = $var; - } - - public function getOptionalUint32() - { - return $this->optional_uint32; - } - - public function setOptionalUint32($var) - { - GPBUtil::checkUint32($var); - $this->optional_uint32 = $var; - } - - public function getOptionalUint64() - { - return $this->optional_uint64; - } - - public function setOptionalUint64($var) - { - GPBUtil::checkUint64($var); - $this->optional_uint64 = $var; - } - - public function getOptionalSint32() - { - return $this->optional_sint32; - } - - public function setOptionalSint32($var) - { - GPBUtil::checkInt32($var); - $this->optional_sint32 = $var; - } - - public function getOptionalSint64() - { - return $this->optional_sint64; - } - - public function setOptionalSint64($var) - { - GPBUtil::checkInt64($var); - $this->optional_sint64 = $var; - } - - public function getOptionalFixed32() - { - return $this->optional_fixed32; - } - - public function setOptionalFixed32($var) - { - GPBUtil::checkUint32($var); - $this->optional_fixed32 = $var; - } - - public function getOptionalFixed64() - { - return $this->optional_fixed64; - } - - public function setOptionalFixed64($var) - { - GPBUtil::checkUint64($var); - $this->optional_fixed64 = $var; - } - - public function getOptionalSfixed32() - { - return $this->optional_sfixed32; - } - - public function setOptionalSfixed32($var) - { - GPBUtil::checkInt32($var); - $this->optional_sfixed32 = $var; - } - - public function getOptionalSfixed64() - { - return $this->optional_sfixed64; - } - - public function setOptionalSfixed64($var) - { - GPBUtil::checkInt64($var); - $this->optional_sfixed64 = $var; - } - - public function getOptionalFloat() - { - return $this->optional_float; - } - - public function setOptionalFloat($var) - { - GPBUtil::checkFloat($var); - $this->optional_float = $var; - } - - public function getOptionalDouble() - { - return $this->optional_double; - } - - public function setOptionalDouble($var) - { - GPBUtil::checkDouble($var); - $this->optional_double = $var; - } - - public function getOptionalBool() - { - return $this->optional_bool; - } - - public function setOptionalBool($var) - { - GPBUtil::checkBool($var); - $this->optional_bool = $var; - } - - public function getOptionalString() - { - return $this->optional_string; - } - - public function setOptionalString($var) - { - GPBUtil::checkString($var, True); - $this->optional_string = $var; - } - - public function getOptionalBytes() - { - return $this->optional_bytes; - } - - public function setOptionalBytes($var) - { - GPBUtil::checkString($var, False); - $this->optional_bytes = $var; - } - - public function getOptionalEnum() - { - return $this->optional_enum; - } - - public function setOptionalEnum($var) - { - GPBUtil::checkEnum($var, \Foo\TestEnum::class); - $this->optional_enum = $var; - } - - public function getOptionalMessage() - { - return $this->optional_message; - } - - public function setOptionalMessage(&$var) - { - GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class); - $this->optional_message = $var; - } - - public function getOptionalIncludedMessage() - { - return $this->optional_included_message; - } - - public function setOptionalIncludedMessage(&$var) - { - GPBUtil::checkMessage($var, \Bar\TestInclude::class); - $this->optional_included_message = $var; - } - - public function getRecursive() - { - return $this->recursive; - } - - public function setRecursive(&$var) - { - GPBUtil::checkMessage($var, \Foo\TestMessage::class); - $this->recursive = $var; - } - - public function getRepeatedInt32() - { - return $this->repeated_int32; - } - - public function setRepeatedInt32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->repeated_int32 = $var; - } - - public function getRepeatedInt64() - { - return $this->repeated_int64; - } - - public function setRepeatedInt64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT64); - $this->repeated_int64 = $var; - } - - public function getRepeatedUint32() - { - return $this->repeated_uint32; - } - - public function setRepeatedUint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT32); - $this->repeated_uint32 = $var; - } - - public function getRepeatedUint64() - { - return $this->repeated_uint64; - } - - public function setRepeatedUint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT64); - $this->repeated_uint64 = $var; - } - - public function getRepeatedSint32() - { - return $this->repeated_sint32; - } - - public function setRepeatedSint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT32); - $this->repeated_sint32 = $var; - } - - public function getRepeatedSint64() - { - return $this->repeated_sint64; - } - - public function setRepeatedSint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT64); - $this->repeated_sint64 = $var; - } - - public function getRepeatedFixed32() - { - return $this->repeated_fixed32; - } - - public function setRepeatedFixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED32); - $this->repeated_fixed32 = $var; - } - - public function getRepeatedFixed64() - { - return $this->repeated_fixed64; - } - - public function setRepeatedFixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED64); - $this->repeated_fixed64 = $var; - } - - public function getRepeatedSfixed32() - { - return $this->repeated_sfixed32; - } - - public function setRepeatedSfixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); - $this->repeated_sfixed32 = $var; - } - - public function getRepeatedSfixed64() - { - return $this->repeated_sfixed64; - } - - public function setRepeatedSfixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); - $this->repeated_sfixed64 = $var; - } - - public function getRepeatedFloat() - { - return $this->repeated_float; - } - - public function setRepeatedFloat(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FLOAT); - $this->repeated_float = $var; - } - - public function getRepeatedDouble() - { - return $this->repeated_double; - } - - public function setRepeatedDouble(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); - $this->repeated_double = $var; - } - - public function getRepeatedBool() - { - return $this->repeated_bool; - } - - public function setRepeatedBool(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::BOOL); - $this->repeated_bool = $var; - } - - public function getRepeatedString() - { - return $this->repeated_string; - } - - public function setRepeatedString(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::STRING); - $this->repeated_string = $var; - } - - public function getRepeatedBytes() - { - return $this->repeated_bytes; - } - - public function setRepeatedBytes(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::BYTES); - $this->repeated_bytes = $var; - } - - public function getRepeatedEnum() - { - return $this->repeated_enum; - } - - public function setRepeatedEnum(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); - $this->repeated_enum = $var; - } - - public function getRepeatedMessage() - { - return $this->repeated_message; - } - - public function setRepeatedMessage(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage_Sub::class); - $this->repeated_message = $var; - } - - public function getRepeatedRecursive() - { - return $this->repeated_recursive; - } - - public function setRepeatedRecursive(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::MESSAGE, \Foo\TestMessage::class); - $this->repeated_recursive = $var; - } - - public function getOneofInt32() - { - return $this->readOneof(51); - } - - public function setOneofInt32($var) - { - GPBUtil::checkInt32($var); - $this->writeOneof(51, $var); - } - - public function getOneofInt64() - { - return $this->readOneof(52); - } - - public function setOneofInt64($var) - { - GPBUtil::checkInt64($var); - $this->writeOneof(52, $var); - } - - public function getOneofUint32() - { - return $this->readOneof(53); - } - - public function setOneofUint32($var) - { - GPBUtil::checkUint32($var); - $this->writeOneof(53, $var); - } - - public function getOneofUint64() - { - return $this->readOneof(54); - } - - public function setOneofUint64($var) - { - GPBUtil::checkUint64($var); - $this->writeOneof(54, $var); - } - - public function getOneofSint32() - { - return $this->readOneof(55); - } - - public function setOneofSint32($var) - { - GPBUtil::checkUint32($var); - $this->writeOneof(55, $var); - } - - public function getOneofSint64() - { - return $this->readOneof(56); - } - - public function setOneofSint64($var) - { - GPBUtil::checkUint64($var); - $this->writeOneof(56, $var); - } - - public function getOneofFixed32() - { - return $this->readOneof(57); - } - - public function setOneofFixed32($var) - { - GPBUtil::checkUint32($var); - $this->writeOneof(57, $var); - } - - public function getOneofFixed64() - { - return $this->readOneof(58); - } - - public function setOneofFixed64($var) - { - GPBUtil::checkUint64($var); - $this->writeOneof(58, $var); - } - - public function getOneofSfixed32() - { - return $this->readOneof(59); - } - - public function setOneofSfixed32($var) - { - GPBUtil::checkUint32($var); - $this->writeOneof(59, $var); - } - - public function getOneofSfixed64() - { - return $this->readOneof(60); - } - - public function setOneofSfixed64($var) - { - GPBUtil::checkUint64($var); - $this->writeOneof(60, $var); - } - - public function getOneofDouble() - { - return $this->readOneof(61); - } - - public function setOneofDouble($var) - { - GPBUtil::checkDouble($var); - $this->writeOneof(61, $var); - } - - public function getOneofFloat() - { - return $this->readOneof(62); - } - - public function setOneofFloat($var) - { - GPBUtil::checkFloat($var); - $this->writeOneof(62, $var); - } - - public function getOneofBool() - { - return $this->readOneof(63); - } - - public function setOneofBool($var) - { - GPBUtil::checkBool($var); - $this->writeOneof(63, $var); - } - - public function getOneofString() - { - return $this->readOneof(64); - } - - public function setOneofString($var) - { - GPBUtil::checkString($var, True); - $this->writeOneof(64, $var); - } - - public function getOneofBytes() - { - return $this->readOneof(65); - } - - public function setOneofBytes($var) - { - GPBUtil::checkString($var, False); - $this->writeOneof(65, $var); - } - - public function getOneofEnum() - { - return $this->readOneof(66); - } - - public function setOneofEnum($var) - { - GPBUtil::checkEnum($var, \Foo\TestEnum::class); - $this->writeOneof(66, $var); - } - - public function getOneofMessage() - { - return $this->readOneof(67); - } - - public function setOneofMessage(&$var) - { - GPBUtil::checkMessage($var, \Foo\TestMessage_Sub::class); - $this->writeOneof(67, $var); - } - - public function getMapInt32Int32() - { - return $this->map_int32_int32; - } - - public function setMapInt32Int32(&$var) - { - $this->map_int32_int32 = $var; - } - - public function getMapInt64Int64() - { - return $this->map_int64_int64; - } - - public function setMapInt64Int64(&$var) - { - $this->map_int64_int64 = $var; - } - - public function getMapUint32Uint32() - { - return $this->map_uint32_uint32; - } - - public function setMapUint32Uint32(&$var) - { - $this->map_uint32_uint32 = $var; - } - - public function getMapUint64Uint64() - { - return $this->map_uint64_uint64; - } - - public function setMapUint64Uint64(&$var) - { - $this->map_uint64_uint64 = $var; - } - - public function getMapSint32Sint32() - { - return $this->map_sint32_sint32; - } - - public function setMapSint32Sint32(&$var) - { - $this->map_sint32_sint32 = $var; - } - - public function getMapSint64Sint64() - { - return $this->map_sint64_sint64; - } - - public function setMapSint64Sint64(&$var) - { - $this->map_sint64_sint64 = $var; - } - - public function getMapFixed32Fixed32() - { - return $this->map_fixed32_fixed32; - } - - public function setMapFixed32Fixed32(&$var) - { - $this->map_fixed32_fixed32 = $var; - } - - public function getMapFixed64Fixed64() - { - return $this->map_fixed64_fixed64; - } - - public function setMapFixed64Fixed64(&$var) - { - $this->map_fixed64_fixed64 = $var; - } - - public function getMapSfixed32Sfixed32() - { - return $this->map_sfixed32_sfixed32; - } - - public function setMapSfixed32Sfixed32(&$var) - { - $this->map_sfixed32_sfixed32 = $var; - } - - public function getMapSfixed64Sfixed64() - { - return $this->map_sfixed64_sfixed64; - } - - public function setMapSfixed64Sfixed64(&$var) - { - $this->map_sfixed64_sfixed64 = $var; - } - - public function getMapInt32Float() - { - return $this->map_int32_float; - } - - public function setMapInt32Float(&$var) - { - $this->map_int32_float = $var; - } - - public function getMapInt32Double() - { - return $this->map_int32_double; - } - - public function setMapInt32Double(&$var) - { - $this->map_int32_double = $var; - } - - public function getMapBoolBool() - { - return $this->map_bool_bool; - } - - public function setMapBoolBool(&$var) - { - $this->map_bool_bool = $var; - } - - public function getMapStringString() - { - return $this->map_string_string; - } - - public function setMapStringString(&$var) - { - $this->map_string_string = $var; - } - - public function getMapInt32Bytes() - { - return $this->map_int32_bytes; - } - - public function setMapInt32Bytes(&$var) - { - $this->map_int32_bytes = $var; - } - - public function getMapInt32Enum() - { - return $this->map_int32_enum; - } - - public function setMapInt32Enum(&$var) - { - $this->map_int32_enum = $var; - } - - public function getMapInt32Message() - { - return $this->map_int32_message; - } - - public function setMapInt32Message(&$var) - { - $this->map_int32_message = $var; - } - - public function getMapRecursive() - { - return $this->map_recursive; - } - - public function setMapRecursive(&$var) - { - $this->map_recursive = $var; - } - - public function getMyOneof() - { - return $this->my_oneof; - } - -} - -class TestMessage_Sub extends \Google\Protobuf\Internal\Message -{ - private $a = 0; - - public function getA() - { - return $this->a; - } - - public function setA($var) - { - GPBUtil::checkInt32($var); - $this->a = $var; - } - -} - -class TestPackedMessage extends \Google\Protobuf\Internal\Message -{ - private $repeated_int32; - private $repeated_int64; - private $repeated_uint32; - private $repeated_uint64; - private $repeated_sint32; - private $repeated_sint64; - private $repeated_fixed32; - private $repeated_fixed64; - private $repeated_sfixed32; - private $repeated_sfixed64; - private $repeated_float; - private $repeated_double; - private $repeated_bool; - private $repeated_enum; - - public function getRepeatedInt32() - { - return $this->repeated_int32; - } - - public function setRepeatedInt32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->repeated_int32 = $var; - } - - public function getRepeatedInt64() - { - return $this->repeated_int64; - } - - public function setRepeatedInt64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT64); - $this->repeated_int64 = $var; - } - - public function getRepeatedUint32() - { - return $this->repeated_uint32; - } - - public function setRepeatedUint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT32); - $this->repeated_uint32 = $var; - } - - public function getRepeatedUint64() - { - return $this->repeated_uint64; - } - - public function setRepeatedUint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT64); - $this->repeated_uint64 = $var; - } - - public function getRepeatedSint32() - { - return $this->repeated_sint32; - } - - public function setRepeatedSint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT32); - $this->repeated_sint32 = $var; - } - - public function getRepeatedSint64() - { - return $this->repeated_sint64; - } - - public function setRepeatedSint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT64); - $this->repeated_sint64 = $var; - } - - public function getRepeatedFixed32() - { - return $this->repeated_fixed32; - } - - public function setRepeatedFixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED32); - $this->repeated_fixed32 = $var; - } - - public function getRepeatedFixed64() - { - return $this->repeated_fixed64; - } - - public function setRepeatedFixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED64); - $this->repeated_fixed64 = $var; - } - - public function getRepeatedSfixed32() - { - return $this->repeated_sfixed32; - } - - public function setRepeatedSfixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); - $this->repeated_sfixed32 = $var; - } - - public function getRepeatedSfixed64() - { - return $this->repeated_sfixed64; - } - - public function setRepeatedSfixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); - $this->repeated_sfixed64 = $var; - } - - public function getRepeatedFloat() - { - return $this->repeated_float; - } - - public function setRepeatedFloat(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FLOAT); - $this->repeated_float = $var; - } - - public function getRepeatedDouble() - { - return $this->repeated_double; - } - - public function setRepeatedDouble(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); - $this->repeated_double = $var; - } - - public function getRepeatedBool() - { - return $this->repeated_bool; - } - - public function setRepeatedBool(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::BOOL); - $this->repeated_bool = $var; - } - - public function getRepeatedEnum() - { - return $this->repeated_enum; - } - - public function setRepeatedEnum(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); - $this->repeated_enum = $var; - } - -} - -class TestUnpackedMessage extends \Google\Protobuf\Internal\Message -{ - private $repeated_int32; - private $repeated_int64; - private $repeated_uint32; - private $repeated_uint64; - private $repeated_sint32; - private $repeated_sint64; - private $repeated_fixed32; - private $repeated_fixed64; - private $repeated_sfixed32; - private $repeated_sfixed64; - private $repeated_float; - private $repeated_double; - private $repeated_bool; - private $repeated_enum; - - public function getRepeatedInt32() - { - return $this->repeated_int32; - } - - public function setRepeatedInt32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT32); - $this->repeated_int32 = $var; - } - - public function getRepeatedInt64() - { - return $this->repeated_int64; - } - - public function setRepeatedInt64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::INT64); - $this->repeated_int64 = $var; - } - - public function getRepeatedUint32() - { - return $this->repeated_uint32; - } - - public function setRepeatedUint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT32); - $this->repeated_uint32 = $var; - } - - public function getRepeatedUint64() - { - return $this->repeated_uint64; - } - - public function setRepeatedUint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::UINT64); - $this->repeated_uint64 = $var; - } - - public function getRepeatedSint32() - { - return $this->repeated_sint32; - } - - public function setRepeatedSint32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT32); - $this->repeated_sint32 = $var; - } - - public function getRepeatedSint64() - { - return $this->repeated_sint64; - } - - public function setRepeatedSint64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SINT64); - $this->repeated_sint64 = $var; - } - - public function getRepeatedFixed32() - { - return $this->repeated_fixed32; - } - - public function setRepeatedFixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED32); - $this->repeated_fixed32 = $var; - } - - public function getRepeatedFixed64() - { - return $this->repeated_fixed64; - } - - public function setRepeatedFixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FIXED64); - $this->repeated_fixed64 = $var; - } - - public function getRepeatedSfixed32() - { - return $this->repeated_sfixed32; - } - - public function setRepeatedSfixed32(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED32); - $this->repeated_sfixed32 = $var; - } - - public function getRepeatedSfixed64() - { - return $this->repeated_sfixed64; - } - - public function setRepeatedSfixed64(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::SFIXED64); - $this->repeated_sfixed64 = $var; - } - - public function getRepeatedFloat() - { - return $this->repeated_float; - } - - public function setRepeatedFloat(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::FLOAT); - $this->repeated_float = $var; - } - - public function getRepeatedDouble() - { - return $this->repeated_double; - } - - public function setRepeatedDouble(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::DOUBLE); - $this->repeated_double = $var; - } - - public function getRepeatedBool() - { - return $this->repeated_bool; - } - - public function setRepeatedBool(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::BOOL); - $this->repeated_bool = $var; - } - - public function getRepeatedEnum() - { - return $this->repeated_enum; - } - - public function setRepeatedEnum(&$var) - { - GPBUtil::checkRepeatedField($var, GPBType::ENUM, Foo\TestEnum::class); - $this->repeated_enum = $var; - } - -} - -class TestEnum -{ - const ZERO = 0; - const ONE = 1; -} - -$pool = DescriptorPool::getGeneratedPool(); - -$pool->internalAddGeneratedFile(hex2bin( - "0a83250a0a746573742e70726f746f1203666f6f1a12746573745f696e63" . - "6c7564652e70726f746f22be1d0a0b546573744d65737361676512160a0e" . - "6f7074696f6e616c5f696e74333218012001280512160a0e6f7074696f6e" . - "616c5f696e74363418022001280312170a0f6f7074696f6e616c5f75696e" . - "74333218032001280d12170a0f6f7074696f6e616c5f75696e7436341804" . - "2001280412170a0f6f7074696f6e616c5f73696e74333218052001281112" . - "170a0f6f7074696f6e616c5f73696e74363418062001281212180a106f70" . - "74696f6e616c5f6669786564333218072001280712180a106f7074696f6e" . - "616c5f6669786564363418082001280612190a116f7074696f6e616c5f73" . - "6669786564333218092001280f12190a116f7074696f6e616c5f73666978" . - "65643634180a2001281012160a0e6f7074696f6e616c5f666c6f6174180b" . - "2001280212170a0f6f7074696f6e616c5f646f75626c65180c2001280112" . - "150a0d6f7074696f6e616c5f626f6f6c180d2001280812170a0f6f707469" . - "6f6e616c5f737472696e67180e2001280912160a0e6f7074696f6e616c5f" . - "6279746573180f2001280c12240a0d6f7074696f6e616c5f656e756d1810" . - "2001280e320d2e666f6f2e54657374456e756d122e0a106f7074696f6e61" . - "6c5f6d65737361676518112001280b32142e666f6f2e546573744d657373" . - "6167652e53756212330a196f7074696f6e616c5f696e636c756465645f6d" . - "65737361676518122001280b32102e6261722e54657374496e636c756465" . - "12230a0972656375727369766518132001280b32102e666f6f2e54657374" . - "4d65737361676512160a0e72657065617465645f696e743332181f200328" . - "0512160a0e72657065617465645f696e74363418202003280312170a0f72" . - "657065617465645f75696e74333218212003280d12170a0f726570656174" . - "65645f75696e74363418222003280412170a0f72657065617465645f7369" . - "6e74333218232003281112170a0f72657065617465645f73696e74363418" . - "242003281212180a1072657065617465645f666978656433321825200328" . - "0712180a1072657065617465645f6669786564363418262003280612190a" . - "1172657065617465645f736669786564333218272003280f12190a117265" . - "7065617465645f736669786564363418282003281012160a0e7265706561" . - "7465645f666c6f617418292003280212170a0f72657065617465645f646f" . - "75626c65182a2003280112150a0d72657065617465645f626f6f6c182b20" . - "03280812170a0f72657065617465645f737472696e67182c200328091216" . - "0a0e72657065617465645f6279746573182d2003280c12240a0d72657065" . - "617465645f656e756d182e2003280e320d2e666f6f2e54657374456e756d" . - "122e0a1072657065617465645f6d657373616765182f2003280b32142e66" . - "6f6f2e546573744d6573736167652e537562122c0a127265706561746564" . - "5f72656375727369766518302003280b32102e666f6f2e546573744d6573" . - "7361676512150a0b6f6e656f665f696e743332183320012805480012150a" . - "0b6f6e656f665f696e743634183420012803480012160a0c6f6e656f665f" . - "75696e74333218352001280d480012160a0c6f6e656f665f75696e743634" . - "183620012804480012160a0c6f6e656f665f73696e74333218372001280d" . - "480012160a0c6f6e656f665f73696e743634183820012804480012170a0d" . - "6f6e656f665f6669786564333218392001280d480012170a0d6f6e656f66" . - "5f66697865643634183a20012804480012180a0e6f6e656f665f73666978" . - "65643332183b2001280d480012180a0e6f6e656f665f7366697865643634" . - "183c20012804480012160a0c6f6e656f665f646f75626c65183d20012801" . - "480012150a0b6f6e656f665f666c6f6174183e20012802480012140a0a6f" . - "6e656f665f626f6f6c183f20012808480012160a0c6f6e656f665f737472" . - "696e67184020012809480012150a0b6f6e656f665f627974657318412001" . - "280c480012230a0a6f6e656f665f656e756d18422001280e320d2e666f6f" . - "2e54657374456e756d4800122d0a0d6f6e656f665f6d6573736167651843" . - "2001280b32142e666f6f2e546573744d6573736167652e5375624800123c" . - "0a0f6d61705f696e7433325f696e74333218472003280b32232e666f6f2e" . - "546573744d6573736167652e4d6170496e743332496e743332456e747279" . - "123c0a0f6d61705f696e7436345f696e74363418482003280b32232e666f" . - "6f2e546573744d6573736167652e4d6170496e743634496e743634456e74" . - "727912400a116d61705f75696e7433325f75696e74333218492003280b32" . - "252e666f6f2e546573744d6573736167652e4d617055696e74333255696e" . - "743332456e74727912400a116d61705f75696e7436345f75696e74363418" . - "4a2003280b32252e666f6f2e546573744d6573736167652e4d617055696e" . - "74363455696e743634456e74727912400a116d61705f73696e7433325f73" . - "696e743332184b2003280b32252e666f6f2e546573744d6573736167652e" . - "4d617053696e74333253696e743332456e74727912400a116d61705f7369" . - "6e7436345f73696e743634184c2003280b32252e666f6f2e546573744d65" . - "73736167652e4d617053696e74363453696e743634456e74727912440a13" . - "6d61705f666978656433325f66697865643332184d2003280b32272e666f" . - "6f2e546573744d6573736167652e4d617046697865643332466978656433" . - "32456e74727912440a136d61705f666978656436345f6669786564363418" . - "4e2003280b32272e666f6f2e546573744d6573736167652e4d6170466978" . - "6564363446697865643634456e74727912480a156d61705f736669786564" . - "33325f7366697865643332184f2003280b32292e666f6f2e546573744d65" . - "73736167652e4d617053666978656433325366697865643332456e747279" . - "12480a156d61705f73666978656436345f73666978656436341850200328" . - "0b32292e666f6f2e546573744d6573736167652e4d617053666978656436" . - "345366697865643634456e747279123c0a0f6d61705f696e7433325f666c" . - "6f617418512003280b32232e666f6f2e546573744d6573736167652e4d61" . - "70496e743332466c6f6174456e747279123e0a106d61705f696e7433325f" . - "646f75626c6518522003280b32242e666f6f2e546573744d657373616765" . - "2e4d6170496e743332446f75626c65456e74727912380a0d6d61705f626f" . - "6f6c5f626f6f6c18532003280b32212e666f6f2e546573744d6573736167" . - "652e4d6170426f6f6c426f6f6c456e74727912400a116d61705f73747269" . - "6e675f737472696e6718542003280b32252e666f6f2e546573744d657373" . - "6167652e4d6170537472696e67537472696e67456e747279123c0a0f6d61" . - "705f696e7433325f627974657318552003280b32232e666f6f2e54657374" . - "4d6573736167652e4d6170496e7433324279746573456e747279123a0a0e" . - "6d61705f696e7433325f656e756d18562003280b32222e666f6f2e546573" . - "744d6573736167652e4d6170496e743332456e756d456e74727912400a11" . - "6d61705f696e7433325f6d65737361676518572003280b32252e666f6f2e" . - "546573744d6573736167652e4d6170496e7433324d657373616765456e74" . - "727912390a0d6d61705f72656375727369766518582003280b32222e666f" . - "6f2e546573744d6573736167652e4d6170526563757273697665456e7472" . - "791a340a124d6170496e743332496e743332456e747279120b0a036b6579" . - "180120012805120d0a0576616c75651802200128053a0238011a340a124d" . - "6170496e743634496e743634456e747279120b0a036b6579180120012803" . - "120d0a0576616c75651802200128033a0238011a360a144d617055696e74" . - "333255696e743332456e747279120b0a036b657918012001280d120d0a05" . - "76616c756518022001280d3a0238011a360a144d617055696e7436345569" . - "6e743634456e747279120b0a036b6579180120012804120d0a0576616c75" . - "651802200128043a0238011a360a144d617053696e74333253696e743332" . - "456e747279120b0a036b6579180120012811120d0a0576616c7565180220" . - "0128113a0238011a360a144d617053696e74363453696e743634456e7472" . - "79120b0a036b6579180120012812120d0a0576616c75651802200128123a" . - "0238011a380a164d61704669786564333246697865643332456e74727912" . - "0b0a036b6579180120012807120d0a0576616c75651802200128073a0238" . - "011a380a164d61704669786564363446697865643634456e747279120b0a" . - "036b6579180120012806120d0a0576616c75651802200128063a0238011a" . - "3a0a184d617053666978656433325366697865643332456e747279120b0a" . - "036b657918012001280f120d0a0576616c756518022001280f3a0238011a" . - "3a0a184d617053666978656436345366697865643634456e747279120b0a" . - "036b6579180120012810120d0a0576616c75651802200128103a0238011a" . - "340a124d6170496e743332466c6f6174456e747279120b0a036b65791801" . - "20012805120d0a0576616c75651802200128023a0238011a350a134d6170" . - "496e743332446f75626c65456e747279120b0a036b657918012001280512" . - "0d0a0576616c75651802200128013a0238011a320a104d6170426f6f6c42" . - "6f6f6c456e747279120b0a036b6579180120012808120d0a0576616c7565" . - "1802200128083a0238011a360a144d6170537472696e67537472696e6745" . - "6e747279120b0a036b6579180120012809120d0a0576616c756518022001" . - "28093a0238011a340a124d6170496e7433324279746573456e747279120b" . - "0a036b6579180120012805120d0a0576616c756518022001280c3a023801" . - "1a420a114d6170496e743332456e756d456e747279120b0a036b65791801" . - "20012805121c0a0576616c756518022001280e320d2e666f6f2e54657374" . - "456e756d3a0238011a4c0a144d6170496e7433324d657373616765456e74" . - "7279120b0a036b657918012001280512230a0576616c756518022001280b" . - "32142e666f6f2e546573744d6573736167652e5375623a0238011a450a11" . - "4d6170526563757273697665456e747279120b0a036b6579180120012805" . - "121f0a0576616c756518022001280b32102e666f6f2e546573744d657373" . - "6167653a0238011a100a0353756212090a0161180120012805420a0a086d" . - "795f6f6e656f6622b7030a11546573745061636b65644d65737361676512" . - "1a0a0e72657065617465645f696e743332185a2003280542021001121a0a" . - "0e72657065617465645f696e743634185b2003280342021001121b0a0f72" . - "657065617465645f75696e743332185c2003280d42021001121b0a0f7265" . - "7065617465645f75696e743634185d2003280442021001121b0a0f726570" . - "65617465645f73696e743332185e2003281142021001121b0a0f72657065" . - "617465645f73696e743634185f2003281242021001121c0a107265706561" . - "7465645f6669786564333218602003280742021001121c0a107265706561" . - "7465645f6669786564363418612003280642021001121d0a117265706561" . - "7465645f736669786564333218622003280f42021001121d0a1172657065" . - "617465645f736669786564363418632003281042021001121a0a0e726570" . - "65617465645f666c6f617418642003280242021001121b0a0f7265706561" . - "7465645f646f75626c651865200328014202100112190a0d726570656174" . - "65645f626f6f6c1866200328084202100112280a0d72657065617465645f" . - "656e756d18672003280e320d2e666f6f2e54657374456e756d4202100122" . - "b9030a1354657374556e7061636b65644d657373616765121a0a0e726570" . - "65617465645f696e743332185a2003280542021000121a0a0e7265706561" . - "7465645f696e743634185b2003280342021000121b0a0f72657065617465" . - "645f75696e743332185c2003280d42021000121b0a0f7265706561746564" . - "5f75696e743634185d2003280442021000121b0a0f72657065617465645f" . - "73696e743332185e2003281142021000121b0a0f72657065617465645f73" . - "696e743634185f2003281242021000121c0a1072657065617465645f6669" . - "786564333218602003280742021000121c0a1072657065617465645f6669" . - "786564363418612003280642021000121d0a1172657065617465645f7366" . - "69786564333218622003280f42021000121d0a1172657065617465645f73" . - "6669786564363418632003281042021000121a0a0e72657065617465645f" . - "666c6f617418642003280242021000121b0a0f72657065617465645f646f" . - "75626c651865200328014202100012190a0d72657065617465645f626f6f" . - "6c1866200328084202100012280a0d72657065617465645f656e756d1867" . - "2003280e320d2e666f6f2e54657374456e756d420210002a1d0a08546573" . - "74456e756d12080a045a45524f100012070a034f4e451001620670726f74" . - "6f33" -)); - diff --git a/php/tests/test.sh b/php/tests/test.sh index a6ca89b9..3635d86c 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -1,14 +1,11 @@ #!/bin/bash -# Generate test file -../../src/protoc --php_out=. test.proto test_include.proto - # Compile c extension pushd ../ext/google/protobuf/ make clean set -e # Add following in configure for debug: --enable-debug CFLAGS='-g -O0' -phpize && ./configure && make +phpize && ./configure --enable-debug CFLAGS='-g -O0' && make popd tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php ) @@ -18,7 +15,7 @@ do echo "****************************" echo "* $t" echo "****************************" - php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` $t + php -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t echo "" done diff --git a/php/tests/test_include.pb.php b/php/tests/test_include.pb.php deleted file mode 100644 index 2c43cc41..00000000 --- a/php/tests/test_include.pb.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: test_include.proto - -namespace Bar; - -use Google\Protobuf\Internal\DescriptorPool; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBUtil; - -class TestInclude extends \Google\Protobuf\Internal\Message -{ - private $a = 0; - - public function getA() - { - return $this->a; - } - - public function setA($var) - { - GPBUtil::checkInt32($var); - $this->a = $var; - } - -} - -$pool = DescriptorPool::getGeneratedPool(); - -$pool->internalAddGeneratedFile(hex2bin( - "0a3b0a12746573745f696e636c7564652e70726f746f120362617222180a" . - "0b54657374496e636c75646512090a0161180120012805620670726f746f" . - "33" -)); - diff --git a/php/tests/test_no_namespace.pb.php b/php/tests/test_no_namespace.pb.php deleted file mode 100644 index 2f92c955..00000000 --- a/php/tests/test_no_namespace.pb.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: test_no_namespace.proto - -use Google\Protobuf\Internal\DescriptorPool; -use Google\Protobuf\Internal\GPBType; -use Google\Protobuf\Internal\RepeatedField; -use Google\Protobuf\Internal\GPBUtil; - -class NoNameSpace extends \Google\Protobuf\Internal\Message -{ - private $a = 0; - - public function getA() - { - return $this->a; - } - - public function setA($var) - { - GPBUtil::checkInt32($var); - $this->a = $var; - } - -} - -$pool = DescriptorPool::getGeneratedPool(); - -$pool->internalAddGeneratedFile(hex2bin( - "0a3b0a17746573745f6e6f5f6e616d6573706163652e70726f746f22180a" . - "0b4e6f4e616d65537061636512090a0161180120012805620670726f746f" . - "33" -)); - diff --git a/php/tests/well_known_test.php b/php/tests/well_known_test.php index 30715ba9..40ff1c8f 100644 --- a/php/tests/well_known_test.php +++ b/php/tests/well_known_test.php @@ -1,7 +1,5 @@ <?php -require_once("google/protobuf/empty.pb.php"); - use Google\Protobuf\GPBEmpty; class WellKnownTest extends PHPUnit_Framework_TestCase { diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index f9118d8e..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<phpunit bootstrap="./vendor/autoload.php" - colors="true"> - <testsuites> - <testsuite name="protobuf-tests"> - <file>php/tests/php_implementation_test.php</file> - <file>php/tests/array_test.php</file> - <file>php/tests/encode_decode_test.php</file> - <file>php/tests/generated_class_test.php</file> - <file>php/tests/map_field_test.php</file> - <file>php/tests/well_known_test.php</file> - </testsuite> - </testsuites> -</phpunit> diff --git a/protobuf.bzl b/protobuf.bzl index ac448201..3998e77b 100644 --- a/protobuf.bzl +++ b/protobuf.bzl @@ -1,5 +1,3 @@ -# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED - def _GetPath(ctx, path): if ctx.label.workspace_root: return ctx.label.workspace_root + '/' + path @@ -240,7 +238,6 @@ def cc_proto_library( includes=includes, **kargs) - def internal_gen_well_known_protos_java(srcs): """Bazel rule to generate the gen_well_known_protos_java genrule @@ -264,7 +261,6 @@ def internal_gen_well_known_protos_java(srcs): tools = [":protoc"], ) - def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs): """Macro to copy files to a different directory and then create a filegroup. @@ -294,7 +290,6 @@ def internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs): srcs = outs, **kwargs) - def py_proto_library( name, srcs=[], @@ -304,6 +299,7 @@ def py_proto_library( include=None, default_runtime="//:protobuf_python", protoc="//:protoc", + use_grpc_plugin=False, **kargs): """Bazel rule to create a Python protobuf library from proto source files @@ -323,6 +319,8 @@ def py_proto_library( default_runtime: the implicitly default runtime which will be depended on by the generated py_library target. protoc: the label of the protocol compiler to generate the sources. + use_grpc_plugin: a flag to indicate whether to call the Python C++ plugin + when processing the proto files. **kargs: other keyword arguments that are passed to cc_library. """ @@ -332,6 +330,13 @@ def py_proto_library( if include != None: includes = [include] + grpc_python_plugin = None + if use_grpc_plugin: + grpc_python_plugin = "//external:grpc_python_plugin" + # Note: Generated grpc code depends on Python grpc module. This dependency + # is not explicitly listed in py_libs. Instead, host system is assumed to + # have grpc installed. + proto_gen( name=name + "_genproto", srcs=srcs, @@ -341,6 +346,8 @@ def py_proto_library( gen_py=1, outs=outs, visibility=["//visibility:public"], + plugin=grpc_python_plugin, + plugin_language="grpc" ) if default_runtime and not default_runtime in py_libs + deps: diff --git a/python/google/protobuf/descriptor_pool.py b/python/google/protobuf/descriptor_pool.py index 5f43ee5f..fc3a7f44 100644 --- a/python/google/protobuf/descriptor_pool.py +++ b/python/google/protobuf/descriptor_pool.py @@ -57,6 +57,8 @@ directly instead of this class. __author__ = 'matthewtoia@google.com (Matt Toia)' +import collections + from google.protobuf import descriptor from google.protobuf import descriptor_database from google.protobuf import text_encoding @@ -88,6 +90,14 @@ def _OptionsOrNone(descriptor_proto): return None +def _IsMessageSetExtension(field): + return (field.is_extension and + field.containing_type.has_options and + field.containing_type.GetOptions().message_set_wire_format and + field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and + field.label == descriptor.FieldDescriptor.LABEL_OPTIONAL) + + class DescriptorPool(object): """A collection of protobufs dynamically constructed by descriptor protos.""" @@ -115,6 +125,12 @@ class DescriptorPool(object): self._descriptors = {} self._enum_descriptors = {} self._file_descriptors = {} + self._toplevel_extensions = {} + # 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 Add(self, file_desc_proto): """Adds the FileDescriptorProto and its types to this pool. @@ -170,6 +186,48 @@ class DescriptorPool(object): self._enum_descriptors[enum_desc.full_name] = enum_desc self.AddFileDescriptor(enum_desc.file) + def AddExtensionDescriptor(self, extension): + """Adds a FieldDescriptor describing an extension to the pool. + + Args: + extension: A FieldDescriptor. + + Raises: + AssertionError: when another extension with the same number extends the + same message. + TypeError: when the specified extension is not a + descriptor.FieldDescriptor. + """ + if not (isinstance(extension, descriptor.FieldDescriptor) and + extension.is_extension): + raise TypeError('Expected an extension descriptor.') + + if extension.extension_scope is None: + self._toplevel_extensions[extension.full_name] = extension + + try: + existing_desc = self._extensions_by_number[ + extension.containing_type][extension.number] + except KeyError: + pass + else: + if extension is not existing_desc: + raise AssertionError( + 'Extensions "%s" and "%s" both try to extend message type "%s" ' + 'with field number %d.' % + (extension.full_name, existing_desc.full_name, + extension.containing_type.full_name, extension.number)) + + self._extensions_by_number[extension.containing_type][ + extension.number] = extension + self._extensions_by_name[extension.containing_type][ + extension.full_name] = extension + + # Also register MessageSet extensions with the type name. + if _IsMessageSetExtension(extension): + self._extensions_by_name[extension.containing_type][ + extension.message_type.full_name] = extension + def AddFileDescriptor(self, file_desc): """Adds a FileDescriptor to the pool, non-recursively. @@ -302,6 +360,14 @@ class DescriptorPool(object): A FieldDescriptor, describing the named extension. """ full_name = _NormalizeFullyQualifiedName(full_name) + try: + # The proto compiler does not give any link between the FileDescriptor + # and top-level extensions unless the FileDescriptorProto is added to + # the DescriptorDatabase, but this can impact memory usage. + # So we registered these extensions by name explicitly. + return self._toplevel_extensions[full_name] + except KeyError: + pass message_name, _, extension_name = full_name.rpartition('.') try: # Most extensions are nested inside a message. @@ -311,6 +377,39 @@ class DescriptorPool(object): scope = self.FindFileContainingSymbol(full_name) return scope.extensions_by_name[extension_name] + def FindExtensionByNumber(self, message_descriptor, number): + """Gets the extension of the specified message with the specified number. + + Extensions have to be registered to this pool by calling + AddExtensionDescriptor. + + Args: + message_descriptor: descriptor of the extended message. + number: integer, number of the extension field. + + Returns: + A FieldDescriptor describing the extension. + + Raise: + KeyError: when no extension with the given number is known for the + specified message. + """ + return self._extensions_by_number[message_descriptor][number] + + def FindAllExtensions(self, message_descriptor): + """Gets all the known extension of a given message. + + Extensions have to be registered to this pool by calling + AddExtensionDescriptor. + + Args: + message_descriptor: descriptor of the extended message. + + Returns: + A list of FieldDescriptor describing the extensions. + """ + return list(self._extensions_by_number[message_descriptor].values()) + def _ConvertFileProtoToFileDescriptor(self, file_proto): """Creates a FileDescriptor from a proto or returns a cached copy. diff --git a/python/google/protobuf/internal/decoder.py b/python/google/protobuf/internal/decoder.py index 31869e45..c5f73dc1 100755 --- a/python/google/protobuf/internal/decoder.py +++ b/python/google/protobuf/internal/decoder.py @@ -642,10 +642,10 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default): MESSAGE_SET_ITEM_TAG = encoder.TagBytes(1, wire_format.WIRETYPE_START_GROUP) -def MessageSetItemDecoder(extensions_by_number): +def MessageSetItemDecoder(descriptor): """Returns a decoder for a MessageSet item. - The parameter is the _extensions_by_number map for the message class. + The parameter is the message Descriptor. The message set message looks like this: message MessageSet { @@ -694,7 +694,7 @@ def MessageSetItemDecoder(extensions_by_number): if message_start == -1: raise _DecodeError('MessageSet item missing message.') - extension = extensions_by_number.get(type_id) + extension = message.Extensions._FindExtensionByNumber(type_id) if extension is not None: value = field_dict.get(extension) if value is None: diff --git a/python/google/protobuf/internal/descriptor_pool_test.py b/python/google/protobuf/internal/descriptor_pool_test.py index d4de2d81..1e710dcf 100644 --- a/python/google/protobuf/internal/descriptor_pool_test.py +++ b/python/google/protobuf/internal/descriptor_pool_test.py @@ -254,6 +254,53 @@ class DescriptorPoolTest(unittest.TestCase): with self.assertRaises(KeyError): self.pool.FindFieldByName('Does not exist') + def testFindAllExtensions(self): + factory1_message = self.pool.FindMessageTypeByName( + 'google.protobuf.python.internal.Factory1Message') + factory2_message = self.pool.FindMessageTypeByName( + 'google.protobuf.python.internal.Factory2Message') + # An extension defined in a message. + one_more_field = factory2_message.extensions_by_name['one_more_field'] + self.pool.AddExtensionDescriptor(one_more_field) + # An extension defined at file scope. + factory_test2 = self.pool.FindFileByName( + 'google/protobuf/internal/factory_test2.proto') + another_field = factory_test2.extensions_by_name['another_field'] + self.pool.AddExtensionDescriptor(another_field) + + extensions = self.pool.FindAllExtensions(factory1_message) + expected_extension_numbers = set([one_more_field, another_field]) + self.assertEqual(expected_extension_numbers, set(extensions)) + # Verify that mutating the returned list does not affect the pool. + extensions.append('unexpected_element') + # Get the extensions again, the returned value does not contain the + # 'unexpected_element'. + extensions = self.pool.FindAllExtensions(factory1_message) + self.assertEqual(expected_extension_numbers, set(extensions)) + + def testFindExtensionByNumber(self): + factory1_message = self.pool.FindMessageTypeByName( + 'google.protobuf.python.internal.Factory1Message') + factory2_message = self.pool.FindMessageTypeByName( + 'google.protobuf.python.internal.Factory2Message') + # An extension defined in a message. + one_more_field = factory2_message.extensions_by_name['one_more_field'] + self.pool.AddExtensionDescriptor(one_more_field) + # An extension defined at file scope. + factory_test2 = self.pool.FindFileByName( + 'google/protobuf/internal/factory_test2.proto') + another_field = factory_test2.extensions_by_name['another_field'] + self.pool.AddExtensionDescriptor(another_field) + + # An extension defined in a message. + extension = self.pool.FindExtensionByNumber(factory1_message, 1001) + self.assertEqual(extension.name, 'one_more_field') + # An extension defined at file scope. + extension = self.pool.FindExtensionByNumber(factory1_message, 1002) + self.assertEqual(extension.name, 'another_field') + with self.assertRaises(KeyError): + extension = self.pool.FindExtensionByNumber(factory1_message, 1234567) + def testExtensionsAreNotFields(self): with self.assertRaises(KeyError): self.pool.FindFieldByName('google.protobuf.python.internal.another_field') diff --git a/python/google/protobuf/internal/message_factory_test.py b/python/google/protobuf/internal/message_factory_test.py index 7bb7d1ac..4caa2443 100644 --- a/python/google/protobuf/internal/message_factory_test.py +++ b/python/google/protobuf/internal/message_factory_test.py @@ -114,18 +114,18 @@ class MessageFactoryTest(unittest.TestCase): ).issubset(set(messages.keys()))) self._ExerciseDynamicClass( messages['google.protobuf.python.internal.Factory2Message']) - self.assertTrue( - set(['google.protobuf.python.internal.Factory2Message.one_more_field', - 'google.protobuf.python.internal.another_field'], - ).issubset( - set(messages['google.protobuf.python.internal.Factory1Message'] - ._extensions_by_name.keys()))) factory_msg1 = messages['google.protobuf.python.internal.Factory1Message'] + self.assertTrue(set( + ['google.protobuf.python.internal.Factory2Message.one_more_field', + 'google.protobuf.python.internal.another_field'],).issubset(set( + ext.full_name + for ext in factory_msg1.DESCRIPTOR.file.pool.FindAllExtensions( + factory_msg1.DESCRIPTOR)))) msg1 = messages['google.protobuf.python.internal.Factory1Message']() - ext1 = factory_msg1._extensions_by_name[ - 'google.protobuf.python.internal.Factory2Message.one_more_field'] - ext2 = factory_msg1._extensions_by_name[ - 'google.protobuf.python.internal.another_field'] + ext1 = msg1.Extensions._FindExtensionByName( + 'google.protobuf.python.internal.Factory2Message.one_more_field') + ext2 = msg1.Extensions._FindExtensionByName( + 'google.protobuf.python.internal.another_field') msg1.Extensions[ext1] = 'test1' msg1.Extensions[ext2] = 'test2' self.assertEqual('test1', msg1.Extensions[ext1]) diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py index dc6565d4..c1bd1f9c 100755 --- a/python/google/protobuf/internal/python_message.py +++ b/python/google/protobuf/internal/python_message.py @@ -51,8 +51,8 @@ this file*. __author__ = 'robinson@google.com (Will Robinson)' from io import BytesIO -import sys import struct +import sys import weakref import six @@ -162,12 +162,10 @@ class GeneratedProtocolMessageType(type): """ descriptor = dictionary[GeneratedProtocolMessageType._DESCRIPTOR_KEY] cls._decoders_by_tag = {} - cls._extensions_by_name = {} - cls._extensions_by_number = {} if (descriptor.has_options and descriptor.GetOptions().message_set_wire_format): cls._decoders_by_tag[decoder.MESSAGE_SET_ITEM_TAG] = ( - decoder.MessageSetItemDecoder(cls._extensions_by_number), None) + decoder.MessageSetItemDecoder(descriptor), None) # Attach stuff to each FieldDescriptor for quick lookup later on. for field in descriptor.fields: @@ -747,32 +745,21 @@ def _AddPropertiesForExtensions(descriptor, cls): constant_name = extension_name.upper() + "_FIELD_NUMBER" setattr(cls, constant_name, extension_field.number) + # TODO(amauryfa): Migrate all users of these attributes to functions like + # pool.FindExtensionByNumber(descriptor). + if descriptor.file is not None: + # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available. + pool = descriptor.file.pool + cls._extensions_by_number = pool._extensions_by_number[descriptor] + cls._extensions_by_name = pool._extensions_by_name[descriptor] def _AddStaticMethods(cls): # TODO(robinson): This probably needs to be thread-safe(?) def RegisterExtension(extension_handle): extension_handle.containing_type = cls.DESCRIPTOR + # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available. + cls.DESCRIPTOR.file.pool.AddExtensionDescriptor(extension_handle) _AttachFieldHelpers(cls, extension_handle) - - # Try to insert our extension, failing if an extension with the same number - # already exists. - actual_handle = cls._extensions_by_number.setdefault( - extension_handle.number, extension_handle) - if actual_handle is not extension_handle: - raise AssertionError( - 'Extensions "%s" and "%s" both try to extend message type "%s" with ' - 'field number %d.' % - (extension_handle.full_name, actual_handle.full_name, - cls.DESCRIPTOR.full_name, extension_handle.number)) - - cls._extensions_by_name[extension_handle.full_name] = extension_handle - - handle = extension_handle # avoid line wrapping - if _IsMessageSetExtension(handle): - # MessageSet extension. Also register under type name. - cls._extensions_by_name[ - extension_handle.message_type.full_name] = extension_handle - cls.RegisterExtension = staticmethod(RegisterExtension) def FromString(s): @@ -1230,7 +1217,7 @@ def _AddMergeFromMethod(cls): if not isinstance(msg, cls): raise TypeError( "Parameter to MergeFrom() must be instance of same class: " - "expected %s got %s." % (cls.__name__, type(msg).__name__)) + 'expected %s got %s.' % (cls.__name__, msg.__class__.__name__)) assert msg is not self self._Modified() diff --git a/python/google/protobuf/internal/reflection_test.py b/python/google/protobuf/internal/reflection_test.py index dad79c37..0e881015 100755 --- a/python/google/protobuf/internal/reflection_test.py +++ b/python/google/protobuf/internal/reflection_test.py @@ -99,12 +99,12 @@ class _MiniDecoder(object): return wire_format.UnpackTag(self.ReadVarint()) def ReadFloat(self): - result = struct.unpack("<f", self._bytes[self._pos:self._pos+4])[0] + result = struct.unpack('<f', self._bytes[self._pos:self._pos+4])[0] self._pos += 4 return result def ReadDouble(self): - result = struct.unpack("<d", self._bytes[self._pos:self._pos+8])[0] + result = struct.unpack('<d', self._bytes[self._pos:self._pos+8])[0] self._pos += 8 return result @@ -621,9 +621,15 @@ class ReflectionTest(BaseTestCase): self.assertRaises(TypeError, setattr, proto, 'optional_string', 10) self.assertRaises(TypeError, setattr, proto, 'optional_bytes', 10) - def testIntegerTypes(self): + def assertIntegerTypes(self, integer_fn): + """Verifies setting of scalar integers. + + Args: + integer_fn: A function to wrap the integers that will be assigned. + """ def TestGetAndDeserialize(field_name, value, expected_type): proto = unittest_pb2.TestAllTypes() + value = integer_fn(value) setattr(proto, field_name, value) self.assertIsInstance(getattr(proto, field_name), expected_type) proto2 = unittest_pb2.TestAllTypes() @@ -635,7 +641,7 @@ class ReflectionTest(BaseTestCase): TestGetAndDeserialize('optional_uint32', 1 << 30, int) try: integer_64 = long - except NameError: # Python3 + except NameError: # Python3 integer_64 = int if struct.calcsize('L') == 4: # Python only has signed ints, so 32-bit python can't fit an uint32 @@ -649,9 +655,33 @@ class ReflectionTest(BaseTestCase): TestGetAndDeserialize('optional_uint64', 1 << 30, integer_64) TestGetAndDeserialize('optional_uint64', 1 << 60, integer_64) - def testSingleScalarBoundsChecking(self): + def testIntegerTypes(self): + self.assertIntegerTypes(lambda x: x) + + def testNonStandardIntegerTypes(self): + self.assertIntegerTypes(test_util.NonStandardInteger) + + def testIllegalValuesForIntegers(self): + pb = unittest_pb2.TestAllTypes() + + # Strings are illegal, even when the represent an integer. + with self.assertRaises(TypeError): + pb.optional_uint64 = '2' + + # The exact error should propagate with a poorly written custom integer. + with self.assertRaisesRegexp(RuntimeError, 'my_error'): + pb.optional_uint64 = test_util.NonStandardInteger(5, 'my_error') + + def assetIntegerBoundsChecking(self, integer_fn): + """Verifies bounds checking for scalar integer fields. + + Args: + integer_fn: A function to wrap the integers that will be assigned. + """ def TestMinAndMaxIntegers(field_name, expected_min, expected_max): pb = unittest_pb2.TestAllTypes() + expected_min = integer_fn(expected_min) + expected_max = integer_fn(expected_max) setattr(pb, field_name, expected_min) self.assertEqual(expected_min, getattr(pb, field_name)) setattr(pb, field_name, expected_max) @@ -663,11 +693,22 @@ class ReflectionTest(BaseTestCase): TestMinAndMaxIntegers('optional_uint32', 0, 0xffffffff) TestMinAndMaxIntegers('optional_int64', -(1 << 63), (1 << 63) - 1) TestMinAndMaxIntegers('optional_uint64', 0, 0xffffffffffffffff) + # A bit of white-box testing since -1 is an int and not a long in C++ and + # so goes down a different path. + pb = unittest_pb2.TestAllTypes() + with self.assertRaises(ValueError): + pb.optional_uint64 = integer_fn(-(1 << 63)) pb = unittest_pb2.TestAllTypes() - pb.optional_nested_enum = 1 + pb.optional_nested_enum = integer_fn(1) self.assertEqual(1, pb.optional_nested_enum) + def testSingleScalarBoundsChecking(self): + self.assetIntegerBoundsChecking(lambda x: x) + + def testNonStandardSingleScalarBoundsChecking(self): + self.assetIntegerBoundsChecking(test_util.NonStandardInteger) + def testRepeatedScalarTypeSafety(self): proto = unittest_pb2.TestAllTypes() self.assertRaises(TypeError, proto.repeated_int32.append, 1.1) @@ -1187,12 +1228,18 @@ class ReflectionTest(BaseTestCase): self.assertTrue(not extendee_proto.HasExtension(extension)) def testRegisteredExtensions(self): - self.assertTrue('protobuf_unittest.optional_int32_extension' in - unittest_pb2.TestAllExtensions._extensions_by_name) - self.assertTrue(1 in unittest_pb2.TestAllExtensions._extensions_by_number) + pool = unittest_pb2.DESCRIPTOR.pool + self.assertTrue( + pool.FindExtensionByNumber( + unittest_pb2.TestAllExtensions.DESCRIPTOR, 1)) + self.assertIs( + pool.FindExtensionByName( + 'protobuf_unittest.optional_int32_extension').containing_type, + unittest_pb2.TestAllExtensions.DESCRIPTOR) # Make sure extensions haven't been registered into types that shouldn't # have any. - self.assertEqual(0, len(unittest_pb2.TestAllTypes._extensions_by_name)) + self.assertEqual(0, len( + pool.FindAllExtensions(unittest_pb2.TestAllTypes.DESCRIPTOR))) # If message A directly contains message B, and # a.HasField('b') is currently False, then mutating any diff --git a/python/google/protobuf/internal/test_util.py b/python/google/protobuf/internal/test_util.py index 2c805599..269d0e2d 100755 --- a/python/google/protobuf/internal/test_util.py +++ b/python/google/protobuf/internal/test_util.py @@ -36,8 +36,9 @@ This is intentionally modeled on C++ code in __author__ = 'robinson@google.com (Will Robinson)' +import numbers +import operator import os.path - import sys from google.protobuf import unittest_import_pb2 @@ -694,3 +695,154 @@ def SetAllUnpackedFields(message): message.unpacked_bool.extend([True, False]) message.unpacked_enum.extend([unittest_pb2.FOREIGN_BAR, unittest_pb2.FOREIGN_BAZ]) + + +class NonStandardInteger(numbers.Integral): + """An integer object that does not subclass int. + + This is used to verify that both C++ and regular proto systems can handle + integer others than int and long and that they handle them in predictable + ways. + + NonStandardInteger is the minimal legal specification for a custom Integral. + As such, it does not support 0 < x < 5 and it is not hashable. + + Note: This is added here instead of relying on numpy or a similar library with + custom integers to limit dependencies. + """ + + def __init__(self, val, error_string_on_conversion=None): + assert isinstance(val, numbers.Integral) + if isinstance(val, NonStandardInteger): + val = val.val + self.val = val + self.error_string_on_conversion = error_string_on_conversion + + def __long__(self): + if self.error_string_on_conversion: + raise RuntimeError(self.error_string_on_conversion) + return long(self.val) + + def __abs__(self): + return NonStandardInteger(operator.abs(self.val)) + + def __add__(self, y): + return NonStandardInteger(operator.add(self.val, y)) + + def __div__(self, y): + return NonStandardInteger(operator.div(self.val, y)) + + def __eq__(self, y): + return operator.eq(self.val, y) + + def __floordiv__(self, y): + return NonStandardInteger(operator.floordiv(self.val, y)) + + def __truediv__(self, y): + return NonStandardInteger(operator.truediv(self.val, y)) + + def __invert__(self): + return NonStandardInteger(operator.invert(self.val)) + + def __mod__(self, y): + return NonStandardInteger(operator.mod(self.val, y)) + + def __mul__(self, y): + return NonStandardInteger(operator.mul(self.val, y)) + + def __neg__(self): + return NonStandardInteger(operator.neg(self.val)) + + def __pos__(self): + return NonStandardInteger(operator.pos(self.val)) + + def __pow__(self, y): + return NonStandardInteger(operator.pow(self.val, y)) + + def __trunc__(self): + return int(self.val) + + def __radd__(self, y): + return NonStandardInteger(operator.add(y, self.val)) + + def __rdiv__(self, y): + return NonStandardInteger(operator.div(y, self.val)) + + def __rmod__(self, y): + return NonStandardInteger(operator.mod(y, self.val)) + + def __rmul__(self, y): + return NonStandardInteger(operator.mul(y, self.val)) + + def __rpow__(self, y): + return NonStandardInteger(operator.pow(y, self.val)) + + def __rfloordiv__(self, y): + return NonStandardInteger(operator.floordiv(y, self.val)) + + def __rtruediv__(self, y): + return NonStandardInteger(operator.truediv(y, self.val)) + + def __lshift__(self, y): + return NonStandardInteger(operator.lshift(self.val, y)) + + def __rshift__(self, y): + return NonStandardInteger(operator.rshift(self.val, y)) + + def __rlshift__(self, y): + return NonStandardInteger(operator.lshift(y, self.val)) + + def __rrshift__(self, y): + return NonStandardInteger(operator.rshift(y, self.val)) + + def __le__(self, y): + if isinstance(y, NonStandardInteger): + y = y.val + return operator.le(self.val, y) + + def __lt__(self, y): + if isinstance(y, NonStandardInteger): + y = y.val + return operator.lt(self.val, y) + + def __and__(self, y): + return NonStandardInteger(operator.and_(self.val, y)) + + def __or__(self, y): + return NonStandardInteger(operator.or_(self.val, y)) + + def __xor__(self, y): + return NonStandardInteger(operator.xor(self.val, y)) + + def __rand__(self, y): + return NonStandardInteger(operator.and_(y, self.val)) + + def __ror__(self, y): + return NonStandardInteger(operator.or_(y, self.val)) + + def __rxor__(self, y): + return NonStandardInteger(operator.xor(y, self.val)) + + def __bool__(self): + return self.val + + def __nonzero__(self): + return self.val + + def __ceil__(self): + return self + + def __floor__(self): + return self + + def __int__(self): + if self.error_string_on_conversion: + raise RuntimeError(self.error_string_on_conversion) + return int(self.val) + + def __round__(self): + return self + + def __repr__(self): + return 'NonStandardInteger(%s)' % self.val + diff --git a/python/google/protobuf/internal/testing_refleaks.py b/python/google/protobuf/internal/testing_refleaks.py index c461a9f4..8ce06519 100644 --- a/python/google/protobuf/internal/testing_refleaks.py +++ b/python/google/protobuf/internal/testing_refleaks.py @@ -124,5 +124,3 @@ else: def Same(func): return func return Same - - diff --git a/python/google/protobuf/internal/text_format_test.py b/python/google/protobuf/internal/text_format_test.py index ab481ab4..176cbd15 100755 --- a/python/google/protobuf/internal/text_format_test.py +++ b/python/google/protobuf/internal/text_format_test.py @@ -582,22 +582,20 @@ class OnlyWorksWithProto2RightNowTests(TextFormatBase): % (letter,) for letter in string.ascii_uppercase)) self.CompareToGoldenText(text_format.MessageToString(message), golden) - def testMapOrderSemantics(self): - golden_lines = self.ReadGolden('map_test_data.txt') - # The C++ implementation emits defaulted-value fields, while the Python - # implementation does not. Adjusting for this is awkward, but it is - # valuable to test against a common golden file. - line_blacklist = (' key: 0\n', ' value: 0\n', ' key: false\n', - ' value: false\n') - golden_lines = [line for line in golden_lines if line not in line_blacklist] - - message = map_unittest_pb2.TestMap() - text_format.ParseLines(golden_lines, message) - candidate = text_format.MessageToString(message) - # The Python implementation emits "1.0" for the double value that the C++ - # implementation emits as "1". - candidate = candidate.replace('1.0', '1', 2) - self.assertMultiLineEqual(candidate, ''.join(golden_lines)) + # TODO(teboring): In c/137553523, not serializing default value for map entry + # message has been fixed. This test needs to be disabled in order to submit + # that cl. Add this back when c/137553523 has been submitted. + # def testMapOrderSemantics(self): + # golden_lines = self.ReadGolden('map_test_data.txt') + + # message = map_unittest_pb2.TestMap() + # text_format.ParseLines(golden_lines, message) + # candidate = text_format.MessageToString(message) + # # The Python implementation emits "1.0" for the double value that the C++ + # # implementation emits as "1". + # candidate = candidate.replace('1.0', '1', 2) + # candidate = candidate.replace('0.0', '0', 2) + # self.assertMultiLineEqual(candidate, ''.join(golden_lines)) # Tests of proto2-only features (MessageSet, extensions, etc.). diff --git a/python/google/protobuf/internal/type_checkers.py b/python/google/protobuf/internal/type_checkers.py index 1be3ad9a..4a76cd4e 100755 --- a/python/google/protobuf/internal/type_checkers.py +++ b/python/google/protobuf/internal/type_checkers.py @@ -45,6 +45,7 @@ TYPE_TO_DESERIALIZE_METHOD: A dictionary with field types and deserialization __author__ = 'robinson@google.com (Will Robinson)' +import numbers import six if six.PY3: @@ -126,11 +127,11 @@ class IntValueChecker(object): """Checker used for integer fields. Performs type-check and range check.""" def CheckValue(self, proposed_value): - if not isinstance(proposed_value, six.integer_types): + if not isinstance(proposed_value, numbers.Integral): message = ('%.1024r has type %s, but expected one of: %s' % (proposed_value, type(proposed_value), six.integer_types)) raise TypeError(message) - if not self._MIN <= proposed_value <= self._MAX: + if not self._MIN <= int(proposed_value) <= self._MAX: raise ValueError('Value out of range: %d' % proposed_value) # We force 32-bit values to int and 64-bit values to long to make # alternate implementations where the distinction is more significant @@ -150,11 +151,11 @@ class EnumValueChecker(object): self._enum_type = enum_type def CheckValue(self, proposed_value): - if not isinstance(proposed_value, six.integer_types): + if not isinstance(proposed_value, numbers.Integral): message = ('%.1024r has type %s, but expected one of: %s' % (proposed_value, type(proposed_value), six.integer_types)) raise TypeError(message) - if proposed_value not in self._enum_type.values_by_number: + if int(proposed_value) not in self._enum_type.values_by_number: raise ValueError('Unknown enum value: %d' % proposed_value) return proposed_value @@ -223,11 +224,11 @@ _VALUE_CHECKERS = { _FieldDescriptor.CPPTYPE_UINT32: Uint32ValueChecker(), _FieldDescriptor.CPPTYPE_UINT64: Uint64ValueChecker(), _FieldDescriptor.CPPTYPE_DOUBLE: TypeCheckerWithDefault( - 0.0, float, int, long), + 0.0, numbers.Real), _FieldDescriptor.CPPTYPE_FLOAT: TypeCheckerWithDefault( - 0.0, float, int, long), + 0.0, numbers.Real), _FieldDescriptor.CPPTYPE_BOOL: TypeCheckerWithDefault( - False, bool, int), + False, bool, numbers.Integral), _FieldDescriptor.CPPTYPE_STRING: TypeCheckerWithDefault(b'', bytes), } diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py index c42371d0..d02cb091 100644 --- a/python/google/protobuf/json_format.py +++ b/python/google/protobuf/json_format.py @@ -43,9 +43,9 @@ Simple usage example: __author__ = 'jieluo@google.com (Jie Luo)' try: - from collections import OrderedDict + from collections import OrderedDict except ImportError: - from ordereddict import OrderedDict #PY26 + from ordereddict import OrderedDict #PY26 import base64 import json import math diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc index a42e5431..fa66bf9a 100644 --- a/python/google/protobuf/pyext/descriptor_pool.cc +++ b/python/google/protobuf/pyext/descriptor_pool.cc @@ -319,6 +319,51 @@ PyObject* FindFileContainingSymbol(PyDescriptorPool* self, PyObject* arg) { return PyFileDescriptor_FromDescriptor(file_descriptor); } +PyObject* FindExtensionByNumber(PyDescriptorPool* self, PyObject* args) { + PyObject* message_descriptor; + int number; + if (!PyArg_ParseTuple(args, "Oi", &message_descriptor, &number)) { + return NULL; + } + const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor( + message_descriptor); + if (descriptor == NULL) { + return NULL; + } + + const FieldDescriptor* extension_descriptor = + self->pool->FindExtensionByNumber(descriptor, number); + if (extension_descriptor == NULL) { + PyErr_Format(PyExc_KeyError, "Couldn't find extension %d", number); + return NULL; + } + + return PyFieldDescriptor_FromDescriptor(extension_descriptor); +} + +PyObject* FindAllExtensions(PyDescriptorPool* self, PyObject* arg) { + const Descriptor* descriptor = PyMessageDescriptor_AsDescriptor(arg); + if (descriptor == NULL) { + return NULL; + } + + std::vector<const FieldDescriptor*> extensions; + self->pool->FindAllExtensions(descriptor, &extensions); + + ScopedPyObjectPtr result(PyList_New(extensions.size())); + if (result == NULL) { + return NULL; + } + for (int i = 0; i < extensions.size(); i++) { + PyObject* extension = PyFieldDescriptor_FromDescriptor(extensions[i]); + if (extension == NULL) { + return NULL; + } + PyList_SET_ITEM(result.get(), i, extension); // Steals the reference. + } + return result.release(); +} + // These functions should not exist -- the only valid way to create // descriptors is to call Add() or AddSerializedFile(). // But these AddDescriptor() functions were created in Python and some people @@ -376,6 +421,22 @@ PyObject* AddEnumDescriptor(PyDescriptorPool* self, PyObject* descriptor) { Py_RETURN_NONE; } +PyObject* AddExtensionDescriptor(PyDescriptorPool* self, PyObject* descriptor) { + const FieldDescriptor* extension_descriptor = + PyFieldDescriptor_AsDescriptor(descriptor); + if (!extension_descriptor) { + return NULL; + } + if (extension_descriptor != + self->pool->FindExtensionByName(extension_descriptor->full_name())) { + PyErr_Format(PyExc_ValueError, + "The extension descriptor %s does not belong to this pool", + extension_descriptor->full_name().c_str()); + return NULL; + } + Py_RETURN_NONE; +} + // The code below loads new Descriptors from a serialized FileDescriptorProto. @@ -475,6 +536,8 @@ static PyMethodDef Methods[] = { "No-op. Add() must have been called before." }, { "AddEnumDescriptor", (PyCFunction)AddEnumDescriptor, METH_O, "No-op. Add() must have been called before." }, + { "AddExtensionDescriptor", (PyCFunction)AddExtensionDescriptor, METH_O, + "No-op. Add() must have been called before." }, { "FindFileByName", (PyCFunction)FindFileByName, METH_O, "Searches for a file descriptor by its .proto name." }, @@ -495,6 +558,10 @@ static PyMethodDef Methods[] = { { "FindFileContainingSymbol", (PyCFunction)FindFileContainingSymbol, METH_O, "Gets the FileDescriptor containing the specified symbol." }, + { "FindExtensionByNumber", (PyCFunction)FindExtensionByNumber, METH_VARARGS, + "Gets the extension descriptor for the given number." }, + { "FindAllExtensions", (PyCFunction)FindAllExtensions, METH_O, + "Gets all known extensions of the given message descriptor." }, {NULL} }; diff --git a/python/google/protobuf/pyext/extension_dict.cc b/python/google/protobuf/pyext/extension_dict.cc index dbb7bca0..9423c1d8 100644 --- a/python/google/protobuf/pyext/extension_dict.cc +++ b/python/google/protobuf/pyext/extension_dict.cc @@ -38,6 +38,7 @@ #include <google/protobuf/descriptor.h> #include <google/protobuf/dynamic_message.h> #include <google/protobuf/message.h> +#include <google/protobuf/descriptor.pb.h> #include <google/protobuf/pyext/descriptor.h> #include <google/protobuf/pyext/message.h> #include <google/protobuf/pyext/message_factory.h> @@ -46,6 +47,16 @@ #include <google/protobuf/pyext/scoped_pyobject_ptr.h> #include <google/protobuf/stubs/shared_ptr.h> +#if PY_MAJOR_VERSION >= 3 + #if PY_VERSION_HEX < 0x03030000 + #error "Python 3.0 - 3.2 are not supported." + #endif + #define PyString_AsStringAndSize(ob, charpp, sizep) \ + (PyUnicode_Check(ob)? \ + ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \ + PyBytes_AsStringAndSize(ob, (charpp), (sizep))) +#endif + namespace google { namespace protobuf { namespace python { @@ -90,6 +101,7 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) { if (descriptor->label() != FieldDescriptor::LABEL_REPEATED && descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + // TODO(plabatut): consider building the class on the fly! PyObject* sub_message = cmessage::InternalGetSubMessage( self->parent, descriptor); if (sub_message == NULL) { @@ -101,7 +113,17 @@ PyObject* subscript(ExtensionDict* self, PyObject* key) { if (descriptor->label() == FieldDescriptor::LABEL_REPEATED) { if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - CMessageClass* message_class = message_factory::GetMessageClass( + // On the fly message class creation is needed to support the following + // situation: + // 1- add FileDescriptor to the pool that contains extensions of a message + // defined by another proto file. Do not create any message classes. + // 2- instantiate an extended message, and access the extension using + // the field descriptor. + // 3- the extension submessage fails to be returned, because no class has + // been created. + // It happens when deserializing text proto format, or when enumerating + // fields of a deserialized message. + CMessageClass* message_class = message_factory::GetOrCreateMessageClass( cmessage::GetFactoryForMessage(self->parent), descriptor->message_type()); if (message_class == NULL) { @@ -154,34 +176,51 @@ int ass_subscript(ExtensionDict* self, PyObject* key, PyObject* value) { return 0; } -PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* name) { - ScopedPyObjectPtr extensions_by_name(PyObject_GetAttrString( - reinterpret_cast<PyObject*>(self->parent), "_extensions_by_name")); - if (extensions_by_name == NULL) { +PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) { + char* name; + Py_ssize_t name_size; + if (PyString_AsStringAndSize(arg, &name, &name_size) < 0) { return NULL; } - PyObject* result = PyDict_GetItem(extensions_by_name.get(), name); - if (result == NULL) { + + PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool; + const FieldDescriptor* message_extension = + pool->pool->FindExtensionByName(string(name, name_size)); + if (message_extension == NULL) { + // Is is the name of a message set extension? + const Descriptor* message_descriptor = pool->pool->FindMessageTypeByName( + string(name, name_size)); + if (message_descriptor && message_descriptor->extension_count() > 0) { + const FieldDescriptor* extension = message_descriptor->extension(0); + if (extension->is_extension() && + extension->containing_type()->options().message_set_wire_format() && + extension->type() == FieldDescriptor::TYPE_MESSAGE && + extension->label() == FieldDescriptor::LABEL_OPTIONAL) { + message_extension = extension; + } + } + } + if (message_extension == NULL) { Py_RETURN_NONE; - } else { - Py_INCREF(result); - return result; } + + return PyFieldDescriptor_FromDescriptor(message_extension); } -PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* number) { - ScopedPyObjectPtr extensions_by_number(PyObject_GetAttrString( - reinterpret_cast<PyObject*>(self->parent), "_extensions_by_number")); - if (extensions_by_number == NULL) { +PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* arg) { + int64 number = PyLong_AsLong(arg); + if (number == -1 && PyErr_Occurred()) { return NULL; } - PyObject* result = PyDict_GetItem(extensions_by_number.get(), number); - if (result == NULL) { + + PyDescriptorPool* pool = cmessage::GetFactoryForMessage(self->parent)->pool; + const FieldDescriptor* message_extension = pool->pool->FindExtensionByNumber( + self->parent->message->GetDescriptor(), number); + if (message_extension == NULL) { Py_RETURN_NONE; - } else { - Py_INCREF(result); - return result; } + + return PyFieldDescriptor_FromDescriptor(message_extension); } ExtensionDict* NewExtensionDict(CMessage *parent) { diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index 318c2e7c..088ddf93 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -374,7 +374,7 @@ static int InitializeAndCopyToParentContainer(MapContainer* from, // A somewhat roundabout way of copying just one field from old_message to // new_message. This is the best we can do with what Reflection gives us. Message* mutable_old = from->GetMutableMessage(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; fields.push_back(from->parent_field_descriptor); // Move the map field into the new message. diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 6626ddef..4f3abc84 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -64,11 +64,11 @@ #include <google/protobuf/pyext/repeated_scalar_container.h> #include <google/protobuf/pyext/map_container.h> #include <google/protobuf/pyext/message_factory.h> +#include <google/protobuf/pyext/safe_numerics.h> #include <google/protobuf/pyext/scoped_pyobject_ptr.h> #include <google/protobuf/stubs/strutil.h> #if PY_MAJOR_VERSION >= 3 - #define PyInt_Check PyLong_Check #define PyInt_AsLong PyLong_AsLong #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t @@ -92,8 +92,6 @@ namespace protobuf { namespace python { static PyObject* kDESCRIPTOR; -static PyObject* k_extensions_by_name; -static PyObject* k_extensions_by_number; PyObject* EnumTypeWrapper_class; static PyObject* PythonMessage_class; static PyObject* kEmptyWeakref; @@ -128,19 +126,6 @@ static bool AddFieldNumberToClass( // Finalize the creation of the Message class. static int AddDescriptors(PyObject* cls, const Descriptor* descriptor) { - // If there are extension_ranges, the message is "extendable", and extension - // classes will register themselves in this class. - if (descriptor->extension_range_count() > 0) { - ScopedPyObjectPtr by_name(PyDict_New()); - if (PyObject_SetAttr(cls, k_extensions_by_name, by_name.get()) < 0) { - return -1; - } - ScopedPyObjectPtr by_number(PyDict_New()); - if (PyObject_SetAttr(cls, k_extensions_by_number, by_number.get()) < 0) { - return -1; - } - } - // For each field set: cls.<field>_FIELD_NUMBER = <number> for (int i = 0; i < descriptor->field_count(); ++i) { if (!AddFieldNumberToClass(cls, descriptor->field(i))) { @@ -357,6 +342,61 @@ static int InsertEmptyWeakref(PyTypeObject *base_type) { #endif // PY_MAJOR_VERSION >= 3 } +// The _extensions_by_name dictionary is built on every access. +// TODO(amauryfa): Migrate all users to pool.FindAllExtensions() +static PyObject* GetExtensionsByName(CMessageClass *self, void *closure) { + const PyDescriptorPool* pool = self->py_message_factory->pool; + + std::vector<const FieldDescriptor*> extensions; + pool->pool->FindAllExtensions(self->message_descriptor, &extensions); + + ScopedPyObjectPtr result(PyDict_New()); + for (int i = 0; i < extensions.size(); i++) { + ScopedPyObjectPtr extension( + PyFieldDescriptor_FromDescriptor(extensions[i])); + if (extension == NULL) { + return NULL; + } + if (PyDict_SetItemString(result.get(), extensions[i]->full_name().c_str(), + extension.get()) < 0) { + return NULL; + } + } + return result.release(); +} + +// The _extensions_by_number dictionary is built on every access. +// TODO(amauryfa): Migrate all users to pool.FindExtensionByNumber() +static PyObject* GetExtensionsByNumber(CMessageClass *self, void *closure) { + const PyDescriptorPool* pool = self->py_message_factory->pool; + + std::vector<const FieldDescriptor*> extensions; + pool->pool->FindAllExtensions(self->message_descriptor, &extensions); + + ScopedPyObjectPtr result(PyDict_New()); + for (int i = 0; i < extensions.size(); i++) { + ScopedPyObjectPtr extension( + PyFieldDescriptor_FromDescriptor(extensions[i])); + if (extension == NULL) { + return NULL; + } + ScopedPyObjectPtr number(PyInt_FromLong(extensions[i]->number())); + if (number == NULL) { + return NULL; + } + if (PyDict_SetItem(result.get(), number.get(), extension.get()) < 0) { + return NULL; + } + } + return result.release(); +} + +static PyGetSetDef Getters[] = { + {"_extensions_by_name", (getter)GetExtensionsByName, NULL}, + {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL}, + {NULL} +}; + } // namespace message_meta PyTypeObject CMessageClass_Type = { @@ -389,7 +429,7 @@ PyTypeObject CMessageClass_Type = { 0, // tp_iternext 0, // tp_methods 0, // tp_members - 0, // tp_getset + message_meta::Getters, // tp_getset 0, // tp_base 0, // tp_dict 0, // tp_descr_get @@ -525,23 +565,10 @@ int ForEachCompositeField(CMessage* self, Visitor visitor) { // --------------------------------------------------------------------- -// Constants used for integer type range checking. -PyObject* kPythonZero; -PyObject* kint32min_py; -PyObject* kint32max_py; -PyObject* kuint32max_py; -PyObject* kint64min_py; -PyObject* kint64max_py; -PyObject* kuint64max_py; - PyObject* EncodeError_class; PyObject* DecodeError_class; PyObject* PickleError_class; -// Constant PyString values used for GetAttr/GetItem. -static PyObject* k_cdescriptor; -static PyObject* kfull_name; - /* Is 64bit */ void FormatTypeError(PyObject* arg, char* expected_types) { PyObject* repr = PyObject_Repr(arg); @@ -555,68 +582,126 @@ void FormatTypeError(PyObject* arg, char* expected_types) { } } -template<class T> -bool CheckAndGetInteger( - PyObject* arg, T* value, PyObject* min, PyObject* max) { - bool is_long = PyLong_Check(arg); -#if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(arg) && !is_long) { - FormatTypeError(arg, "int, long"); - return false; +void OutOfRangeError(PyObject* arg) { + PyObject *s = PyObject_Str(arg); + if (s) { + PyErr_Format(PyExc_ValueError, + "Value out of range: %s", + PyString_AsString(s)); + Py_DECREF(s); } - if (PyObject_Compare(min, arg) > 0 || PyObject_Compare(max, arg) < 0) { -#else - if (!is_long) { - FormatTypeError(arg, "int"); +} + +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 (PyObject_RichCompareBool(min, arg, Py_LE) != 1 || - PyObject_RichCompareBool(max, arg, Py_GE) != 1) { -#endif - if (!PyErr_Occurred()) { - PyObject *s = PyObject_Str(arg); - if (s) { - PyErr_Format(PyExc_ValueError, - "Value out of range: %s", - PyString_AsString(s)); - Py_DECREF(s); - } - } + if GOOGLE_PREDICT_FALSE(!IsValidNumericCast<RangeType>(value)) { + OutOfRangeError(arg); return false; } + return true; +} + +template<class T> +bool CheckAndGetInteger(PyObject* arg, T* value) { + // The fast path. #if PY_MAJOR_VERSION < 3 - if (!is_long) { - *value = static_cast<T>(PyInt_AsLong(arg)); - } else // NOLINT + // 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; + } + } #endif - { - if (min == kPythonZero) { - *value = static_cast<T>(PyLong_AsUnsignedLongLong(arg)); + // 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)) { + FormatTypeError(arg, "int, long"); + return false; + } + + // Now we have an integral number so we can safely use PyLong_ functions. + // We need to treat the signed and unsigned cases differently in case arg is + // holding a value above the maximum for signed longs. + if (std::numeric_limits<T>::min() == 0) { + // Unsigned case. + unsigned PY_LONG_LONG ulong_result; + if (PyLong_Check(arg)) { + ulong_result = PyLong_AsUnsignedLongLong(arg); + } else { + // 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; + } + ulong_result = PyLong_AsUnsignedLongLong(casted); + Py_DECREF(casted); + } + if (VerifyIntegerCastAndRange<T, unsigned PY_LONG_LONG>(arg, + ulong_result)) { + *value = static_cast<T>(ulong_result); + } else { + return false; + } + } else { + // Signed case. + PY_LONG_LONG long_result; + PyNumberMethods *nb; + if ((nb = arg->ob_type->tp_as_number) != NULL && nb->nb_int != NULL) { + // PyLong_AsLongLong requires it to be a long or to have an __int__() + // method. + long_result = PyLong_AsLongLong(arg); } else { - *value = static_cast<T>(PyLong_AsLongLong(arg)); + // 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; + } + long_result = PyLong_AsLongLong(casted); + Py_DECREF(casted); + } + if (VerifyIntegerCastAndRange<T, PY_LONG_LONG>(arg, long_result)) { + *value = static_cast<T>(long_result); + } else { + return false; } } + return true; } // These are referenced by repeated_scalar_container, and must // be explicitly instantiated. -template bool CheckAndGetInteger<int32>( - PyObject*, int32*, PyObject*, PyObject*); -template bool CheckAndGetInteger<int64>( - PyObject*, int64*, PyObject*, PyObject*); -template bool CheckAndGetInteger<uint32>( - PyObject*, uint32*, PyObject*, PyObject*); -template bool CheckAndGetInteger<uint64>( - PyObject*, uint64*, PyObject*, PyObject*); +template bool CheckAndGetInteger<int32>(PyObject*, int32*); +template bool CheckAndGetInteger<int64>(PyObject*, int64*); +template bool CheckAndGetInteger<uint32>(PyObject*, uint32*); +template bool CheckAndGetInteger<uint64>(PyObject*, uint64*); bool CheckAndGetDouble(PyObject* arg, double* value) { - if (!PyInt_Check(arg) && !PyLong_Check(arg) && - !PyFloat_Check(arg)) { + *value = PyFloat_AsDouble(arg); + if GOOGLE_PREDICT_FALSE(*value == -1 && PyErr_Occurred()) { FormatTypeError(arg, "int, long, float"); return false; } - *value = PyFloat_AsDouble(arg); return true; } @@ -630,11 +715,13 @@ bool CheckAndGetFloat(PyObject* arg, float* value) { } bool CheckAndGetBool(PyObject* arg, bool* value) { - if (!PyInt_Check(arg) && !PyBool_Check(arg) && !PyLong_Check(arg)) { + long long_value = PyInt_AsLong(arg); + if (long_value == -1 && PyErr_Occurred()) { FormatTypeError(arg, "int, long, bool"); return false; } - *value = static_cast<bool>(PyInt_AsLong(arg)); + *value = static_cast<bool>(long_value); + return true; } @@ -966,20 +1053,7 @@ int InternalDeleteRepeatedField( int min, max; length = reflection->FieldSize(*message, field_descriptor); - if (PyInt_Check(slice) || PyLong_Check(slice)) { - from = to = PyLong_AsLong(slice); - if (from < 0) { - from = to = length + from; - } - step = 1; - min = max = from; - - // Range check. - if (from < 0 || from >= length) { - PyErr_Format(PyExc_IndexError, "list assignment index out of range"); - return -1; - } - } else if (PySlice_Check(slice)) { + if (PySlice_Check(slice)) { from = to = step = slice_length = 0; PySlice_GetIndicesEx( #if PY_MAJOR_VERSION < 3 @@ -996,8 +1070,23 @@ int InternalDeleteRepeatedField( max = from; } } else { - PyErr_SetString(PyExc_TypeError, "list indices must be integers"); - return -1; + from = to = PyLong_AsLong(slice); + if (from == -1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "list indices must be integers"); + return -1; + } + + if (from < 0) { + from = to = length + from; + } + step = 1; + min = max = from; + + // Range check. + if (from < 0 || from >= length) { + PyErr_Format(PyExc_IndexError, "list assignment index out of range"); + return -1; + } } Py_ssize_t i = from; @@ -1962,99 +2051,29 @@ static PyObject* ByteSize(CMessage* self, PyObject* args) { return PyLong_FromLong(self->message->ByteSize()); } -static PyObject* RegisterExtension(PyObject* cls, - PyObject* extension_handle) { +PyObject* RegisterExtension(PyObject* cls, PyObject* extension_handle) { const FieldDescriptor* descriptor = GetExtensionDescriptor(extension_handle); if (descriptor == NULL) { return NULL; } - - ScopedPyObjectPtr extensions_by_name( - PyObject_GetAttr(cls, k_extensions_by_name)); - if (extensions_by_name == NULL) { - PyErr_SetString(PyExc_TypeError, "no extensions_by_name on class"); + if (!PyObject_TypeCheck(cls, &CMessageClass_Type)) { + PyErr_Format(PyExc_TypeError, "Expected a message class, got %s", + cls->ob_type->tp_name); return NULL; } - ScopedPyObjectPtr full_name(PyObject_GetAttr(extension_handle, kfull_name)); - if (full_name == NULL) { + CMessageClass *message_class = reinterpret_cast<CMessageClass*>(cls); + if (message_class == NULL) { return NULL; } - // If the extension was already registered, check that it is the same. - PyObject* existing_extension = - PyDict_GetItem(extensions_by_name.get(), full_name.get()); - if (existing_extension != NULL) { - const FieldDescriptor* existing_extension_descriptor = - GetExtensionDescriptor(existing_extension); - if (existing_extension_descriptor != descriptor) { - PyErr_SetString(PyExc_ValueError, "Double registration of Extensions"); - return NULL; - } - // Nothing else to do. - Py_RETURN_NONE; - } - - if (PyDict_SetItem(extensions_by_name.get(), full_name.get(), - extension_handle) < 0) { - return NULL; - } - - // Also store a mapping from extension number to implementing class. - ScopedPyObjectPtr extensions_by_number( - PyObject_GetAttr(cls, k_extensions_by_number)); - if (extensions_by_number == NULL) { - PyErr_SetString(PyExc_TypeError, "no extensions_by_number on class"); - return NULL; - } - - ScopedPyObjectPtr number(PyObject_GetAttrString(extension_handle, "number")); - if (number == NULL) { - return NULL; - } - - // If the extension was already registered by number, check that it is the - // same. - existing_extension = PyDict_GetItem(extensions_by_number.get(), number.get()); - if (existing_extension != NULL) { - const FieldDescriptor* existing_extension_descriptor = - GetExtensionDescriptor(existing_extension); - if (existing_extension_descriptor != descriptor) { - const Descriptor* msg_desc = GetMessageDescriptor( - reinterpret_cast<PyTypeObject*>(cls)); - PyErr_Format( - PyExc_ValueError, - "Extensions \"%s\" and \"%s\" both try to extend message type " - "\"%s\" with field number %ld.", - existing_extension_descriptor->full_name().c_str(), - descriptor->full_name().c_str(), - msg_desc->full_name().c_str(), - PyInt_AsLong(number.get())); - return NULL; - } - // Nothing else to do. - Py_RETURN_NONE; - } - if (PyDict_SetItem(extensions_by_number.get(), number.get(), - extension_handle) < 0) { + const FieldDescriptor* existing_extension = + message_class->py_message_factory->pool->pool->FindExtensionByNumber( + descriptor->containing_type(), descriptor->number()); + if (existing_extension != NULL && existing_extension != descriptor) { + PyErr_SetString(PyExc_ValueError, "Double registration of Extensions"); return NULL; } - - // Check if it's a message set - if (descriptor->is_extension() && - descriptor->containing_type()->options().message_set_wire_format() && - descriptor->type() == FieldDescriptor::TYPE_MESSAGE && - descriptor->label() == FieldDescriptor::LABEL_OPTIONAL) { - ScopedPyObjectPtr message_name(PyString_FromStringAndSize( - descriptor->message_type()->full_name().c_str(), - descriptor->message_type()->full_name().size())); - if (message_name == NULL) { - return NULL; - } - PyDict_SetItem(extensions_by_name.get(), message_name.get(), - extension_handle); - } - Py_RETURN_NONE; } @@ -2091,7 +2110,7 @@ static PyObject* WhichOneof(CMessage* self, PyObject* arg) { static PyObject* GetExtensionDict(CMessage* self, void *closure); static PyObject* ListFields(CMessage* self) { - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; self->message->GetReflection()->ListFields(*self->message, &fields); // Normally, the list will be exactly the size of the fields. @@ -2182,7 +2201,7 @@ static PyObject* DiscardUnknownFields(CMessage* self) { PyObject* FindInitializationErrors(CMessage* self) { Message* message = self->message; - vector<string> errors; + std::vector<string> errors; message->FindInitializationErrors(&errors); PyObject* error_list = PyList_New(errors.size()); @@ -2574,11 +2593,24 @@ static PyObject* GetExtensionDict(CMessage* self, void *closure) { return NULL; } +static PyObject* GetExtensionsByName(CMessage *self, void *closure) { + return message_meta::GetExtensionsByName( + reinterpret_cast<CMessageClass*>(Py_TYPE(self)), closure); +} + +static PyObject* GetExtensionsByNumber(CMessage *self, void *closure) { + return message_meta::GetExtensionsByNumber( + reinterpret_cast<CMessageClass*>(Py_TYPE(self)), closure); +} + static PyGetSetDef Getters[] = { {"Extensions", (getter)GetExtensionDict, NULL, "Extension dict"}, + {"_extensions_by_name", (getter)GetExtensionsByName, NULL}, + {"_extensions_by_number", (getter)GetExtensionsByNumber, NULL}, {NULL} }; + static PyMethodDef Methods[] = { { "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, "Makes a deep copy of the class." }, @@ -2839,19 +2871,7 @@ void InitGlobals() { // TODO(gps): Check all return values in this function for NULL and propagate // the error (MemoryError) on up to result in an import failure. These should // also be freed and reset to NULL during finalization. - kPythonZero = PyInt_FromLong(0); - kint32min_py = PyInt_FromLong(kint32min); - kint32max_py = PyInt_FromLong(kint32max); - kuint32max_py = PyLong_FromLongLong(kuint32max); - kint64min_py = PyLong_FromLongLong(kint64min); - kint64max_py = PyLong_FromLongLong(kint64max); - kuint64max_py = PyLong_FromUnsignedLongLong(kuint64max); - kDESCRIPTOR = PyString_FromString("DESCRIPTOR"); - k_cdescriptor = PyString_FromString("_cdescriptor"); - kfull_name = PyString_FromString("full_name"); - k_extensions_by_name = PyString_FromString("_extensions_by_name"); - k_extensions_by_number = PyString_FromString("_extensions_by_number"); PyObject *dummy_obj = PySet_New(NULL); kEmptyWeakref = PyWeakref_NewRef(dummy_obj, NULL); @@ -2891,25 +2911,6 @@ bool InitProto2MessageModule(PyObject *m) { // DESCRIPTOR is set on each protocol buffer message class elsewhere, but set // it here as well to document that subclasses need to set it. PyDict_SetItem(CMessage_Type.tp_dict, kDESCRIPTOR, Py_None); - // Subclasses with message extensions will override _extensions_by_name and - // _extensions_by_number with fresh mutable dictionaries in AddDescriptors. - // All other classes can share this same immutable mapping. - ScopedPyObjectPtr empty_dict(PyDict_New()); - if (empty_dict == NULL) { - return false; - } - ScopedPyObjectPtr immutable_dict(PyDictProxy_New(empty_dict.get())); - if (immutable_dict == NULL) { - return false; - } - if (PyDict_SetItem(CMessage_Type.tp_dict, - k_extensions_by_name, immutable_dict.get()) < 0) { - return false; - } - if (PyDict_SetItem(CMessage_Type.tp_dict, - k_extensions_by_number, immutable_dict.get()) < 0) { - return false; - } PyModule_AddObject(m, "Message", reinterpret_cast<PyObject*>(&CMessage_Type)); diff --git a/python/google/protobuf/pyext/message.h b/python/google/protobuf/pyext/message.h index 1550724c..ce80497e 100644 --- a/python/google/protobuf/pyext/message.h +++ b/python/google/protobuf/pyext/message.h @@ -117,6 +117,7 @@ typedef struct CMessage { PyObject* weakreflist; } CMessage; +extern PyTypeObject CMessageClass_Type; extern PyTypeObject CMessage_Type; @@ -235,6 +236,10 @@ int InitAttributes(CMessage* self, PyObject* args, PyObject* kwargs); PyObject* MergeFrom(CMessage* self, PyObject* arg); +// This method does not do anything beyond checking that no other extension +// 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. // @@ -275,25 +280,25 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg); #define GOOGLE_CHECK_GET_INT32(arg, value, err) \ int32 value; \ - if (!CheckAndGetInteger(arg, &value, kint32min_py, kint32max_py)) { \ + if (!CheckAndGetInteger(arg, &value)) { \ return err; \ } #define GOOGLE_CHECK_GET_INT64(arg, value, err) \ int64 value; \ - if (!CheckAndGetInteger(arg, &value, kint64min_py, kint64max_py)) { \ + if (!CheckAndGetInteger(arg, &value)) { \ return err; \ } #define GOOGLE_CHECK_GET_UINT32(arg, value, err) \ uint32 value; \ - if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint32max_py)) { \ + if (!CheckAndGetInteger(arg, &value)) { \ return err; \ } #define GOOGLE_CHECK_GET_UINT64(arg, value, err) \ uint64 value; \ - if (!CheckAndGetInteger(arg, &value, kPythonZero, kuint64max_py)) { \ + if (!CheckAndGetInteger(arg, &value)) { \ return err; \ } @@ -316,20 +321,11 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg); } -extern PyObject* kPythonZero; -extern PyObject* kint32min_py; -extern PyObject* kint32max_py; -extern PyObject* kuint32max_py; -extern PyObject* kint64min_py; -extern PyObject* kint64max_py; -extern PyObject* kuint64max_py; - #define FULL_MODULE_NAME "google.protobuf.pyext._message" void FormatTypeError(PyObject* arg, char* expected_types); template<class T> -bool CheckAndGetInteger( - PyObject* arg, T* value, PyObject* min, PyObject* max); +bool CheckAndGetInteger(PyObject* arg, T* value); bool CheckAndGetDouble(PyObject* arg, double* value); bool CheckAndGetFloat(PyObject* arg, float* value); bool CheckAndGetBool(PyObject* arg, bool* value); diff --git a/python/google/protobuf/pyext/message_factory.cc b/python/google/protobuf/pyext/message_factory.cc index 2ad89022..e0b45bf2 100644 --- a/python/google/protobuf/pyext/message_factory.cc +++ b/python/google/protobuf/pyext/message_factory.cc @@ -130,6 +130,72 @@ int RegisterMessageClass(PyMessageFactory* self, return 0; } +CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self, + const Descriptor* descriptor) { + // This is the same implementation as MessageFactory.GetPrototype(). + ScopedPyObjectPtr py_descriptor( + PyMessageDescriptor_FromDescriptor(descriptor)); + if (py_descriptor == NULL) { + return NULL; + } + // Do not create a MessageClass that already exists. + hash_map<const Descriptor*, CMessageClass*>::iterator it = + self->classes_by_descriptor->find(descriptor); + if (it != self->classes_by_descriptor->end()) { + Py_INCREF(it->second); + return it->second; + } + // Create a new message class. + ScopedPyObjectPtr args(Py_BuildValue( + "s(){sOsOsO}", descriptor->name().c_str(), + "DESCRIPTOR", py_descriptor.get(), + "__module__", Py_None, + "message_factory", self)); + if (args == NULL) { + return NULL; + } + ScopedPyObjectPtr message_class(PyObject_CallObject( + reinterpret_cast<PyObject*>(&CMessageClass_Type), args.get())); + if (message_class == NULL) { + return NULL; + } + // Create messages class for the messages used by the fields, and registers + // all extensions for these messages during the recursion. + for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) { + const Descriptor* sub_descriptor = + descriptor->field(field_idx)->message_type(); + // It is NULL if the field type is not a message. + if (sub_descriptor != NULL) { + CMessageClass* result = GetOrCreateMessageClass(self, sub_descriptor); + if (result == NULL) { + return NULL; + } + Py_DECREF(result); + } + } + + // Register extensions defined in this message. + for (int ext_idx = 0 ; ext_idx < descriptor->extension_count() ; ext_idx++) { + const FieldDescriptor* extension = descriptor->extension(ext_idx); + ScopedPyObjectPtr py_extended_class( + GetOrCreateMessageClass(self, extension->containing_type()) + ->AsPyObject()); + if (py_extended_class == NULL) { + return NULL; + } + ScopedPyObjectPtr py_extension(PyFieldDescriptor_FromDescriptor(extension)); + if (py_extension == NULL) { + return NULL; + } + ScopedPyObjectPtr result(cmessage::RegisterExtension( + py_extended_class.get(), py_extension.get())); + if (result == NULL) { + return NULL; + } + } + return reinterpret_cast<CMessageClass*>(message_class.release()); +} + // Retrieve the message class added to our database. CMessageClass* GetMessageClass(PyMessageFactory* self, const Descriptor* message_descriptor) { diff --git a/python/google/protobuf/pyext/message_factory.h b/python/google/protobuf/pyext/message_factory.h index 07cccbfb..36092f7e 100644 --- a/python/google/protobuf/pyext/message_factory.h +++ b/python/google/protobuf/pyext/message_factory.h @@ -82,14 +82,14 @@ PyMessageFactory* NewMessageFactory(PyTypeObject* type, PyDescriptorPool* pool); int RegisterMessageClass(PyMessageFactory* self, const Descriptor* message_descriptor, CMessageClass* message_class); - -// Retrieves the Python class registered with the given message descriptor. -// -// Returns a *borrowed* reference if found, otherwise returns NULL with an -// exception set. +// Retrieves the Python class registered with the given message descriptor, or +// fail with a TypeError. Returns a *borrowed* reference. CMessageClass* GetMessageClass(PyMessageFactory* self, const Descriptor* message_descriptor); - +// Retrieves the Python class registered with the given message descriptor. +// The class is created if not done yet. Returns a *new* reference. +CMessageClass* GetOrCreateMessageClass(PyMessageFactory* self, + const Descriptor* message_descriptor); } // namespace message_factory // Initialize objects used by this module. diff --git a/python/google/protobuf/pyext/safe_numerics.h b/python/google/protobuf/pyext/safe_numerics.h new file mode 100644 index 00000000..639ba2c8 --- /dev/null +++ b/python/google/protobuf/pyext/safe_numerics.h @@ -0,0 +1,164 @@ +// 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. + +#ifndef GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__ +#define GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__ +// Copied from chromium with only changes to the namespace. + +#include <limits> + +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/common.h> + +namespace google { +namespace protobuf { +namespace python { + +template <bool SameSize, bool DestLarger, + bool DestIsSigned, bool SourceIsSigned> +struct IsValidNumericCastImpl; + +#define BASE_NUMERIC_CAST_CASE_SPECIALIZATION(A, B, C, D, Code) \ +template <> struct IsValidNumericCastImpl<A, B, C, D> { \ + template <class Source, class DestBounds> static inline bool Test( \ + Source source, DestBounds min, DestBounds max) { \ + return Code; \ + } \ +} + +#define BASE_NUMERIC_CAST_CASE_SAME_SIZE(DestSigned, SourceSigned, Code) \ + BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \ + true, true, DestSigned, SourceSigned, Code); \ + BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \ + true, false, DestSigned, SourceSigned, Code) + +#define BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(DestSigned, SourceSigned, Code) \ + BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \ + false, false, DestSigned, SourceSigned, Code); \ + +#define BASE_NUMERIC_CAST_CASE_DEST_LARGER(DestSigned, SourceSigned, Code) \ + BASE_NUMERIC_CAST_CASE_SPECIALIZATION( \ + false, true, DestSigned, SourceSigned, Code); \ + +// The three top level cases are: +// - Same size +// - Source larger +// - Dest larger +// And for each of those three cases, we handle the 4 different possibilities +// of signed and unsigned. This gives 12 cases to handle, which we enumerate +// below. +// +// The last argument in each of the macros is the actual comparison code. It +// has three arguments available, source (the value), and min/max which are +// the ranges of the destination. + + +// These are the cases where both types have the same size. + +// Both signed. +BASE_NUMERIC_CAST_CASE_SAME_SIZE(true, true, true); +// Both unsigned. +BASE_NUMERIC_CAST_CASE_SAME_SIZE(false, false, true); +// Dest unsigned, Source signed. +BASE_NUMERIC_CAST_CASE_SAME_SIZE(false, true, source >= 0); +// Dest signed, Source unsigned. +// This cast is OK because Dest's max must be less than Source's. +BASE_NUMERIC_CAST_CASE_SAME_SIZE(true, false, + source <= static_cast<Source>(max)); + + +// These are the cases where Source is larger. + +// Both unsigned. +BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(false, false, source <= max); +// Both signed. +BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(true, true, + source >= min && source <= max); +// Dest is unsigned, Source is signed. +BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(false, true, + source >= 0 && source <= max); +// Dest is signed, Source is unsigned. +// This cast is OK because Dest's max must be less than Source's. +BASE_NUMERIC_CAST_CASE_SOURCE_LARGER(true, false, + source <= static_cast<Source>(max)); + + +// These are the cases where Dest is larger. + +// Both unsigned. +BASE_NUMERIC_CAST_CASE_DEST_LARGER(false, false, true); +// Both signed. +BASE_NUMERIC_CAST_CASE_DEST_LARGER(true, true, true); +// Dest is unsigned, Source is signed. +BASE_NUMERIC_CAST_CASE_DEST_LARGER(false, true, source >= 0); +// Dest is signed, Source is unsigned. +BASE_NUMERIC_CAST_CASE_DEST_LARGER(true, false, true); + +#undef BASE_NUMERIC_CAST_CASE_SPECIALIZATION +#undef BASE_NUMERIC_CAST_CASE_SAME_SIZE +#undef BASE_NUMERIC_CAST_CASE_SOURCE_LARGER +#undef BASE_NUMERIC_CAST_CASE_DEST_LARGER + + +// The main test for whether the conversion will under or overflow. +template <class Dest, class Source> +inline bool IsValidNumericCast(Source source) { + typedef std::numeric_limits<Source> SourceLimits; + typedef std::numeric_limits<Dest> DestLimits; + GOOGLE_COMPILE_ASSERT(SourceLimits::is_specialized, argument_must_be_numeric); + GOOGLE_COMPILE_ASSERT(SourceLimits::is_integer, argument_must_be_integral); + GOOGLE_COMPILE_ASSERT(DestLimits::is_specialized, result_must_be_numeric); + GOOGLE_COMPILE_ASSERT(DestLimits::is_integer, result_must_be_integral); + + return IsValidNumericCastImpl< + sizeof(Dest) == sizeof(Source), + (sizeof(Dest) > sizeof(Source)), + DestLimits::is_signed, + SourceLimits::is_signed>::Test( + source, + DestLimits::min(), + DestLimits::max()); +} + +// checked_numeric_cast<> is analogous to static_cast<> for numeric types, +// except that it CHECKs that the specified numeric conversion will not +// overflow or underflow. Floating point arguments are not currently allowed +// (this is COMPILE_ASSERTd), though this could be supported if necessary. +template <class Dest, class Source> +inline Dest checked_numeric_cast(Source source) { + GOOGLE_CHECK(IsValidNumericCast<Dest>(source)); + return static_cast<Dest>(source); +} + +} // namespace python +} // namespace protobuf + +} // namespace google +#endif // GOOGLE_PROTOBUF_PYTHON_CPP_SAFE_NUMERICS_H__ diff --git a/python/setup.py b/python/setup.py index 524a312f..ef1a31b4 100755 --- a/python/setup.py +++ b/python/setup.py @@ -78,6 +78,7 @@ def generate_proto(source, require = True): def GenerateUnittestProtos(): generate_proto("../src/google/protobuf/any_test.proto", False) generate_proto("../src/google/protobuf/map_unittest.proto", False) + generate_proto("../src/google/protobuf/test_messages_proto3.proto", False) generate_proto("../src/google/protobuf/unittest_arena.proto", False) generate_proto("../src/google/protobuf/unittest_no_arena.proto", False) generate_proto("../src/google/protobuf/unittest_no_arena_import.proto", False) diff --git a/ruby/Rakefile b/ruby/Rakefile index ba1cf4cf..40d0a314 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -44,11 +44,11 @@ if RUBY_PLATFORM == "java" raise ArgumentError, "maven needs to be installed" end task :clean do - system("mvn clean") + system("mvn --batch-mode clean") end task :compile do - system("mvn package") + system("mvn --batch-mode package") end else Rake::ExtensionTask.new("protobuf_c", spec) do |ext| diff --git a/ruby/lib/google/protobuf/repeated_field.rb b/ruby/lib/google/protobuf/repeated_field.rb index 831e0320..11d6c2eb 100644 --- a/ruby/lib/google/protobuf/repeated_field.rb +++ b/ruby/lib/google/protobuf/repeated_field.rb @@ -74,7 +74,7 @@ module Google :include?, :index, :inspect, :join, :pack, :permutation, :product, :pretty_print, :pretty_print_cycle, :rassoc, :repeated_combination, :repeated_permutation, :reverse, - :rindex, :rotate, :sample, :shuffle, :shelljoin, :slice, + :rindex, :rotate, :sample, :shuffle, :shelljoin, :to_s, :transpose, :uniq, :| diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 967ff81f..e0dba8bd 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -1183,13 +1183,15 @@ module BasicTest end def test_comparison_with_arbitrary_object - assert_false MapMessage.new == nil + assert MapMessage.new != nil end def test_respond_to + # This test fails with JRuby 1.7.23, likely because of an old JRuby bug. + return if RUBY_PLATFORM == "java" msg = MapMessage.new assert msg.respond_to?(:map_string_int32) - assert_false msg.respond_to?(:bacon) + assert !msg.respond_to?(:bacon) end end end diff --git a/src/Makefile.am b/src/Makefile.am index 8d9e07ab..d6f27fa8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,6 +161,7 @@ nobase_include_HEADERS = \ google/protobuf/compiler/java/java_names.h \ google/protobuf/compiler/javanano/javanano_generator.h \ google/protobuf/compiler/js/js_generator.h \ + google/protobuf/compiler/js/well_known_types_embed.h \ google/protobuf/compiler/objectivec/objectivec_generator.h \ google/protobuf/compiler/objectivec/objectivec_helpers.h \ google/protobuf/compiler/php/php_generator.h \ @@ -399,6 +400,7 @@ libprotoc_la_SOURCES = \ google/protobuf/compiler/java/java_doc_comment.cc \ google/protobuf/compiler/java/java_doc_comment.h \ google/protobuf/compiler/js/js_generator.cc \ + google/protobuf/compiler/js/well_known_types_embed.cc \ google/protobuf/compiler/javanano/javanano_enum.cc \ google/protobuf/compiler/javanano/javanano_enum.h \ google/protobuf/compiler/javanano/javanano_enum_field.cc \ diff --git a/src/google/protobuf/any.cc b/src/google/protobuf/any.cc index f7b1d310..83edba57 100644 --- a/src/google/protobuf/any.cc +++ b/src/google/protobuf/any.cc @@ -30,6 +30,8 @@ #include <google/protobuf/any.h> +#include <google/protobuf/generated_message_util.h> + namespace google { namespace protobuf { namespace internal { @@ -70,13 +72,11 @@ bool AnyMetadata::UnpackTo(Message* message) const { if (!InternalIs(message->GetDescriptor())) { return false; } - return message->ParseFromString( - value_->GetNoArena(&::google::protobuf::internal::GetEmptyString())); + return message->ParseFromString(value_->GetNoArena()); } bool AnyMetadata::InternalIs(const Descriptor* descriptor) const { - const string type_url = type_url_->GetNoArena( - &::google::protobuf::internal::GetEmptyString()); + const string type_url = type_url_->GetNoArena(); string full_name; if (!ParseAnyTypeUrl(type_url, &full_name)) { return false; diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index 0df8d168..e73ebffd 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -19,86 +19,88 @@ namespace google { namespace protobuf { +class AnyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Any> {}; +AnyDefaultTypeInternal _Any_default_instance_; namespace { -const ::google::protobuf::Descriptor* Any_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Any_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/any.proto"); - GOOGLE_CHECK(file != NULL); - Any_descriptor_ = file->message_type(0); - static const int Any_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_), }; - Any_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Any_descriptor_, - Any::internal_default_instance(), - Any_offsets_, - -1, - -1, - -1, - sizeof(Any), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Any)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Any_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/any.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fany_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Any_descriptor_, Any::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() { - Any_default_instance_.Shutdown(); - delete Any_reflection_; + _Any_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::internal::GetEmptyString(); - Any_default_instance_.DefaultConstruct(); - Any_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Any_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + static const char descriptor[] = { + "\n\031google/protobuf/any.proto\022\017google.prot" + "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" + " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" + "%github.com/golang/protobuf/ptypes/any\242\002" + "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" + "roto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\031google/protobuf/any.proto\022\017google.prot" - "obuf\"&\n\003Any\022\020\n\010type_url\030\001 \001(\t\022\r\n\005value\030\002" - " \001(\014Bo\n\023com.google.protobufB\010AnyProtoP\001Z" - "%github.com/golang/protobuf/ptypes/any\242\002" - "\003GPB\252\002\036Google.Protobuf.WellKnownTypesb\006p" - "roto3", 205); + descriptor, 205); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/any.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto); @@ -116,16 +118,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== void Any::PackFrom(const ::google::protobuf::Message& message) { @@ -148,20 +140,26 @@ const int Any::kValueFieldNumber; Any::Any() : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Any) } - -void Any::InitAsDefaultInstance() { -} - Any::Any(const Any& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL), - _any_metadata_(&type_url_, &value_) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0), + _any_metadata_(&type_url_, &value_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.type_url().size() > 0) { + type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); + } + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) } @@ -188,7 +186,7 @@ void Any::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Any::descriptor() { protobuf_AssignDescriptorsOnce(); - return Any_descriptor_; + return file_level_metadata[0].descriptor; } const Any& Any::default_instance() { @@ -196,8 +194,6 @@ const Any& Any::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_; - Any* Any::New(::google::protobuf::Arena* arena) const { Any* n = new Any; if (arena != NULL) { @@ -218,13 +214,13 @@ bool Any::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Any) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string type_url = 1; + // string type_url = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -234,20 +230,17 @@ bool Any::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } - // optional bytes value = 2; + // bytes value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -275,7 +268,7 @@ failure: void Any::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Any) - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -285,7 +278,7 @@ void Any::SerializeWithCachedSizes( 1, this->type_url(), output); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 2, this->value(), output); @@ -298,7 +291,7 @@ void Any::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any) - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -309,7 +302,7 @@ void Any::SerializeWithCachedSizes( 1, this->type_url(), target); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( @@ -324,14 +317,14 @@ size_t Any::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any) size_t total_size = 0; - // optional string type_url = 1; + // string type_url = 1; if (this->type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->type_url()); } - // optional bytes value = 2; + // bytes value = 2; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( @@ -347,7 +340,7 @@ size_t Any::ByteSizeLong() const { void Any::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Any* source = ::google::protobuf::internal::DynamicCastToGenerated<const Any>( &from); @@ -356,21 +349,14 @@ void Any::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Any::MergeFrom(const Any& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Any::UnsafeMergeFrom(const Any& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.type_url().size() > 0) { type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_); @@ -392,11 +378,10 @@ void Any::CopyFrom(const Any& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Any::IsInitialized() const { - return true; } @@ -407,28 +392,24 @@ void Any::Swap(Any* other) { void Any::InternalSwap(Any* other) { type_url_.Swap(&other->type_url_); value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Any::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Any_descriptor_; - metadata.reflection = Any_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Any -// optional string type_url = 1; +// string type_url = 1; void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) - return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.GetNoArena(); } void Any::set_type_url(const ::std::string& value) { @@ -466,13 +447,13 @@ void Any::set_allocated_type_url(::std::string* type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } -// optional bytes value = 2; +// bytes value = 2; void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.GetNoArena(); } void Any::set_value(const ::std::string& value) { @@ -510,9 +491,6 @@ void Any::set_allocated_value(::std::string* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } -inline const Any* Any::internal_default_instance() { - return &Any_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 0641e244..482db72f 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -24,11 +24,18 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Any; +class AnyDefaultTypeInternal; +extern AnyDefaultTypeInternal _Any_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -36,10 +43,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); - -class Any; // =================================================================== @@ -58,7 +61,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Any& default_instance(); - static const Any* internal_default_instance(); + static inline const Any* internal_default_instance() { + return reinterpret_cast<const Any*>( + &_Any_default_instance_); + } // implements Any ----------------------------------------------- @@ -74,49 +80,49 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in // implements Message ---------------------------------------------- - inline Any* New() const { return New(NULL); } + inline Any* New() const PROTOBUF_FINAL { return New(NULL); } - Any* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Any* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Any& from); void MergeFrom(const Any& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Any* other); - void UnsafeMergeFrom(const Any& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string type_url = 1; + // string type_url = 1; void clear_type_url(); static const int kTypeUrlFieldNumber = 1; const ::std::string& type_url() const; @@ -127,7 +133,7 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::std::string* release_type_url(); void set_allocated_type_url(::std::string* type_url); - // optional bytes value = 2; + // bytes value = 2; void clear_value(); static const int kValueFieldNumber = 2; const ::std::string& value() const; @@ -148,13 +154,10 @@ class LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_in ::google::protobuf::internal::AnyMetadata _any_metadata_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fany_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_instance_; - // =================================================================== @@ -163,13 +166,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Any> Any_default_inst #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Any -// optional string type_url = 1; +// string type_url = 1; inline void Any::clear_type_url() { type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) - return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.GetNoArena(); } inline void Any::set_type_url(const ::std::string& value) { @@ -207,13 +210,13 @@ inline void Any::set_allocated_type_url(::std::string* type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url) } -// optional bytes value = 2; +// bytes value = 2; inline void Any::clear_value() { value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.GetNoArena(); } inline void Any::set_value(const ::std::string& value) { @@ -251,13 +254,11 @@ inline void Any::set_allocated_value(::std::string* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value) } -inline const Any* Any::internal_default_instance() { - return &Any_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 35139faf..2bc6153a 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -19,31 +19,27 @@ namespace google { namespace protobuf { +class ApiDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Api> {}; +ApiDefaultTypeInternal _Api_default_instance_; +class MethodDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Method> {}; +MethodDefaultTypeInternal _Method_default_instance_; +class MixinDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Mixin> {}; +MixinDefaultTypeInternal _Mixin_default_instance_; namespace { -const ::google::protobuf::Descriptor* Api_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Api_reflection_ = NULL; -const ::google::protobuf::Descriptor* Method_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Method_reflection_ = NULL; -const ::google::protobuf::Descriptor* Mixin_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Mixin_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[3]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/api.proto"); - GOOGLE_CHECK(file != NULL); - Api_descriptor_ = file->message_type(0); - static const int Api_offsets_[7] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_), @@ -51,19 +47,10 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_), - }; - Api_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Api_descriptor_, - Api::internal_default_instance(), - Api_offsets_, - -1, - -1, - -1, - sizeof(Api), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_)); - Method_descriptor_ = file->message_type(1); - static const int Method_offsets_[7] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_), @@ -71,62 +58,58 @@ void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_), - }; - Method_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Method_descriptor_, - Method::internal_default_instance(), - Method_offsets_, - -1, - -1, - -1, - sizeof(Method), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_)); - Mixin_descriptor_ = file->message_type(2); - static const int Mixin_offsets_[2] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_), }; - Mixin_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Mixin_descriptor_, - Mixin::internal_default_instance(), - Mixin_offsets_, - -1, - -1, - -1, - sizeof(Mixin), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Api)}, + { 11, -1, sizeof(Method)}, + { 22, -1, sizeof(Mixin)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Api_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Method_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Mixin_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/api.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Api_descriptor_, Api::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Method_descriptor_, Method::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Mixin_descriptor_, Mixin::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() { - Api_default_instance_.Shutdown(); - delete Api_reflection_; - Method_default_instance_.Shutdown(); - delete Method_reflection_; - Mixin_default_instance_.Shutdown(); - delete Mixin_reflection_; + _Api_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _Method_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Mixin_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { @@ -134,45 +117,43 @@ void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl() { ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); - ::google::protobuf::internal::GetEmptyString(); - Api_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Method_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Mixin_default_instance_.DefaultConstruct(); - Api_default_instance_.get_mutable()->InitAsDefaultInstance(); - Method_default_instance_.get_mutable()->InitAsDefaultInstance(); - Mixin_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_); + ::google::protobuf::internal::InitProtobufDefaults(); + _Api_default_instance_.DefaultConstruct(); + _Method_default_instance_.DefaultConstruct(); + _Mixin_default_instance_.DefaultConstruct(); + _Api_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + static const char descriptor[] = { + "\n\031google/protobuf/api.proto\022\017google.prot" + "obuf\032$google/protobuf/source_context.pro" + "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014" + "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p" + "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google" + ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou" + "rce_context\030\005 \001(\0132\036.google.protobuf.Sour" + "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto" + "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto" + "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r" + "equest_type_url\030\002 \001(\t\022\031\n\021request_streami" + "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r" + "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" + "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" + "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" + "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBu\n\023com.google.pr" + "otobufB\010ApiProtoP\001Z+google.golang.org/ge" + "nproto/protobuf/api;api\242\002\003GPB\252\002\036Google.P" + "rotobuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\031google/protobuf/api.proto\022\017google.prot" - "obuf\032$google/protobuf/source_context.pro" - "to\032\032google/protobuf/type.proto\"\201\002\n\003Api\022\014" - "\n\004name\030\001 \001(\t\022(\n\007methods\030\002 \003(\0132\027.google.p" - "rotobuf.Method\022(\n\007options\030\003 \003(\0132\027.google" - ".protobuf.Option\022\017\n\007version\030\004 \001(\t\0226\n\016sou" - "rce_context\030\005 \001(\0132\036.google.protobuf.Sour" - "ceContext\022&\n\006mixins\030\006 \003(\0132\026.google.proto" - "buf.Mixin\022\'\n\006syntax\030\007 \001(\0162\027.google.proto" - "buf.Syntax\"\325\001\n\006Method\022\014\n\004name\030\001 \001(\t\022\030\n\020r" - "equest_type_url\030\002 \001(\t\022\031\n\021request_streami" - "ng\030\003 \001(\010\022\031\n\021response_type_url\030\004 \001(\t\022\032\n\022r" - "esponse_streaming\030\005 \001(\010\022(\n\007options\030\006 \003(\013" - "2\027.google.protobuf.Option\022\'\n\006syntax\030\007 \001(" - "\0162\027.google.protobuf.Syntax\"#\n\005Mixin\022\014\n\004n" - "ame\030\001 \001(\t\022\014\n\004root\030\002 \001(\tBH\n\023com.google.pr" - "otobufB\010ApiProtoP\001\242\002\003GPB\252\002\036Google.Protob" - "uf.WellKnownTypesb\006proto3", 705); + descriptor, 750); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/api.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); @@ -192,16 +173,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -216,29 +187,42 @@ const int Api::kSyntaxFieldNumber; Api::Api() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Api) } - -void Api::InitAsDefaultInstance() { - source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); -} - Api::Api(const Api& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + methods_(from.methods_), + options_(from.options_), + mixins_(from.mixins_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.version().size() > 0) { + version_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.version_); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Api) } void Api::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -250,7 +234,7 @@ Api::~Api() { void Api::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &Api_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -262,7 +246,7 @@ void Api::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Api::descriptor() { protobuf_AssignDescriptorsOnce(); - return Api_descriptor_; + return file_level_metadata[0].descriptor; } const Api& Api::default_instance() { @@ -270,8 +254,6 @@ const Api& Api::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_; - Api* Api::New(::google::protobuf::Arena* arena) const { Api* n = new Api; if (arena != NULL) { @@ -282,14 +264,16 @@ Api* Api::New(::google::protobuf::Arena* arena) const { void Api::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Api) + methods_.Clear(); + options_.Clear(); + mixins_.Clear(); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } source_context_ = NULL; syntax_ = 0; - methods_.Clear(); - options_.Clear(); - mixins_.Clear(); } bool Api::MergePartialFromCodedStream( @@ -298,13 +282,13 @@ bool Api::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Api) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -314,47 +298,38 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_methods; break; } // repeated .google.protobuf.Method methods = 2; case 2: { - if (tag == 18) { - parse_methods: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_methods: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_methods())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_methods; - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(34)) goto parse_version; break; } - // optional string version = 4; + // string version = 4; case 4: { - if (tag == 34) { - parse_version: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_version())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -364,44 +339,36 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42) { - parse_source_context: + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_mixins; break; } // repeated .google.protobuf.Mixin mixins = 6; case 6: { - if (tag == 50) { - parse_mixins: + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_mixins: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_mixins())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_mixins; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(56)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56) { - parse_syntax: + if (tag == 56u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -410,7 +377,6 @@ bool Api::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -438,7 +404,7 @@ failure: void Api::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Api) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -460,7 +426,7 @@ void Api::SerializeWithCachedSizes( 3, this->options(i), output); } - // optional string version = 4; + // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->version().data(), this->version().length(), @@ -470,7 +436,7 @@ void Api::SerializeWithCachedSizes( 4, this->version(), output); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *this->source_context_, output); @@ -482,7 +448,7 @@ void Api::SerializeWithCachedSizes( 6, this->mixins(i), output); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 7, this->syntax(), output); @@ -495,7 +461,7 @@ void Api::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -520,7 +486,7 @@ void Api::SerializeWithCachedSizes( 3, this->options(i), false, target); } - // optional string version = 4; + // string version = 4; if (this->version().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->version().data(), this->version().length(), @@ -531,7 +497,7 @@ void Api::SerializeWithCachedSizes( 4, this->version(), target); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -545,7 +511,7 @@ void Api::SerializeWithCachedSizes( 6, this->mixins(i), false, target); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 7, this->syntax(), target); @@ -559,33 +525,6 @@ size_t Api::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string version = 4; - if (this->version().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->version()); - } - - // optional .google.protobuf.SourceContext source_context = 5; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 7; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.Method methods = 2; { unsigned int count = this->methods_size(); @@ -619,6 +558,33 @@ size_t Api::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // string version = 4; + if (this->version().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->version()); + } + + // .google.protobuf.SourceContext source_context = 5; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 7; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -628,7 +594,7 @@ size_t Api::ByteSizeLong() const { void Api::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Api* source = ::google::protobuf::internal::DynamicCastToGenerated<const Api>( &from); @@ -637,21 +603,14 @@ void Api::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Api) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Api::MergeFrom(const Api& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Api::UnsafeMergeFrom(const Api& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); methods_.MergeFrom(from.methods_); options_.MergeFrom(from.options_); mixins_.MergeFrom(from.mixins_); @@ -682,11 +641,10 @@ void Api::CopyFrom(const Api& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Api::IsInitialized() const { - return true; } @@ -695,35 +653,31 @@ void Api::Swap(Api* other) { InternalSwap(other); } void Api::InternalSwap(Api* other) { - name_.Swap(&other->name_); methods_.UnsafeArenaSwap(&other->methods_); options_.UnsafeArenaSwap(&other->options_); + mixins_.UnsafeArenaSwap(&other->mixins_); + name_.Swap(&other->name_); version_.Swap(&other->version_); std::swap(source_context_, other->source_context_); - mixins_.UnsafeArenaSwap(&other->mixins_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Api::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Api_descriptor_; - metadata.reflection = Api_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Api -// optional string name = 1; +// string name = 1; void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Api::set_name(const ::std::string& value) { @@ -821,13 +775,13 @@ Api::options() const { return options_; } -// optional string version = 4; +// string version = 4; void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return version_.GetNoArena(); } void Api::set_version(const ::std::string& value) { @@ -865,7 +819,7 @@ void Api::set_allocated_version(::std::string* version) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; bool Api::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -934,7 +888,7 @@ Api::mixins() const { return mixins_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; void Api::clear_syntax() { syntax_ = 0; } @@ -948,9 +902,6 @@ void Api::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) } -inline const Api* Api::internal_default_instance() { - return &Api_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -967,19 +918,33 @@ const int Method::kSyntaxFieldNumber; Method::Method() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Method) } - -void Method::InitAsDefaultInstance() { -} - Method::Method(const Method& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.request_type_url().size() > 0) { + request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); + } + response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.response_type_url().size() > 0) { + response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); + } + ::memcpy(&request_streaming_, &from.request_streaming_, + reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Method) } @@ -1010,7 +975,7 @@ void Method::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Method::descriptor() { protobuf_AssignDescriptorsOnce(); - return Method_descriptor_; + return file_level_metadata[1].descriptor; } const Method& Method::default_instance() { @@ -1018,8 +983,6 @@ const Method& Method::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_; - Method* Method::New(::google::protobuf::Arena* arena) const { Method* n = new Method; if (arena != NULL) { @@ -1030,31 +993,12 @@ Method* Method::New(::google::protobuf::Arena* arena) const { void Method::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Method) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Method, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Method*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(request_streaming_, syntax_); + options_.Clear(); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - -#undef ZR_HELPER_ -#undef ZR_ - - options_.Clear(); + ::memset(&request_streaming_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&request_streaming_) + sizeof(syntax_)); } bool Method::MergePartialFromCodedStream( @@ -1063,13 +1007,13 @@ bool Method::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Method) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1079,14 +1023,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_request_type_url; break; } - // optional string request_type_url = 2; + // string request_type_url = 2; case 2: { - if (tag == 18) { - parse_request_type_url: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_request_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1096,14 +1038,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_request_streaming; break; } - // optional bool request_streaming = 3; + // bool request_streaming = 3; case 3: { - if (tag == 24) { - parse_request_streaming: + if (tag == 24u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1111,14 +1051,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_response_type_url; break; } - // optional string response_type_url = 4; + // string response_type_url = 4; case 4: { - if (tag == 34) { - parse_response_type_url: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_response_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1128,14 +1066,12 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_response_streaming; break; } - // optional bool response_streaming = 5; + // bool response_streaming = 5; case 5: { - if (tag == 40) { - parse_response_streaming: + if (tag == 40u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1143,31 +1079,25 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_options; break; } // repeated .google.protobuf.Option options = 6; case 6: { - if (tag == 50) { - parse_options: + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(56)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; case 7: { - if (tag == 56) { - parse_syntax: + if (tag == 56u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1176,7 +1106,6 @@ bool Method::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1204,7 +1133,7 @@ failure: void Method::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Method) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1214,7 +1143,7 @@ void Method::SerializeWithCachedSizes( 1, this->name(), output); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->request_type_url().data(), this->request_type_url().length(), @@ -1224,12 +1153,12 @@ void Method::SerializeWithCachedSizes( 2, this->request_type_url(), output); } - // optional bool request_streaming = 3; + // bool request_streaming = 3; if (this->request_streaming() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->request_streaming(), output); } - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->response_type_url().data(), this->response_type_url().length(), @@ -1239,7 +1168,7 @@ void Method::SerializeWithCachedSizes( 4, this->response_type_url(), output); } - // optional bool response_streaming = 5; + // bool response_streaming = 5; if (this->response_streaming() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->response_streaming(), output); } @@ -1250,7 +1179,7 @@ void Method::SerializeWithCachedSizes( 6, this->options(i), output); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 7, this->syntax(), output); @@ -1263,7 +1192,7 @@ void Method::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1274,7 +1203,7 @@ void Method::SerializeWithCachedSizes( 1, this->name(), target); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->request_type_url().data(), this->request_type_url().length(), @@ -1285,12 +1214,12 @@ void Method::SerializeWithCachedSizes( 2, this->request_type_url(), target); } - // optional bool request_streaming = 3; + // bool request_streaming = 3; if (this->request_streaming() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->request_streaming(), target); } - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->response_type_url().data(), this->response_type_url().length(), @@ -1301,7 +1230,7 @@ void Method::SerializeWithCachedSizes( 4, this->response_type_url(), target); } - // optional bool response_streaming = 5; + // bool response_streaming = 5; if (this->response_streaming() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->response_streaming(), target); } @@ -1313,7 +1242,7 @@ void Method::SerializeWithCachedSizes( 6, this->options(i), false, target); } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 7, this->syntax(), target); @@ -1327,54 +1256,54 @@ size_t Method::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method) size_t total_size = 0; - // optional string name = 1; + // repeated .google.protobuf.Option options = 6; + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } + } + + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional string request_type_url = 2; + // string request_type_url = 2; if (this->request_type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->request_type_url()); } - // optional bool request_streaming = 3; - if (this->request_streaming() != 0) { - total_size += 1 + 1; - } - - // optional string response_type_url = 4; + // string response_type_url = 4; if (this->response_type_url().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->response_type_url()); } - // optional bool response_streaming = 5; + // bool request_streaming = 3; + if (this->request_streaming() != 0) { + total_size += 1 + 1; + } + + // bool response_streaming = 5; if (this->response_streaming() != 0) { total_size += 1 + 1; } - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; if (this->syntax() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); } - // repeated .google.protobuf.Option options = 6; - { - unsigned int count = this->options_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); - } - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -1384,7 +1313,7 @@ size_t Method::ByteSizeLong() const { void Method::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Method* source = ::google::protobuf::internal::DynamicCastToGenerated<const Method>( &from); @@ -1393,21 +1322,14 @@ void Method::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Method) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Method::MergeFrom(const Method& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Method::UnsafeMergeFrom(const Method& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -1417,13 +1339,13 @@ void Method::UnsafeMergeFrom(const Method& from) { request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); } - if (from.request_streaming() != 0) { - set_request_streaming(from.request_streaming()); - } if (from.response_type_url().size() > 0) { response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); } + if (from.request_streaming() != 0) { + set_request_streaming(from.request_streaming()); + } if (from.response_streaming() != 0) { set_response_streaming(from.response_streaming()); } @@ -1443,11 +1365,10 @@ void Method::CopyFrom(const Method& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Method::IsInitialized() const { - return true; } @@ -1456,35 +1377,31 @@ void Method::Swap(Method* other) { InternalSwap(other); } void Method::InternalSwap(Method* other) { + options_.UnsafeArenaSwap(&other->options_); name_.Swap(&other->name_); request_type_url_.Swap(&other->request_type_url_); - std::swap(request_streaming_, other->request_streaming_); response_type_url_.Swap(&other->response_type_url_); + std::swap(request_streaming_, other->request_streaming_); std::swap(response_streaming_, other->response_streaming_); - options_.UnsafeArenaSwap(&other->options_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Method::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Method_descriptor_; - metadata.reflection = Method_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Method -// optional string name = 1; +// string name = 1; void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Method::set_name(const ::std::string& value) { @@ -1522,13 +1439,13 @@ void Method::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } -// optional string request_type_url = 2; +// string request_type_url = 2; void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) - return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return request_type_url_.GetNoArena(); } void Method::set_request_type_url(const ::std::string& value) { @@ -1566,7 +1483,7 @@ void Method::set_allocated_request_type_url(::std::string* request_type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } -// optional bool request_streaming = 3; +// bool request_streaming = 3; void Method::clear_request_streaming() { request_streaming_ = false; } @@ -1580,13 +1497,13 @@ void Method::set_request_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) } -// optional string response_type_url = 4; +// string response_type_url = 4; void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) - return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return response_type_url_.GetNoArena(); } void Method::set_response_type_url(const ::std::string& value) { @@ -1624,7 +1541,7 @@ void Method::set_allocated_response_type_url(::std::string* response_type_url) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } -// optional bool response_streaming = 5; +// bool response_streaming = 5; void Method::clear_response_streaming() { response_streaming_ = false; } @@ -1668,7 +1585,7 @@ Method::options() const { return options_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; void Method::clear_syntax() { syntax_ = 0; } @@ -1682,9 +1599,6 @@ void Method::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) } -inline const Method* Method::internal_default_instance() { - return &Method_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1696,19 +1610,25 @@ const int Mixin::kRootFieldNumber; Mixin::Mixin() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Mixin) } - -void Mixin::InitAsDefaultInstance() { -} - Mixin::Mixin(const Mixin& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.root().size() > 0) { + root_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) } @@ -1735,7 +1655,7 @@ void Mixin::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Mixin::descriptor() { protobuf_AssignDescriptorsOnce(); - return Mixin_descriptor_; + return file_level_metadata[2].descriptor; } const Mixin& Mixin::default_instance() { @@ -1743,8 +1663,6 @@ const Mixin& Mixin::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_; - Mixin* Mixin::New(::google::protobuf::Arena* arena) const { Mixin* n = new Mixin; if (arena != NULL) { @@ -1765,13 +1683,13 @@ bool Mixin::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Mixin) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1781,14 +1699,12 @@ bool Mixin::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_root; break; } - // optional string root = 2; + // string root = 2; case 2: { - if (tag == 18) { - parse_root: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_root())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1798,7 +1714,6 @@ bool Mixin::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1826,7 +1741,7 @@ failure: void Mixin::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Mixin) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1836,7 +1751,7 @@ void Mixin::SerializeWithCachedSizes( 1, this->name(), output); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->root().data(), this->root().length(), @@ -1853,7 +1768,7 @@ void Mixin::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1864,7 +1779,7 @@ void Mixin::SerializeWithCachedSizes( 1, this->name(), target); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->root().data(), this->root().length(), @@ -1883,14 +1798,14 @@ size_t Mixin::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin) size_t total_size = 0; - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional string root = 2; + // string root = 2; if (this->root().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -1906,7 +1821,7 @@ size_t Mixin::ByteSizeLong() const { void Mixin::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Mixin* source = ::google::protobuf::internal::DynamicCastToGenerated<const Mixin>( &from); @@ -1915,21 +1830,14 @@ void Mixin::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Mixin) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Mixin::MergeFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Mixin::UnsafeMergeFrom(const Mixin& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.name().size() > 0) { name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1951,11 +1859,10 @@ void Mixin::CopyFrom(const Mixin& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Mixin::IsInitialized() const { - return true; } @@ -1966,28 +1873,24 @@ void Mixin::Swap(Mixin* other) { void Mixin::InternalSwap(Mixin* other) { name_.Swap(&other->name_); root_.Swap(&other->root_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Mixin::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Mixin_descriptor_; - metadata.reflection = Mixin_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Mixin -// optional string name = 1; +// string name = 1; void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void Mixin::set_name(const ::std::string& value) { @@ -2025,13 +1928,13 @@ void Mixin::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } -// optional string root = 2; +// string root = 2; void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return root_.GetNoArena(); } void Mixin::set_root(const ::std::string& value) { @@ -2069,9 +1972,6 @@ void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } -inline const Mixin* Mixin::internal_default_instance() { - return &Mixin_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 94102863..255eb4e3 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -24,12 +24,43 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/source_context.pb.h> #include <google/protobuf/type.pb.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Api; +class ApiDefaultTypeInternal; +extern ApiDefaultTypeInternal _Api_default_instance_; +class Enum; +class EnumDefaultTypeInternal; +extern EnumDefaultTypeInternal _Enum_default_instance_; +class EnumValue; +class EnumValueDefaultTypeInternal; +extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; +class Field; +class FieldDefaultTypeInternal; +extern FieldDefaultTypeInternal _Field_default_instance_; +class Method; +class MethodDefaultTypeInternal; +extern MethodDefaultTypeInternal _Method_default_instance_; +class Mixin; +class MixinDefaultTypeInternal; +extern MixinDefaultTypeInternal _Mixin_default_instance_; +class Option; +class OptionDefaultTypeInternal; +extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +class Type; +class TypeDefaultTypeInternal; +extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -37,12 +68,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - -class Api; -class Method; -class Mixin; // =================================================================== @@ -61,55 +86,58 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in static const ::google::protobuf::Descriptor* descriptor(); static const Api& default_instance(); - static const Api* internal_default_instance(); + static inline const Api* internal_default_instance() { + return reinterpret_cast<const Api*>( + &_Api_default_instance_); + } void Swap(Api* other); // implements Message ---------------------------------------------- - inline Api* New() const { return New(NULL); } + inline Api* New() const PROTOBUF_FINAL { return New(NULL); } - Api* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Api* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Api& from); void MergeFrom(const Api& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Api* other); - void UnsafeMergeFrom(const Api& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -144,7 +172,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional string version = 4; + // string version = 4; void clear_version(); static const int kVersionFieldNumber = 4; const ::std::string& version() const; @@ -155,7 +183,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in ::std::string* release_version(); void set_allocated_version(::std::string* version); - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; @@ -176,7 +204,7 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >& mixins() const; - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; void clear_syntax(); static const int kSyntaxFieldNumber = 7; ::google::protobuf::Syntax syntax() const; @@ -196,13 +224,10 @@ class LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_in mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Api> Api_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ { @@ -220,55 +245,58 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc static const ::google::protobuf::Descriptor* descriptor(); static const Method& default_instance(); - static const Method* internal_default_instance(); + static inline const Method* internal_default_instance() { + return reinterpret_cast<const Method*>( + &_Method_default_instance_); + } void Swap(Method* other); // implements Message ---------------------------------------------- - inline Method* New() const { return New(NULL); } + inline Method* New() const PROTOBUF_FINAL { return New(NULL); } - Method* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Method* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Method& from); void MergeFrom(const Method& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Method* other); - void UnsafeMergeFrom(const Method& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -279,7 +307,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional string request_type_url = 2; + // string request_type_url = 2; void clear_request_type_url(); static const int kRequestTypeUrlFieldNumber = 2; const ::std::string& request_type_url() const; @@ -290,13 +318,13 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_request_type_url(); void set_allocated_request_type_url(::std::string* request_type_url); - // optional bool request_streaming = 3; + // bool request_streaming = 3; void clear_request_streaming(); static const int kRequestStreamingFieldNumber = 3; bool request_streaming() const; void set_request_streaming(bool value); - // optional string response_type_url = 4; + // string response_type_url = 4; void clear_response_type_url(); static const int kResponseTypeUrlFieldNumber = 4; const ::std::string& response_type_url() const; @@ -307,7 +335,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc ::std::string* release_response_type_url(); void set_allocated_response_type_url(::std::string* response_type_url); - // optional bool response_streaming = 5; + // bool response_streaming = 5; void clear_response_streaming(); static const int kResponseStreamingFieldNumber = 5; bool response_streaming() const; @@ -325,7 +353,7 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.Syntax syntax = 7; + // .google.protobuf.Syntax syntax = 7; void clear_syntax(); static const int kSyntaxFieldNumber = 7; ::google::protobuf::Syntax syntax() const; @@ -345,13 +373,10 @@ class LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Method> Method_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ { @@ -369,55 +394,58 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ static const ::google::protobuf::Descriptor* descriptor(); static const Mixin& default_instance(); - static const Mixin* internal_default_instance(); + static inline const Mixin* internal_default_instance() { + return reinterpret_cast<const Mixin*>( + &_Mixin_default_instance_); + } void Swap(Mixin* other); // implements Message ---------------------------------------------- - inline Mixin* New() const { return New(NULL); } + inline Mixin* New() const PROTOBUF_FINAL { return New(NULL); } - Mixin* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Mixin* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Mixin& from); void MergeFrom(const Mixin& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Mixin* other); - void UnsafeMergeFrom(const Mixin& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -428,7 +456,7 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ ::std::string* release_name(); void set_allocated_name(::std::string* name); - // optional string root = 2; + // string root = 2; void clear_root(); static const int kRootFieldNumber = 2; const ::std::string& root() const; @@ -448,13 +476,10 @@ class LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fapi_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fapi_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_instance_; - // =================================================================== @@ -463,13 +488,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Mixin> Mixin_default_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Api -// optional string name = 1; +// string name = 1; inline void Api::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Api::set_name(const ::std::string& value) { @@ -567,13 +592,13 @@ Api::options() const { return options_; } -// optional string version = 4; +// string version = 4; inline void Api::clear_version() { version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return version_.GetNoArena(); } inline void Api::set_version(const ::std::string& value) { @@ -611,7 +636,7 @@ inline void Api::set_allocated_version(::std::string* version) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version) } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; inline bool Api::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -680,7 +705,7 @@ Api::mixins() const { return mixins_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; inline void Api::clear_syntax() { syntax_ = 0; } @@ -694,20 +719,17 @@ inline void Api::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax) } -inline const Api* Api::internal_default_instance() { - return &Api_default_instance_.get(); -} // ------------------------------------------------------------------- // Method -// optional string name = 1; +// string name = 1; inline void Method::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Method::set_name(const ::std::string& value) { @@ -745,13 +767,13 @@ inline void Method::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name) } -// optional string request_type_url = 2; +// string request_type_url = 2; inline void Method::clear_request_type_url() { request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Method::request_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url) - return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return request_type_url_.GetNoArena(); } inline void Method::set_request_type_url(const ::std::string& value) { @@ -789,7 +811,7 @@ inline void Method::set_allocated_request_type_url(::std::string* request_type_u // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url) } -// optional bool request_streaming = 3; +// bool request_streaming = 3; inline void Method::clear_request_streaming() { request_streaming_ = false; } @@ -803,13 +825,13 @@ inline void Method::set_request_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming) } -// optional string response_type_url = 4; +// string response_type_url = 4; inline void Method::clear_response_type_url() { response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Method::response_type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url) - return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return response_type_url_.GetNoArena(); } inline void Method::set_response_type_url(const ::std::string& value) { @@ -847,7 +869,7 @@ inline void Method::set_allocated_response_type_url(::std::string* response_type // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url) } -// optional bool response_streaming = 5; +// bool response_streaming = 5; inline void Method::clear_response_streaming() { response_streaming_ = false; } @@ -891,7 +913,7 @@ Method::options() const { return options_; } -// optional .google.protobuf.Syntax syntax = 7; +// .google.protobuf.Syntax syntax = 7; inline void Method::clear_syntax() { syntax_ = 0; } @@ -905,20 +927,17 @@ inline void Method::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax) } -inline const Method* Method::internal_default_instance() { - return &Method_default_instance_.get(); -} // ------------------------------------------------------------------- // Mixin -// optional string name = 1; +// string name = 1; inline void Mixin::clear_name() { name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void Mixin::set_name(const ::std::string& value) { @@ -956,13 +975,13 @@ inline void Mixin::set_allocated_name(::std::string* name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name) } -// optional string root = 2; +// string root = 2; inline void Mixin::clear_root() { root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return root_.GetNoArena(); } inline void Mixin::set_root(const ::std::string& value) { @@ -1000,9 +1019,6 @@ inline void Mixin::set_allocated_root(::std::string* root) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root) } -inline const Mixin* Mixin::internal_default_instance() { - return &Mixin_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -1011,6 +1027,7 @@ inline const Mixin* Mixin::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/api.proto b/src/google/protobuf/api.proto index bbbe9833..7c30e8b7 100644 --- a/src/google/protobuf/api.proto +++ b/src/google/protobuf/api.proto @@ -40,6 +40,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "ApiProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/api;api"; // Api is a light-weight descriptor for a protocol buffer service. message Api { diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index aa4e587c..21fd1be6 100755 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -36,7 +36,7 @@ #ifdef ADDRESS_SANITIZER #include <sanitizer/asan_interface.h> -#endif +#endif // ADDRESS_SANITIZER namespace google { namespace protobuf { @@ -141,7 +141,7 @@ Arena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n, // 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 +#endif // ADDRESS_SANITIZER return b; } @@ -205,7 +205,7 @@ void* Arena::AllocFromBlock(Block* b, size_t n) { b->pos = p + n; #ifdef ADDRESS_SANITIZER ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n); -#endif +#endif // ADDRESS_SANITIZER return reinterpret_cast<char*>(b) + p; } @@ -244,7 +244,7 @@ uint64 Arena::SpaceUsed() const { return space_used; } -pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { +std::pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const { uint64 allocated = 0; uint64 used = 0; @@ -265,9 +265,19 @@ uint64 Arena::FreeBlocks() { space_allocated += (b->size); Block* next = b->next; if (next != NULL) { +#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); +#endif // ADDRESS_SANITIZER options_.block_dealloc(b, b->size); } else { if (owns_first_block_) { +#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); +#endif // ADDRESS_SANITIZER options_.block_dealloc(b, b->size); } else { // User passed in the first block, skip free'ing the memory. diff --git a/src/google/protobuf/arena_test_util.h b/src/google/protobuf/arena_test_util.h index 690cc706..8c9f7698 100644 --- a/src/google/protobuf/arena_test_util.h +++ b/src/google/protobuf/arena_test_util.h @@ -31,9 +31,40 @@ #ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ #define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ +#include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/arena.h> namespace google { namespace protobuf { + +template <typename T, bool use_arena> +void TestParseCorruptedString(const T& message) { + int success_count = 0; + string s = message.SerializeAsString(); + const int kMaxIters = 900; + const int stride = s.size() <= kMaxIters ? 1 : s.size() / kMaxIters; + const int start = stride == 1 || use_arena ? 0 : (stride + 1) / 2; + for (int i = start; i < s.size(); i += stride) { + for (int c = 1 + (i % 17); c < 256; c += 2 * c + (i & 3)) { + s[i] ^= c; + google::protobuf::Arena arena; + T* message = + google::protobuf::Arena::CreateMessage<T>(use_arena ? &arena : NULL); + if (message->ParseFromString(s)) { + ++success_count; + } + if (!use_arena) { + delete message; + } + s[i] ^= c; // Restore s to its original state. + } + } + // This next line is a low bar. But getting through the test without crashing + // due to use-after-free or other bugs is a big part of what we're checking. + GOOGLE_CHECK_GT(success_count, 0); +} + namespace internal { class NoHeapChecker { diff --git a/src/google/protobuf/arena_unittest.cc b/src/google/protobuf/arena_unittest.cc index 35d00463..4f9571db 100644 --- a/src/google/protobuf/arena_unittest.cc +++ b/src/google/protobuf/arena_unittest.cc @@ -249,7 +249,7 @@ TEST(ArenaTest, Parsing) { arena_message->ParseFromString(original.SerializeAsString()); TestUtil::ExpectAllFieldsSet(*arena_message); - // Test that string fields have null terminator bytes (earlier bug). + // Test that string fields have nul terminator bytes (earlier bug). EXPECT_EQ(strlen(original.optional_string().c_str()), strlen(arena_message->optional_string().c_str())); } @@ -1154,6 +1154,13 @@ TEST(ArenaTest, NoHeapAllocationsTest) { arena.Reset(); } +TEST(ArenaTest, ParseCorruptedString) { + TestAllTypes message; + TestUtil::SetAllFields(&message); + TestParseCorruptedString<TestAllTypes, true>(message); + TestParseCorruptedString<TestAllTypes, false>(message); +} + #ifndef GOOGLE_PROTOBUF_NO_RTTI // Test construction on an arena via generic MessageLite interface. We should be // able to successfully deserialize on the arena without incurring heap diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc index cce61d74..f10732c0 100644 --- a/src/google/protobuf/arenastring.cc +++ b/src/google/protobuf/arenastring.cc @@ -44,7 +44,7 @@ void ArenaStringPtr::AssignWithDefault(const ::std::string* default_value, const ::std::string* other = *value.UnsafeRawStringPointer(); // If the pointers are the same then do nothing. if (me != other) { - SetNoArena(default_value, value.GetNoArena(default_value)); + SetNoArena(default_value, value.GetNoArena()); } } diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 590ffce9..b60ee379 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -37,7 +37,6 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/fastmem.h> #include <google/protobuf/arena.h> -#include <google/protobuf/generated_message_util.h> @@ -64,9 +63,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { } // Basic accessors. - inline const ::std::string& Get(const ::std::string* /* default_value */) const { - return *ptr_; - } + inline const ::std::string& Get() const { return *ptr_; } inline ::std::string* Mutable(const ::std::string* default_value, ::google::protobuf::Arena* arena) { @@ -150,13 +147,12 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { std::swap(ptr_, other->ptr_); } - // Frees storage (if not on an arena) and sets field to default value. + // Frees storage (if not on an arena). inline void Destroy(const ::std::string* default_value, ::google::protobuf::Arena* arena) { if (arena == NULL && ptr_ != default_value) { delete ptr_; } - ptr_ = const_cast< ::std::string* >(default_value); } // Clears content, but keeps allocated string if arena != NULL, to avoid the @@ -216,9 +212,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value); - inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const { - return *ptr_; - } + inline const ::std::string& GetNoArena() const { return *ptr_; } inline ::std::string* MutableNoArena(const ::std::string* default_value) { if (ptr_ == default_value) { @@ -253,7 +247,6 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { if (ptr_ != default_value) { delete ptr_; } - ptr_ = NULL; } inline void ClearToEmptyNoArena(const ::std::string* default_value) { @@ -281,6 +274,10 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { return &ptr_; } + inline bool IsDefault(const ::std::string* default_value) const { + return ptr_ == default_value; + } + private: ::std::string* ptr_; diff --git a/src/google/protobuf/arenastring_unittest.cc b/src/google/protobuf/arenastring_unittest.cc index ea405d7d..e5afe42d 100644 --- a/src/google/protobuf/arenastring_unittest.cc +++ b/src/google/protobuf/arenastring_unittest.cc @@ -59,11 +59,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { ArenaStringPtr field; ::std::string default_value = "default"; field.UnsafeSetDefault(&default_value); - EXPECT_EQ(string("default"), field.Get(&default_value)); + EXPECT_EQ(string("default"), field.Get()); field.Set(&default_value, WrapString("Test short"), NULL); - EXPECT_EQ(string("Test short"), field.Get(&default_value)); + EXPECT_EQ(string("Test short"), field.Get()); field.Set(&default_value, WrapString("Test long long long long value"), NULL); - EXPECT_EQ(string("Test long long long long value"), field.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field.Get()); field.Set(&default_value, string(""), NULL); field.Destroy(&default_value, NULL); @@ -71,11 +71,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) { field2.UnsafeSetDefault(&default_value); ::std::string* mut = field2.Mutable(&default_value, NULL); EXPECT_EQ(mut, field2.Mutable(&default_value, NULL)); - EXPECT_EQ(mut, &field2.Get(&default_value)); + EXPECT_EQ(mut, &field2.Get()); EXPECT_NE(&default_value, mut); EXPECT_EQ(string("default"), *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(string("Test long long long long value"), field2.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field2.Get()); field2.Destroy(&default_value, NULL); } @@ -84,12 +84,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { ArenaStringPtr field; ::std::string default_value = "default"; field.UnsafeSetDefault(&default_value); - EXPECT_EQ(string("default"), field.Get(&default_value)); + EXPECT_EQ(string("default"), field.Get()); field.Set(&default_value, WrapString("Test short"), &arena); - EXPECT_EQ(string("Test short"), field.Get(&default_value)); + EXPECT_EQ(string("Test short"), field.Get()); field.Set(&default_value, WrapString("Test long long long long value"), &arena); - EXPECT_EQ(string("Test long long long long value"), - field.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field.Get()); field.Set(&default_value, string(""), &arena); field.Destroy(&default_value, &arena); @@ -97,12 +96,11 @@ TEST(ArenaStringPtrTest, ArenaStringPtrOnArena) { field2.UnsafeSetDefault(&default_value); ::std::string* mut = field2.Mutable(&default_value, &arena); EXPECT_EQ(mut, field2.Mutable(&default_value, &arena)); - EXPECT_EQ(mut, &field2.Get(&default_value)); + EXPECT_EQ(mut, &field2.Get()); EXPECT_NE(&default_value, mut); EXPECT_EQ(string("default"), *mut); *mut = "Test long long long long value"; // ensure string allocates storage - EXPECT_EQ(string("Test long long long long value"), - field2.Get(&default_value)); + EXPECT_EQ(string("Test long long long long value"), field2.Get()); field2.Destroy(&default_value, &arena); } diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index f6ff1e5d..11d0f334 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -34,6 +34,7 @@ #include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/descriptor.h> @@ -46,7 +47,7 @@ namespace compiler { CodeGenerator::~CodeGenerator() {} bool CodeGenerator::GenerateAll( - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* generator_context, string* error) const { @@ -85,18 +86,25 @@ io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert( } void GeneratorContext::ListParsedFiles( - vector<const FileDescriptor*>* output) { + std::vector<const FileDescriptor*>* output) { GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; } +void GeneratorContext::GetCompilerVersion(Version* version) const { + version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); + version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); + version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); + version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); +} + // Parses a set of comma-delimited name/value pairs. void ParseGeneratorParameter(const string& text, - vector<pair<string, string> >* output) { - vector<string> parts = Split(text, ",", true); + std::vector<std::pair<string, string> >* output) { + std::vector<string> parts = Split(text, ",", true); for (int i = 0; i < parts.size(); i++) { string::size_type equals_pos = parts[i].find_first_of('='); - pair<string, string> value; + std::pair<string, string> value; if (equals_pos == string::npos) { value.first = parts[i]; value.second = ""; diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h index 642bbfad..b917d373 100644 --- a/src/google/protobuf/compiler/code_generator.h +++ b/src/google/protobuf/compiler/code_generator.h @@ -50,6 +50,7 @@ namespace io { class ZeroCopyOutputStream; } class FileDescriptor; namespace compiler { +class Version; // Defined in this file. class CodeGenerator; @@ -90,7 +91,7 @@ class LIBPROTOC_EXPORT CodeGenerator { // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. - virtual bool GenerateAll(const vector<const FileDescriptor*>& files, + virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* generator_context, string* error) const; @@ -141,7 +142,11 @@ class LIBPROTOC_EXPORT GeneratorContext { // Returns a vector of FileDescriptors for all the files being compiled // in this run. Useful for languages, such as Go, that treat files // differently when compiled as a set rather than individually. - virtual void ListParsedFiles(vector<const FileDescriptor*>* output); + virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output); + + // Retrieves the version number of the protocol compiler associated with + // this GeneratorContext. + virtual void GetCompilerVersion(Version* version) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); @@ -158,7 +163,7 @@ typedef GeneratorContext OutputDirectory; // parses to the pairs: // ("foo", "bar"), ("baz", ""), ("qux", "corge") extern void ParseGeneratorParameter(const string&, - vector<pair<string, string> >*); + std::vector<std::pair<string, string> >*); } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 8ab69d02..bef0fe5a 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -173,7 +173,8 @@ bool VerifyDirectoryExists(const string& path) { // directories listed in |filename|. bool TryCreateParentDirectory(const string& prefix, const string& filename) { // Recursively create parent directories to the output file. - vector<string> parts = Split(filename, "/", true); + std::vector<string> parts = + Split(filename, "/", true); string path_so_far = prefix; for (int i = 0; i < parts.size() - 1; i++) { path_so_far += parts[i]; @@ -344,7 +345,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, // them all to disk on demand. class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { public: - GeneratorContextImpl(const vector<const FileDescriptor*>& parsed_files); + GeneratorContextImpl(const std::vector<const FileDescriptor*>& parsed_files); ~GeneratorContextImpl(); // Write all files in the directory to disk at the given output location, @@ -360,14 +361,14 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { void AddJarManifest(); // Get name of all output files. - void GetOutputFilenames(vector<string>* output_filenames); + void GetOutputFilenames(std::vector<string>* output_filenames); // implements GeneratorContext -------------------------------------- io::ZeroCopyOutputStream* Open(const string& filename); io::ZeroCopyOutputStream* OpenForAppend(const string& filename); io::ZeroCopyOutputStream* OpenForInsert( const string& filename, const string& insertion_point); - void ListParsedFiles(vector<const FileDescriptor*>* output) { + void ListParsedFiles(std::vector<const FileDescriptor*>* output) { *output = parsed_files_; } @@ -376,8 +377,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { // map instead of hash_map so that files are written in order (good when // writing zips). - map<string, string*> files_; - const vector<const FileDescriptor*>& parsed_files_; + std::map<string, string*> files_; + const std::vector<const FileDescriptor*>& parsed_files_; bool had_error_; }; @@ -414,7 +415,7 @@ class CommandLineInterface::MemoryOutputStream // ------------------------------------------------------------------- CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl( - const vector<const FileDescriptor*>& parsed_files) + const std::vector<const FileDescriptor*>& parsed_files) : parsed_files_(parsed_files), had_error_(false) { } @@ -433,7 +434,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk( return false; } - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { const string& relative_filename = iter->first; const char* data = iter->second->data(); @@ -521,7 +522,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip( io::FileOutputStream stream(file_descriptor); ZipWriter zip_writer(&stream); - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { zip_writer.Write(iter->first, *iter->second); } @@ -550,8 +551,8 @@ void CommandLineInterface::GeneratorContextImpl::AddJarManifest() { } void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames( - vector<string>* output_filenames) { - for (map<string, string*>::iterator iter = files_.begin(); + std::vector<string>* output_filenames) { + for (std::map<string, string*>::iterator iter = files_.begin(); iter != files_.end(); ++iter) { output_filenames->push_back(iter->first); } @@ -774,7 +775,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { ErrorPrinter error_collector(error_format_, &source_tree); Importer importer(&source_tree, &error_collector); - vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; // Parse each file. for (int i = 0; i < input_files_.size(); i++) { @@ -984,7 +985,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { executable_name_ = argv[0]; - vector<string> arguments; + std::vector<string> arguments; for (int i = 1; i < argc; ++i) { arguments.push_back(argv[i]); } @@ -1030,7 +1031,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>("", ".")); + proto_path_.push_back(std::pair<string, string>("", ".")); } // Check some errror cases. @@ -1153,7 +1154,7 @@ CommandLineInterface::InterpretArgument(const string& name, // Java's -classpath (and some other languages) delimits path components // with colons. Let's accept that syntax too just to make things more // intuitive. - vector<string> parts = Split( + std::vector<string> parts = Split( value, kPathSeparator, true); for (int i = 0; i < parts.size(); i++) { @@ -1190,19 +1191,21 @@ CommandLineInterface::InterpretArgument(const string& name, // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>(virtual_path, disk_path)); + proto_path_.push_back(std::pair<string, string>(virtual_path, disk_path)); } } else if (name == "--direct_dependencies") { if (direct_dependencies_explicitly_set_) { std::cerr << name << " may only be passed once. To specify multiple " "direct dependencies, pass them all as a single " - "parameter separated by ':'." << std::endl; + "parameter separated by ':'." + << std::endl; return PARSE_ARGUMENT_FAIL; } direct_dependencies_explicitly_set_ = true; - vector<string> direct = Split(value, ":", true); + std::vector<string> direct = Split( + value, ":", true); GOOGLE_DCHECK(direct_dependencies_.empty()); direct_dependencies_.insert(direct.begin(), direct.end()); @@ -1476,7 +1479,7 @@ void CommandLineInterface::PrintHelpText() { } bool CommandLineInterface::GenerateOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context) { // Call the generator. @@ -1522,12 +1525,12 @@ bool CommandLineInterface::GenerateOutput( } bool CommandLineInterface::GenerateDependencyManifestFile( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const GeneratorContextMap& output_directories, DiskSourceTree* source_tree) { FileDescriptorSet file_set; - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], false, @@ -1536,12 +1539,12 @@ bool CommandLineInterface::GenerateDependencyManifestFile( file_set.mutable_file()); } - vector<string> output_filenames; + std::vector<string> output_filenames; for (GeneratorContextMap::const_iterator iter = output_directories.begin(); iter != output_directories.end(); ++iter) { const string& location = iter->first; GeneratorContextImpl* directory = iter->second; - vector<string> relative_output_filenames; + std::vector<string> relative_output_filenames; directory->GetOutputFilenames(&relative_output_filenames); for (int i = 0; i < relative_output_filenames.size(); i++) { string output_filename = location + relative_output_filenames[i]; @@ -1594,7 +1597,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile( } bool CommandLineInterface::GeneratePluginOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const string& plugin_name, const string& parameter, GeneratorContext* generator_context, @@ -1607,7 +1610,7 @@ bool CommandLineInterface::GeneratePluginOutput( request.set_parameter(parameter); } - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { request.add_file_to_generate(parsed_files[i]->name()); GetTransitiveDependencies(parsed_files[i], @@ -1616,6 +1619,13 @@ bool CommandLineInterface::GeneratePluginOutput( &already_seen, request.mutable_proto_file()); } + google::protobuf::compiler::Version* version = + request.mutable_compiler_version(); + version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); + version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); + version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); + version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); + // Invoke the plugin. Subprocess subprocess; @@ -1737,11 +1747,11 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { } bool CommandLineInterface::WriteDescriptorSet( - const vector<const FileDescriptor*> parsed_files) { + const std::vector<const FileDescriptor*> parsed_files) { FileDescriptorSet file_set; if (imports_in_descriptor_set_) { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], true, // Include json_name @@ -1749,7 +1759,7 @@ bool CommandLineInterface::WriteDescriptorSet( &already_seen, file_set.mutable_file()); } } else { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { if (!already_seen.insert(parsed_files[i]).second) { continue; @@ -1794,7 +1804,7 @@ void CommandLineInterface::GetTransitiveDependencies( const FileDescriptor* file, bool include_json_name, bool include_source_code_info, - set<const FileDescriptor*>* already_seen, + std::set<const FileDescriptor*>* already_seen, RepeatedPtrField<FileDescriptorProto>* output) { if (!already_seen->insert(file).second) { // Already saw this file. Skip. @@ -1853,11 +1863,11 @@ namespace { // parameter will contain the direct children (when groups are ignored in the // tree) of the given descriptor for the caller to traverse. The declaration // order of the nested messages is also preserved. -typedef pair<int, int> FieldRange; -void GatherOccupiedFieldRanges(const Descriptor* descriptor, - set<FieldRange>* ranges, - vector<const Descriptor*>* nested_messages) { - set<const Descriptor*> groups; +typedef std::pair<int, int> FieldRange; +void GatherOccupiedFieldRanges( + const Descriptor* descriptor, std::set<FieldRange>* ranges, + std::vector<const Descriptor*>* nested_messages) { + std::set<const Descriptor*> groups; for (int i = 0; i < descriptor->field_count(); ++i) { const FieldDescriptor* fd = descriptor->field(i); ranges->insert(FieldRange(fd->number(), fd->number() + 1)); @@ -1889,11 +1899,11 @@ void GatherOccupiedFieldRanges(const Descriptor* descriptor, // Actually prints the formatted free field numbers for given message name and // occupied ranges. void FormatFreeFieldNumbers(const string& name, - const set<FieldRange>& ranges) { + const std::set<FieldRange>& ranges) { string output; StringAppendF(&output, "%-35s free:", name.c_str()); int next_free_number = 1; - for (set<FieldRange>::const_iterator i = ranges.begin(); + for (std::set<FieldRange>::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { // This happens when groups re-use parent field numbers, in which // case we skip the FieldRange entirely. @@ -1920,8 +1930,8 @@ void FormatFreeFieldNumbers(const string& name, void CommandLineInterface::PrintFreeFieldNumbers( const Descriptor* descriptor) { - set<FieldRange> ranges; - vector<const Descriptor*> nested_messages; + std::set<FieldRange> ranges; + std::vector<const Descriptor*> nested_messages; GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages); for (int i = 0; i < nested_messages.size(); ++i) { diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index d779fc87..28471ee7 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -56,9 +56,7 @@ class FileDescriptorProto; // descriptor.pb.h template<typename T> class RepeatedPtrField; // repeated_field.h } // namespace protobuf -} // namespace google -namespace google { namespace protobuf { namespace compiler { @@ -247,24 +245,24 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Generate the given output file from the given input. struct OutputDirective; // see below - bool GenerateOutput(const vector<const FileDescriptor*>& parsed_files, + bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context); - bool GeneratePluginOutput(const vector<const FileDescriptor*>& parsed_files, - const string& plugin_name, - const string& parameter, - GeneratorContext* generator_context, - string* error); + bool GeneratePluginOutput( + const std::vector<const FileDescriptor*>& parsed_files, + const string& plugin_name, const string& parameter, + GeneratorContext* generator_context, string* error); // Implements --encode and --decode. bool EncodeOrDecode(const DescriptorPool* pool); // Implements the --descriptor_set_out option. - bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files); + bool WriteDescriptorSet( + const std::vector<const FileDescriptor*> parsed_files); // Implements the --dependency_out option bool GenerateDependencyManifestFile( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const GeneratorContextMap& output_directories, DiskSourceTree* source_tree); @@ -281,7 +279,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { const FileDescriptor* file, bool include_json_name, bool include_source_code_info, - set<const FileDescriptor*>* already_seen, + std::set<const FileDescriptor*>* already_seen, RepeatedPtrField<FileDescriptorProto>* output); // Implements the --print_free_field_numbers. This function prints free field @@ -315,16 +313,16 @@ class LIBPROTOC_EXPORT CommandLineInterface { CodeGenerator* generator; string help_text; }; - typedef map<string, GeneratorInfo> GeneratorMap; + typedef std::map<string, GeneratorInfo> GeneratorMap; GeneratorMap generators_by_flag_name_; GeneratorMap generators_by_option_name_; // A map from generator names to the parameters specified using the option // flag. For example, if the user invokes the compiler with: // protoc --foo_out=outputdir --foo_opt=enable_bar ... // Then there will be an entry ("--foo_out", "enable_bar") in this map. - map<string, string> generator_parameters_; + std::map<string, string> generator_parameters_; // Similar to generator_parameters_, but stores the parameters for plugins. - map<string, string> plugin_parameters_; + std::map<string, string> plugin_parameters_; // See AllowPlugins(). If this is empty, plugins aren't allowed. string plugin_prefix_; @@ -332,7 +330,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { // Maps specific plugin names to files. When executing a plugin, this map // is searched first to find the plugin executable. If not found here, the // PATH (or other OS-specific search strategy) is searched. - map<string, string> plugins_; + std::map<string, string> plugins_; // Stuff parsed from command line. enum Mode { @@ -358,12 +356,13 @@ class LIBPROTOC_EXPORT CommandLineInterface { ErrorFormat error_format_; - vector<pair<string, string> > proto_path_; // Search path for proto files. - vector<string> input_files_; // Names of the input proto files. + std::vector<std::pair<string, string> > + proto_path_; // Search path for proto files. + std::vector<string> input_files_; // Names of the input proto files. // Names of proto files which are allowed to be imported. Used by build // systems to enforce depend-on-what-you-import. - set<string> direct_dependencies_; + std::set<string> direct_dependencies_; bool direct_dependencies_explicitly_set_; // output_directives_ lists all the files we are supposed to output and what @@ -374,7 +373,7 @@ class LIBPROTOC_EXPORT CommandLineInterface { string parameter; string output_location; }; - vector<OutputDirective> output_directives_; + std::vector<OutputDirective> output_directives_; // When using --encode or --decode, this names the type we are encoding or // decoding. (Empty string indicates --decode_raw.) diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index dfbaa45a..b2ec8426 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -57,6 +57,7 @@ #include <google/protobuf/io/printer.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/testing/file.h> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/substitute.h> @@ -217,7 +218,7 @@ class CommandLineInterfaceTest : public testing::Test { string captured_stdout_; // Pointers which need to be deleted later. - vector<CodeGenerator*> mock_generators_to_delete_; + std::vector<CodeGenerator*> mock_generators_to_delete_; NullCodeGenerator* null_generator_; }; @@ -291,7 +292,7 @@ void CommandLineInterfaceTest::TearDown() { } void CommandLineInterfaceTest::Run(const string& command) { - vector<string> args = Split(command, " ", true); + std::vector<string> args = Split(command, " ", true); if (!disallow_plugins_) { cli_.AllowPlugins("prefix-"); @@ -759,7 +760,7 @@ TEST_F(CommandLineInterfaceTest, TrailingBackslash) { TEST_F(CommandLineInterfaceTest, Win32ErrorMessage) { EXPECT_EQ("The system cannot find the file specified.\r\n", - Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND)); + Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND)); } #endif // defined(_WIN32) || defined(__CYGWIN__) @@ -1582,6 +1583,21 @@ TEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) { ExpectErrorSubstring("Saw json_name: 1"); } +TEST_F(CommandLineInterfaceTest, PluginReceivesCompilerVersion) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "message MockCodeGenerator_ShowVersionNumber {\n" + " optional int32 value = 1;\n" + "}\n"); + + Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring( + StringPrintf("Saw compiler_version: %d %s", + GOOGLE_PROTOBUF_VERSION, + GOOGLE_PROTOBUF_VERSION_SUFFIX)); +} + TEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) { // Test what happens if the plugin isn't found. @@ -1856,7 +1872,7 @@ class EncodeDecodeTest : public testing::Test { enum ReturnCode { SUCCESS, ERROR }; bool Run(const string& command) { - vector<string> args; + std::vector<string> args; args.push_back("protoc"); SplitStringUsing(command, " ", &args); args.push_back("--proto_path=" + TestSourceDir()); diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc index deef290b..bf4e5831 100644 --- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc @@ -114,7 +114,7 @@ class MockGeneratorContext : public GeneratorContext { } private: - map<string, string*> files_; + std::map<string, string*> files_; }; TEST(BootstrapTest, GeneratedDescriptorMatches) { diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 6ced26bc..9493d5f8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -70,7 +70,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, EnumGenerator::~EnumGenerator() {} void EnumGenerator::FillForwardDeclaration( - map<string, const EnumDescriptor*>* enum_names) { + std::map<string, const EnumDescriptor*>* enum_names) { if (!options_.proto_h) { return; } @@ -78,7 +78,7 @@ void EnumGenerator::FillForwardDeclaration( } void EnumGenerator::GenerateDefinition(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; vars["short_name"] = descriptor_->name(); vars["enumbase"] = classname_ + (options_.proto_h ? " : int" : ""); @@ -180,7 +180,7 @@ GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { } void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["nested_name"] = descriptor_->name(); vars["classname"] = classname_; vars["constexpr"] = options_.proto_h ? "constexpr " : ""; @@ -229,33 +229,36 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { } } -void EnumGenerator::GenerateDescriptorInitializer( - io::Printer* printer, int index) { - map<string, string> vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); +void EnumGenerator::GenerateDescriptorInitializer(io::Printer* printer) { + std::map<string, string> vars; + vars["index"] = SimpleItoa(descriptor_->index()); + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); if (descriptor_->containing_type() == NULL) { printer->Print(vars, - "$classname$_descriptor_ = file->enum_type($index$);\n"); + "file_level_enum_descriptors[$index_in_metadata$] = " + "file->enum_type($index$);\n"); } else { vars["parent"] = ClassName(descriptor_->containing_type(), false); printer->Print(vars, - "$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\n"); + "file_level_enum_descriptors[$index_in_metadata$] = " + "$parent$_descriptor->enum_type($index$);\n"); } } void EnumGenerator::GenerateMethods(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); vars["constexpr"] = options_.proto_h ? "constexpr " : ""; if (HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print(vars, - "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n"); + printer->Print( + vars, + "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_enum_descriptors[$index_in_metadata$];\n" + "}\n"); } printer->Print(vars, @@ -266,13 +269,13 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) { // each number once by first constructing a set containing all valid // numbers, then printing a case statement for each element. - set<int> numbers; + std::set<int> numbers; for (int j = 0; j < descriptor_->value_count(); j++) { const EnumValueDescriptor* value = descriptor_->value(j); numbers.insert(value->number()); } - for (set<int>::iterator iter = numbers.begin(); + for (std::set<int>::iterator iter = numbers.begin(); iter != numbers.end(); ++iter) { printer->Print( " case $number$:\n", diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.h b/src/google/protobuf/compiler/cpp/cpp_enum.h index 90edf001..0b568c57 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum.h @@ -66,7 +66,8 @@ class EnumGenerator { // enums. A given key in enum_names will map from an enum class name to the // EnumDescriptor that was responsible for its inclusion in the map. This can // be used to associate the descriptor with the code generated for it. - void FillForwardDeclaration(map<string, const EnumDescriptor*>* enum_names); + void FillForwardDeclaration( + std::map<string, const EnumDescriptor*>* enum_names); // Generate header code defining the enum. This code should be placed // within the enum's package namespace, but NOT within any class, even for @@ -87,7 +88,7 @@ class EnumGenerator { // Generate code that initializes the global variable storing the enum's // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); + void GenerateDescriptorInitializer(io::Printer* printer); // Generate non-inline methods related to the enum, such as IsValidValue(). // Goes in the .cc file. @@ -100,6 +101,9 @@ class EnumGenerator { // whether to generate the *_ARRAYSIZE constant. const bool generate_array_size_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index c3dfa817..b6658079 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -46,7 +46,7 @@ namespace cpp { namespace { void SetEnumVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); const EnumValueDescriptor* default_value = descriptor->default_value_enum(); @@ -82,7 +82,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void EnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -122,6 +122,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void EnumFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_ = from.$name$_;\n"); +} + +void EnumFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "int value;\n" @@ -142,7 +147,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { } else { printer->Print( "} else {\n" - " unknown_fields_stream.WriteVarint32($tag$);\n" + " unknown_fields_stream.WriteVarint32($tag$u);\n" " unknown_fields_stream.WriteVarint32(value);\n", "tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_))); } @@ -186,7 +191,7 @@ EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {} void EnumOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -223,8 +228,9 @@ GenerateSwappingCode(io::Printer* printer) const { void EnumOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, - " $classname$_default_oneof_instance_->$name$_ = $default$;\n"); + printer->Print( + variables_, + " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); } // =================================================================== @@ -262,7 +268,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedEnumFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$(int index) const {\n" @@ -311,11 +317,6 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedEnumFieldGenerator:: -GenerateUnsafeMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); -} - -void RepeatedEnumFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/src/google/protobuf/compiler/cpp/cpp_enum_field.h index 57ffeec5..3ecd7ba8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -58,6 +58,7 @@ class EnumFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -65,7 +66,7 @@ class EnumFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); @@ -101,9 +102,9 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; - void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; @@ -112,7 +113,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index 4554c72c..e4fce461 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -92,7 +92,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor, ExtensionGenerator::~ExtensionGenerator() {} void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["number" ] = SimpleItoa(descriptor_->number()); vars["type_traits" ] = type_traits_; @@ -128,7 +128,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { ClassName(descriptor_->extension_scope(), false) + "::"; string name = scope + descriptor_->name(); - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["type_traits" ] = type_traits_; vars["name" ] = name; @@ -167,7 +167,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) { } void ExtensionGenerator::GenerateRegistration(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; vars["extendee" ] = ExtendeeClassName(descriptor_); vars["number" ] = SimpleItoa(descriptor_->number()); vars["field_type" ] = SimpleItoa(static_cast<int>(descriptor_->type())); diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index e2033c1a..4480a9d2 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -59,7 +59,7 @@ namespace cpp { using internal::WireFormat; void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { (*variables)["name"] = FieldName(descriptor); (*variables)["index"] = SimpleItoa(descriptor->index()); @@ -98,7 +98,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, } void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { const string prefix = descriptor->containing_oneof()->name() + "_."; (*variables)["oneof_prefix"] = prefix; (*variables)["oneof_name"] = descriptor->containing_oneof()->name(); diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index fdd338a6..00dc25d4 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -61,11 +61,11 @@ namespace cpp { // ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size', // 'deprecation']. void SetCommonFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options); void SetCommonOneofFieldVariables(const FieldDescriptor* descriptor, - map<string, string>* variables); + std::map<string, string>* variables); class FieldGenerator { public: @@ -124,10 +124,20 @@ class FieldGenerator { io::Printer* /*printer*/) const {} // Generate lines of code (statements, not declarations) which clear the - // field. This is used to define the clear_$name$() method as well as - // the Clear() method for the whole message. + // field. This is used to define the clear_$name$() method virtual void GenerateClearingCode(io::Printer* printer) const = 0; + // Generate lines of code (statements, not declarations) which clear the field + // as part of the Clear() method for the whole message. For message types + // which have field presence bits, MessageGenerator::GenerateClear will have + // already checked the presence bits. + // + // Since most field types can re-use GenerateClearingCode, this method is not + // pure virtual. + virtual void GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); + } + // Generate lines of code (statements, not declarations) which merges the // contents of the field from the current message to the target message, // which is stored in the generated code variable "from". @@ -136,12 +146,8 @@ class FieldGenerator { // GenerateMergeFrom method. virtual void GenerateMergingCode(io::Printer* printer) const = 0; - // The same, but the generated code may or may not check the possibility that - // the two objects being merged have the same address. To be safe, callers - // should avoid calling this unless they know the objects are different. - virtual void GenerateUnsafeMergingCode(io::Printer* printer) const { - GenerateMergingCode(printer); - } + // Generates a copy constructor + virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 369497ce..bc664c70 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -60,33 +60,42 @@ namespace cpp { FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) : file_(file), options_(options), - message_generators_( - new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]), - enum_generators_( - new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]), - service_generators_( - new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]), - extension_generators_( - new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) { + message_generators_owner_( + new google::protobuf::scoped_ptr<MessageGenerator>[ file->message_type_count() ]), + enum_generators_owner_( + new google::protobuf::scoped_ptr<EnumGenerator>[ file->enum_type_count() ]), + service_generators_owner_( + new google::protobuf::scoped_ptr<ServiceGenerator>[ file->service_count() ]), + extension_generators_owner_( + new google::protobuf::scoped_ptr<ExtensionGenerator>[ file->extension_count() ]) { for (int i = 0; i < file->message_type_count(); i++) { - message_generators_[i].reset( - new MessageGenerator(file->message_type(i), options)); + message_generators_owner_[i].reset( + new MessageGenerator(file->message_type(i), options)); + message_generators_owner_[i]->Flatten(&message_generators_); + } + + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->AddGenerators(&enum_generators_, + &extension_generators_); } for (int i = 0; i < file->enum_type_count(); i++) { - enum_generators_[i].reset( - new EnumGenerator(file->enum_type(i), options)); + enum_generators_owner_[i].reset( + new EnumGenerator(file->enum_type(i), options)); + enum_generators_.push_back(enum_generators_owner_[i].get()); } for (int i = 0; i < file->service_count(); i++) { - service_generators_[i].reset( - new ServiceGenerator(file->service(i), options)); + service_generators_owner_[i].reset( + new ServiceGenerator(file->service(i), options)); + service_generators_.push_back(service_generators_owner_[i].get()); } for (int i = 0; i < file->extension_count(); i++) { - extension_generators_[i].reset( - new ExtensionGenerator(file->extension(i), options)); + extension_generators_owner_[i].reset( + new ExtensionGenerator(file->extension(i), options)); + extension_generators_.push_back(extension_generators_owner_[i].get()); } package_parts_ = Split(file_->package(), ".", true); @@ -94,29 +103,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) FileGenerator::~FileGenerator() {} -void FileGenerator::GenerateProtoHeader(io::Printer* printer, - const string& info_path) { - if (!options_.proto_h) { - return; - } - - string filename_identifier = FilenameIdentifier(file_->name()); - GenerateTopHeaderGuard(printer, filename_identifier); - - - GenerateLibraryIncludes(printer); - - for (int i = 0; i < file_->public_dependency_count(); i++) { - const FileDescriptor* dep = file_->public_dependency(i); - const char* extension = ".proto.h"; - string dependency = StripProto(dep->name()) + extension; - printer->Print( - "#include \"$dependency$\" // IWYU pragma: export\n", - "dependency", dependency); - } - - GenerateMetadataPragma(printer, info_path); - +void FileGenerator::GenerateHeader(io::Printer* printer) { printer->Print( "// @@protoc_insertion_point(includes)\n"); @@ -166,6 +153,32 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer, "\n" "// @@protoc_insertion_point(global_scope)\n" "\n"); +} + +void FileGenerator::GenerateProtoHeader(io::Printer* printer, + const string& info_path) { + if (!options_.proto_h) { + return; + } + + string filename_identifier = FilenameIdentifier(file_->name()); + GenerateTopHeaderGuard(printer, filename_identifier); + + + GenerateLibraryIncludes(printer); + + for (int i = 0; i < file_->public_dependency_count(); i++) { + const FileDescriptor* dep = file_->public_dependency(i); + const char* extension = ".proto.h"; + string dependency = StripProto(dep->name()) + extension; + printer->Print( + "#include \"$dependency$\" // IWYU pragma: export\n", + "dependency", dependency); + } + + GenerateMetadataPragma(printer, info_path); + + GenerateHeader(printer); GenerateBottomHeaderGuard(printer, filename_identifier); } @@ -185,59 +198,29 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, GenerateDependencyIncludes(printer); GenerateMetadataPragma(printer, info_path); - printer->Print( - "// @@protoc_insertion_point(includes)\n"); - - - - // Open namespace. - GenerateNamespaceOpeners(printer); - if (!options_.proto_h) { - GenerateGlobalStateFunctionDeclarations(printer); - GenerateMessageForwardDeclarations(printer); - - printer->Print("\n"); - - GenerateEnumDefinitions(printer); - - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateMessageDefinitions(printer); - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateServiceDefinitions(printer); - - GenerateExtensionIdentifiers(printer); - - printer->Print("\n"); - printer->Print(kThickSeparator); - printer->Print("\n"); - - GenerateInlineFunctionDefinitions(printer); - } - - printer->Print( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + GenerateHeader(printer); + } else { + // This is unfortunately necessary for some plugins. I don't see why we + // need two of the same insertion points. + // TODO(gerbens) remove this. + printer->Print( + "// @@protoc_insertion_point(includes)\n"); - // Close up namespace. - GenerateNamespaceClosers(printer); + // Open namespace. + GenerateNamespaceOpeners(printer); + printer->Print( + "\n" + "// @@protoc_insertion_point(namespace_scope)\n"); + // Close up namespace. + GenerateNamespaceClosers(printer); - if (!options_.proto_h) { - // We need to specialize some templates in the ::google::protobuf namespace: - GenerateProto2NamespaceEnumSpecializations(printer); + printer->Print( + "\n" + "// @@protoc_insertion_point(global_scope)\n" + "\n"); } - printer->Print( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - GenerateBottomHeaderGuard(printer, filename_identifier); } @@ -267,7 +250,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "right", use_system_include ? ">" : "\""); // Unknown fields implementation in lite mode uses StringOutputStream - if (!UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) { + if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { printer->Print( "#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n"); } @@ -297,25 +280,48 @@ void FileGenerator::GenerateSource(io::Printer* printer) { GenerateNamespaceOpeners(printer); + for (int i = 0; i < message_generators_.size(); i++) { + if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; + printer->Print( + "class $classname$DefaultTypeInternal : " + "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {};\n" + "$classname$DefaultTypeInternal _$classname$_default_instance_;\n", + "classname", message_generators_[i]->classname_); + } + if (HasDescriptorMethods(file_, options_)) { printer->Print( "\n" "namespace {\n" "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorDeclarations(printer); + + if (!message_generators_.empty()) { + printer->Print("::google::protobuf::Metadata file_level_metadata[$size$];\n", + "size", SimpleItoa(message_generators_.size())); } - for (int i = 0; i < file_->enum_type_count(); i++) { + if (!enum_generators_.empty()) { printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(file_->enum_type(i), false)); + "const ::google::protobuf::EnumDescriptor* " + "file_level_enum_descriptors[$size$];\n", + "size", SimpleItoa(enum_generators_.size())); + } + if (HasGenericServices(file_, options_) && file_->service_count() > 0) { + printer->Print( + "const ::google::protobuf::ServiceDescriptor* " + "file_level_service_descriptors[$size$];\n", + "size", SimpleItoa(file_->service_count())); } + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->index_in_metadata_ = i; + message_generators_[i]->GenerateDescriptorDeclarations(printer); + } + for (int i = 0; i < enum_generators_.size(); i++) { + enum_generators_[i]->index_in_metadata_ = i; + } if (HasGenericServices(file_, options_)) { - for (int i = 0; i < file_->service_count(); i++) { - printer->Print( - "const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\n", - "name", file_->service(i)->name()); + for (int i = 0; i < service_generators_.size(); i++) { + service_generators_[i]->index_in_metadata_ = i; } } @@ -330,26 +336,12 @@ void FileGenerator::GenerateSource(io::Printer* printer) { GenerateBuildDescriptors(printer); // Generate enums. - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateMethods(printer); } // Generate classes. - for (int i = 0; i < file_->message_type_count(); i++) { - if (i == 0 && HasGeneratedMethods(file_, options_)) { - printer->Print( - "\n" - "namespace {\n" - "\n" - "static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD" - " GOOGLE_ATTRIBUTE_NORETURN;\n" - "static void MergeFromFail(int line) {\n" - " ::google::protobuf::internal::MergeFromFail(__FILE__, line);\n" - "}\n" - "\n" - "} // namespace\n" - "\n"); - } + for (int i = 0; i < message_generators_.size(); i++) { printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -364,7 +356,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { if (HasGenericServices(file_, options_)) { // Generate services. - for (int i = 0; i < file_->service_count(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i == 0) printer->Print("\n"); printer->Print(kThickSeparator); printer->Print("\n"); @@ -373,7 +365,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { } // Define extensions. - for (int i = 0; i < file_->extension_count(); i++) { + for (int i = 0; i < extension_generators_.size(); i++) { extension_generators_[i]->GenerateDefinition(printer); } @@ -391,8 +383,9 @@ void FileGenerator::GenerateSource(io::Printer* printer) { class FileGenerator::ForwardDeclarations { public: ~ForwardDeclarations() { - for (map<string, ForwardDeclarations *>::iterator it = namespaces_.begin(), - end = namespaces_.end(); + for (std::map<string, ForwardDeclarations*>::iterator + it = namespaces_.begin(), + end = namespaces_.end(); it != end; ++it) { delete it->second; } @@ -407,11 +400,11 @@ class FileGenerator::ForwardDeclarations { return ns; } - map<string, const Descriptor*>& classes() { return classes_; } - map<string, const EnumDescriptor*>& enums() { return enums_; } + std::map<string, const Descriptor*>& classes() { return classes_; } + std::map<string, const EnumDescriptor*>& enums() { return enums_; } void Print(io::Printer* printer) const { - for (map<string, const EnumDescriptor *>::const_iterator + for (std::map<string, const EnumDescriptor *>::const_iterator it = enums_.begin(), end = enums_.end(); it != end; ++it) { @@ -420,13 +413,21 @@ class FileGenerator::ForwardDeclarations { printer->Print("bool $enumname$_IsValid(int value);\n", "enumname", it->first); } - for (map<string, const Descriptor *>::const_iterator it = classes_.begin(), - end = classes_.end(); + for (std::map<string, const Descriptor*>::const_iterator + it = classes_.begin(), + end = classes_.end(); it != end; ++it) { printer->Print("class $classname$;\n", "classname", it->first); printer->Annotate("classname", it->second); + + printer->Print( + "class $classname$DefaultTypeInternal;\n" + "extern $classname$DefaultTypeInternal " + "_$classname$_default_instance_;\n", // NOLINT + "classname", + it->first); } - for (map<string, ForwardDeclarations *>::const_iterator + for (std::map<string, ForwardDeclarations *>::const_iterator it = namespaces_.begin(), end = namespaces_.end(); it != end; ++it) { @@ -440,9 +441,9 @@ class FileGenerator::ForwardDeclarations { private: - map<string, ForwardDeclarations*> namespaces_; - map<string, const Descriptor*> classes_; - map<string, const EnumDescriptor*> enums_; + std::map<string, ForwardDeclarations*> namespaces_; + std::map<string, const Descriptor*> classes_; + std::map<string, const EnumDescriptor*> enums_; }; void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { @@ -465,75 +466,135 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // and we only use AddDescriptors() to allocate default instances. if (HasDescriptorMethods(file_, options_)) { - printer->Print( - "\n" - "void $assigndescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\n" - "void $assigndescriptorsname$() {\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - printer->Indent(); - - // Make sure the file has found its way into the pool. If a descriptor - // is requested *during* static init then AddDescriptors() may not have - // been called yet, so we call it manually. Note that it's fine if - // AddDescriptors() is called multiple times. - printer->Print( - "$adddescriptorsname$();\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + if (!message_generators_.empty()) { + printer->Print( + "\n" + "const ::google::protobuf::uint32* $offsetfunname$() GOOGLE_ATTRIBUTE_COLD;\n" + "const ::google::protobuf::uint32* $offsetfunname$() {\n", + "offsetfunname", GlobalOffsetTableName(file_->name())); + printer->Indent(); - // Get the file's descriptor from the pool. - printer->Print( - "const ::google::protobuf::FileDescriptor* file =\n" - " ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n" - " \"$filename$\");\n" - // Note that this GOOGLE_CHECK is necessary to prevent a warning about "file" - // being unused when compiling an empty .proto file. - "GOOGLE_CHECK(file != NULL);\n", - "filename", file_->name()); + printer->Print("static const ::google::protobuf::uint32 offsets[] = {\n"); + printer->Indent(); + std::vector<std::pair<size_t, size_t> > pairs; + for (int i = 0; i < message_generators_.size(); i++) { + pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); + } + printer->Outdent(); + printer->Outdent(); + printer->Print( + " };\n" + " return offsets;\n" + "}\n" + "\n"); - // Go through all the stuff defined in this file and generated code to - // assign the global descriptor pointers based on the file descriptor. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - for (int i = 0; i < file_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - if (HasGenericServices(file_, options_)) { - for (int i = 0; i < file_->service_count(); i++) { - service_generators_[i]->GenerateDescriptorInitializer(printer, i); + printer->Print( + "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n"); + printer->Indent(); + { + int offset = 0; + for (int i = 0; i < message_generators_.size(); i++) { + message_generators_[i]->GenerateSchema(printer, offset, + pairs[i].second); + offset += pairs[i].first; + } + } + printer->Outdent(); + printer->Print( + "};\n" + "\n" + "static const ::google::protobuf::internal::DefaultInstanceData " + "file_default_instances[] = {\n"); + printer->Indent(); + for (int i = 0; i < message_generators_.size(); i++) { + const Descriptor* descriptor = message_generators_[i]->descriptor_; + if (IsMapEntryMessage(descriptor)) continue; + + string oneof_default = "NULL"; + if (message_generators_[i]->descriptor_->oneof_decl_count()) { + oneof_default = + "&" + ClassName(descriptor, false) + "_default_oneof_instance_"; + } + printer->Print( + "{reinterpret_cast<const " + "::google::protobuf::Message*>(&_$classname$_default_instance_), " + "$oneof_default$},\n", + "classname", ClassName(descriptor, false), "oneof_default", + oneof_default); } + printer->Outdent(); + printer->Print( + "};\n" + "\n"); + } else { + // we still need these symbols to exist + printer->Print( + "inline ::google::protobuf::uint32* $offsetfunname$() { return NULL; }\n" + "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" + "static const ::google::protobuf::internal::DefaultInstanceData* " + "file_default_instances = NULL;\n", + "offsetfunname", + GlobalOffsetTableName(file_->name())); } - printer->Outdent(); - printer->Print( - "}\n" - "\n"); - // --------------------------------------------------------------- // protobuf_AssignDescriptorsOnce(): The first time it is called, calls // AssignDescriptors(). All later times, waits for the first call to // complete and then returns. + string message_factory = "NULL"; printer->Print( "namespace {\n" "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\n" + "void protobuf_AssignDescriptors() {\n" + // Make sure the file has found its way into the pool. If a descriptor + // is requested *during* static init then AddDescriptors() may not have + // been called yet, so we call it manually. Note that it's fine if + // AddDescriptors() is called multiple times. + " $adddescriptorsname$();\n" + " ::google::protobuf::MessageFactory* factory = $factory$;\n" + " AssignDescriptors(\n" + " \"$filename$\", schemas, file_default_instances, " + "$offsetfunname$(), factory,\n" + " $metadata$, $enum_descriptors$, $service_descriptors$);\n" + "}\n" + "\n" "void protobuf_AssignDescriptorsOnce() {\n" - " ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n" - " &$assigndescriptorsname$);\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);\n" "}\n" "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name())); - - // protobuf_RegisterTypes(): Calls - // MessageFactory::InternalRegisterGeneratedType() for each message type. + "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), + "offsetfunname", GlobalOffsetTableName(file_->name()), "filename", + file_->name(), "metadata", + !message_generators_.empty() ? "file_level_metadata" : "NULL", + "enum_descriptors", + !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL", + "service_descriptors", + HasGenericServices(file_, options_) && file_->service_count() > 0 + ? "file_level_service_descriptors" + : "NULL", + "factory", message_factory); + + // Only here because of useless string reference that we don't want in + // protobuf_AssignDescriptorsOnce, because that is called from all the + // GetMetadata member methods. printer->Print( "void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\n" "void protobuf_RegisterTypes(const ::std::string&) {\n" " protobuf_AssignDescriptorsOnce();\n"); printer->Indent(); - for (int i = 0; i < file_->message_type_count(); i++) { + // All normal messages can be done generically + if (!message_generators_.empty()) { + printer->Print( + "::google::protobuf::internal::RegisterAllTypes(file_level_metadata, $size$);\n", + "size", SimpleItoa(message_generators_.size())); + } + + // Map types are treated special + // TODO(gerbens) find a way to treat maps more like normal messages. + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateTypeRegistrations(printer); } @@ -553,7 +614,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "shutdownfilename", GlobalShutdownFileName(file_->name())); printer->Indent(); - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateShutdownCode(printer); } @@ -566,8 +627,8 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // Now generate the InitDefaults() function. printer->Print( "void $initdefaultsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n", + " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" + "", // Vars. "initdefaultsname", GlobalInitDefaultsName(file_->name())); @@ -586,26 +647,28 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "name", add_desc_name); } + // Force initialization of primitive values we depend on. + printer->Print("::google::protobuf::internal::InitProtobufDefaults();\n"); + // Allocate and initialize default instances. This can't be done lazily // since default instances are returned by simple accessors and are used with // extensions. Speaking of which, we also register extensions at this time. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateDefaultInstanceAllocator(printer); } - for (int i = 0; i < file_->extension_count(); i++) { + for (int i = 0; i < extension_generators_.size(); i++) { extension_generators_[i]->GenerateRegistration(printer); } - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->GenerateDefaultInstanceInitializer(printer); } printer->Outdent(); printer->Print( "}\n" "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE($initdefaultsname$_once_);\n" "void $initdefaultsname$() {\n" - " ::google::protobuf::GoogleOnceInit(&$initdefaultsname$_once_,\n" - " &$initdefaultsname$_impl);\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &$initdefaultsname$_impl);\n" "}\n", "initdefaultsname", GlobalInitDefaultsName(file_->name())); @@ -614,8 +677,6 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // Now generate the AddDescriptors() function. printer->Print( "void $adddescriptorsname$_impl() {\n" - " GOOGLE_PROTOBUF_VERIFY_VERSION;\n" - "\n" " $initdefaultsname$();\n", // Vars. "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), @@ -632,60 +693,42 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { string file_data; file_proto.SerializeToString(&file_data); + printer->Print("static const char descriptor[] = {\n"); + printer->Indent(); + #ifdef _MSC_VER bool breakdown_large_file = true; #else bool breakdown_large_file = false; #endif - // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 - // bytes in length". Declare a static array of characters rather than use a - // string literal. - if (breakdown_large_file && file_data.size() > 65535) { - // This has to be explicitly marked as a signed char because the generated - // code puts negative values in the array, and sometimes plain char is - // unsigned. That implicit narrowing conversion is not allowed in C++11. - // <http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin> - // has details on why. - printer->Print( - "static const signed char descriptor[] = {\n"); - printer->Indent(); - - // Only write 25 bytes per line. + if (breakdown_large_file && file_data.size() > 66538) { + // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 + // bytes in length". Declare a static array of characters rather than use + // a string literal. Only write 25 bytes per line. static const int kBytesPerLine = 25; for (int i = 0; i < file_data.size();) { - for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { - printer->Print( - "$char$, ", - "char", SimpleItoa(file_data[i])); - } - printer->Print( - "\n"); + for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { + printer->Print("'$char$', ", "char", + CEscape(file_data.substr(i, 1))); + } + printer->Print("\n"); } - - printer->Outdent(); - printer->Print( - "};\n"); - - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, $size$);\n", - "size", SimpleItoa(file_data.size())); - } else { - printer->Print( - "::google::protobuf::DescriptorPool::InternalAddGeneratedFile("); - // Only write 40 bytes per line. static const int kBytesPerLine = 40; for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - printer->Print("\n \"$data$\"", - "data", - EscapeTrigraphs( - CEscape(file_data.substr(i, kBytesPerLine)))); + printer->Print(" \"$data$\"\n", "data", + EscapeTrigraphs(CEscape( + file_data.substr(i, kBytesPerLine)))); + } } + + printer->Outdent(); + printer->Print("};\n"); printer->Print( - ", $size$);\n", + "::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n" + " descriptor, $size$);\n", "size", SimpleItoa(file_data.size())); - } // Call MessageFactory::InternalRegisterGeneratedFile(). printer->Print( @@ -722,7 +765,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); if (!StaticInitializersForced(file_, options_)) { - printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + printer->Print("#ifndef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); } printer->Print( // With static initializers. @@ -777,14 +820,11 @@ void FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) { decls = decls->AddOrGetNamespace(package_parts_[i]); } // Generate enum definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->FillEnumForwardDeclarations(&decls->enums()); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->FillForwardDeclaration(&decls->enums()); } // Generate forward declarations of classes. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { message_generators_[i]->FillMessageForwardDeclarations( &decls->classes()); } @@ -840,12 +880,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { printer->Print( "#include <google/protobuf/arena.h>\n" "#include <google/protobuf/arenastring.h>\n" - "#include <google/protobuf/generated_message_util.h>\n"); - if (UseUnknownFieldSet(file_, options_)) { - printer->Print( - "#include <google/protobuf/metadata.h>\n"); - } - if (file_->message_type_count() > 0) { + "#include <google/protobuf/generated_message_util.h>\n" + "#include <google/protobuf/metadata.h>\n"); + + if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { printer->Print( "#include <google/protobuf/message.h>\n"); @@ -855,8 +893,10 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { } } printer->Print( - "#include <google/protobuf/repeated_field.h>\n" - "#include <google/protobuf/extension_set.h>\n"); + "#include <google/protobuf/repeated_field.h>" + " // IWYU pragma: export\n" + "#include <google/protobuf/extension_set.h>" + " // IWYU pragma: export\n"); if (HasMapFields(file_)) { printer->Print( "#include <google/protobuf/map.h>\n"); @@ -884,7 +924,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { "#include <google/protobuf/service.h>\n"); } - if (UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) { + if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { printer->Print( "#include <google/protobuf/unknown_field_set.h>\n"); } @@ -910,7 +950,7 @@ void FileGenerator::GenerateMetadataPragma(io::Printer* printer, } void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { - set<string> public_import_names; + std::set<string> public_import_names; for (int i = 0; i < file_->public_dependency_count(); i++) { public_import_names.insert(file_->public_dependency(i)->name()); } @@ -943,33 +983,11 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "dllexport_decl", options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); - - printer->Print( - // Note that we don't put dllexport_decl on these because they are only - // called by the .pb.cc file in which they are defined. - "void $assigndescriptorsname$();\n" - "void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", GlobalAssignDescriptorsName(file_->name()), - "shutdownfilename", GlobalShutdownFileName(file_->name())); -} - -void FileGenerator::GenerateMessageForwardDeclarations(io::Printer* printer) { - map<string, const Descriptor*> classes; - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->FillMessageForwardDeclarations(&classes); - } - for (map<string, const Descriptor *>::const_iterator it = classes.begin(), - end = classes.end(); - it != end; ++it) { - printer->Print("class $classname$;\n", "classname", it->first); - printer->Annotate("classname", it->second); - } } void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { // Generate class definitions. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print("\n"); printer->Print(kThinSeparator); @@ -981,10 +999,7 @@ void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { // Generate enum definitions. - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateEnumDefinitions(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateDefinition(printer); } } @@ -992,7 +1007,7 @@ void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { if (HasGenericServices(file_, options_)) { // Generate service definitions. - for (int i = 0; i < file_->service_count(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i > 0) { printer->Print("\n"); printer->Print(kThinSeparator); @@ -1008,9 +1023,10 @@ void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { } void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { - // Declare extension identifiers. + // Declare extension identifiers. These are in global scope and so only + // the global scope extensions. for (int i = 0; i < file_->extension_count(); i++) { - extension_generators_[i]->GenerateDeclaration(printer); + extension_generators_owner_[i]->GenerateDeclaration(printer); } } @@ -1051,7 +1067,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { printer->Print("#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); // Generate class inline methods. - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print(kThinSeparator); printer->Print("\n"); @@ -1061,7 +1077,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { } printer->Print("#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS\n"); - for (int i = 0; i < file_->message_type_count(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { printer->Print(kThinSeparator); printer->Print("\n"); @@ -1084,10 +1100,7 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations( "#ifndef SWIG\n" "namespace google {\nnamespace protobuf {\n" "\n"); - for (int i = 0; i < file_->message_type_count(); i++) { - message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < file_->enum_type_count(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); } printer->Print( diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index 5dcf692b..25d6eabf 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -68,6 +68,9 @@ class FileGenerator { FileGenerator(const FileDescriptor* file, const Options& options); ~FileGenerator(); + // Shared code between the two header generators below. + void GenerateHeader(io::Printer* printer); + // info_path, if non-empty, should be the path (relative to printer's output) // to the metadata file describing this proto header. void GenerateProtoHeader(io::Printer* printer, @@ -117,18 +120,6 @@ class FileGenerator { // Generates types for classes. void GenerateMessageDefinitions(io::Printer* printer); - // Generates forward-declarations for just this file's classes. This is - // used for .pb.h headers, but not in proto_h mode. - void GenerateMessageForwardDeclarations(io::Printer* printer); - - // Fills in types for forward declarations. This is used internally, and - // also by other FileGenerators to determine imports' declarations. - void FillMessageForwardDeclarations(ForwardDeclarations* decls); - void FillMessageDefinitions(ForwardDeclarations* decls); - - // Generates enum definitions. - void GenerateEnumForwardDeclarations(io::Printer* printer); - void FillEnumForwardDeclarations(ForwardDeclarations* decls); void GenerateEnumDefinitions(io::Printer* printer); // Generates generic service definitions. @@ -145,13 +136,25 @@ class FileGenerator { const FileDescriptor* file_; const Options options_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > message_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > service_generators_; - google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; + // Contains the post-order walk of all the messages (and child messages) in + // this file. If you need a pre-order walk just reverse iterate. + std::vector<MessageGenerator*> message_generators_; + std::vector<EnumGenerator*> enum_generators_; + std::vector<ServiceGenerator*> service_generators_; + std::vector<ExtensionGenerator*> extension_generators_; + + // These members are just for owning (and thus proper deleting). Some of the + // message_ and enum_generators above are owned by child messages. + google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > + message_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > + service_generators_owner_; + google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > + extension_generators_owner_; // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector<string> package_parts_; + std::vector<string> package_parts_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index 31d189c2..648ab28a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -59,7 +59,7 @@ bool CppGenerator::Generate(const FileDescriptor* file, const string& parameter, GeneratorContext* generator_context, string* error) const { - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); // ----------------------------------------------------------------- diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 6d844cc2..5a37b9d7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -371,9 +371,9 @@ string DefaultValue(const FieldDescriptor* field) { return "GOOGLE_ULONGLONG(" + SimpleItoa(field->default_value_uint64())+ ")"; case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field->default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { return "::google::protobuf::internal::Infinity()"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { return "-::google::protobuf::internal::Infinity()"; } else if (value != value) { return "::google::protobuf::internal::NaN()"; @@ -384,9 +384,9 @@ string DefaultValue(const FieldDescriptor* field) { case FieldDescriptor::CPPTYPE_FLOAT: { float value = field->default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { return "static_cast<float>(::google::protobuf::internal::Infinity())"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { return "static_cast<float>(-::google::protobuf::internal::Infinity())"; } else if (value != value) { return "static_cast<float>(::google::protobuf::internal::NaN())"; @@ -450,8 +450,8 @@ string GlobalInitDefaultsName(const string& filename) { } // Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename) { - return "protobuf_AssignDesc_" + FilenameIdentifier(filename); +string GlobalOffsetTableName(const string& filename) { + return "protobuf_Offsets_" + FilenameIdentifier(filename); } // Return the name of the ShutdownFile() function for a given file. @@ -602,7 +602,7 @@ static Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field, static void GenerateUtf8CheckCode(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, const char* strict_function, const char* verify_function, @@ -652,7 +652,7 @@ static void GenerateUtf8CheckCode(const FieldDescriptor* field, void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer) { GenerateUtf8CheckCode(field, options, for_parse, variables, parameters, @@ -662,7 +662,7 @@ void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer) { GenerateUtf8CheckCode(field, options, for_parse, variables, parameters, diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index 3a0c0388..c988bda8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -150,8 +150,8 @@ string GlobalAddDescriptorsName(const string& filename); // Return the name of the InitDefaults() function for a given file. string GlobalInitDefaultsName(const string& filename); -// Return the name of the AssignDescriptors() function for a given file. -string GlobalAssignDescriptorsName(const string& filename); +// Return the name of the offset table function for a given file. +string GlobalOffsetTableName(const string& filename); // Return the qualified C++ name for a file level symbol. string QualifiedFileLevelSymbol(const string& package, const string& name); @@ -269,13 +269,13 @@ bool IsWellKnownMessage(const FileDescriptor* descriptor); void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer); void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, const Options& options, bool for_parse, - const map<string, string>& variables, + const std::map<string, string>& variables, const char* parameters, io::Printer* printer); inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 31ac9ca7..5c4b56f7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -45,10 +45,10 @@ bool IsProto3Field(const FieldDescriptor* field_descriptor) { } void SetMessageVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); - (*variables)["type"] = FieldMessageTypeName(descriptor); + (*variables)["type"] = ClassName(descriptor->message_type(), false); (*variables)["stream_writer"] = (*variables)["declared_type"] + (HasFastArraySerialization(descriptor->message_type()->file(), options) @@ -137,7 +137,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void MapFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline" : ""; printer->Print(variables, "$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\n" @@ -154,7 +154,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MapFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; printer->Print(variables, "$this_message$$name$_.Clear();\n"); } @@ -173,14 +173,20 @@ void MapFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print(variables_, - "$name$_.SetAssignDescriptorCallback(\n" - " protobuf_AssignDescriptorsOnce);\n" - "$name$_.SetEntryDescriptor(\n" - " &$type$_descriptor_);\n"); + "$name$_.SetAssignDescriptorCallback(\n" + " protobuf_AssignDescriptorsOnce);\n" + "$name$_.SetEntryDescriptor(\n" + " &$type$_descriptor);\n"); } } void MapFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + GenerateConstructorCode(printer); + GenerateMergingCode(printer); +} + +void MapFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { const FieldDescriptor* key_field = descriptor_->message_type()->FindFieldByName("key"); @@ -224,7 +230,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { "->AddLengthDelimited($number$, data);\n"); } else { printer->Print(variables_, - " unknown_fields_stream.WriteVarint32($tag$);\n" + " unknown_fields_stream.WriteVarint32($tag$u);\n" " unknown_fields_stream.WriteVarint32(data.size());\n" " unknown_fields_stream.WriteString(data);\n"); } @@ -252,7 +258,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { } static void GenerateSerializationLoop(io::Printer* printer, - const map<string, string>& variables, + const std::map<string, string>& variables, bool supports_arenas, const string& utf8_check, const string& loop_header, @@ -291,17 +297,17 @@ static void GenerateSerializationLoop(io::Printer* printer, void MapFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["write_entry"] = "::google::protobuf::internal::WireFormatLite::Write" + variables["stream_writer"] + "(\n " + variables["number"] + ", *entry, output)"; - variables["deterministic"] = "output->IsSerializationDeterminstic()"; + variables["deterministic"] = "output->IsSerializationDeterministic()"; GenerateSerializeWithCachedSizes(printer, variables); } void MapFieldGenerator:: GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["write_entry"] = "target = ::google::protobuf::internal::WireFormatLite::\n" " InternalWrite" + variables["declared_type"] + @@ -312,7 +318,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { } void MapFieldGenerator::GenerateSerializeWithCachedSizes( - io::Printer* printer, const map<string, string>& variables) const { + io::Printer* printer, const std::map<string, string>& variables) const { printer->Print(variables, "if (!this->$name$().empty()) {\n"); printer->Indent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h index 2930fe59..816687b3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h @@ -55,6 +55,7 @@ class MapFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -63,11 +64,11 @@ class MapFieldGenerator : public FieldGenerator { private: // A helper for GenerateSerializeWithCachedSizes{,ToArray}. void GenerateSerializeWithCachedSizes( - io::Printer* printer, const map<string, string>& variables) const; + io::Printer* printer, const std::map<string, string>& variables) const; const FieldDescriptor* descriptor_; const bool dependent_field_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index efc56ddc..2b71acb5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -207,7 +207,7 @@ class FieldGroup { } void SetPreferredLocation(float location) { preferred_location_ = location; } - const vector<const FieldDescriptor*>& fields() const { return fields_; } + const std::vector<const FieldDescriptor*>& fields() const { return fields_; } // FieldGroup objects sort by their preferred location. bool operator<(const FieldGroup& other) const { @@ -221,7 +221,7 @@ class FieldGroup { // approximate, but should put this group close to where its member fields // originally went. float preferred_location_; - vector<const FieldDescriptor*> fields_; + std::vector<const FieldDescriptor*> fields_; // We rely on the default copy constructor and operator= so this type can be // used in a vector. }; @@ -251,6 +251,39 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { } } +bool IsPOD(const FieldDescriptor* field) { + if (field->is_repeated() || field->is_extension()) return false; + switch (field->cpp_type()) { + case internal::WireFormatLite::CPPTYPE_ENUM: + case internal::WireFormatLite::CPPTYPE_INT32: + case internal::WireFormatLite::CPPTYPE_INT64: + case internal::WireFormatLite::CPPTYPE_UINT32: + case internal::WireFormatLite::CPPTYPE_UINT64: + case internal::WireFormatLite::CPPTYPE_FLOAT: + case internal::WireFormatLite::CPPTYPE_DOUBLE: + case internal::WireFormatLite::CPPTYPE_BOOL: + return true; + case internal::WireFormatLite::CPPTYPE_STRING: + return false; + default: + return false; + } +} + +// Helper for the code that emits the SharedCtor() method. +bool CanConstructByZeroing(const FieldDescriptor* field, + const Options& options) { + bool ret = CanInitializeByZeroing(field); + + // Non-repeated, non-lazy message fields are simply raw pointers, so we can + // use memset to initialize these in SharedCtor. We cannot use this in + // Clear, as we need to potentially delete the existing value. + ret = ret || + (!field->is_repeated() && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); + return ret; +} + // Reorder 'fields' so that if the fields are output into a c++ class in the new // order, fields of similiar family (see below) are together and within each // family, alignment padding is minimized. @@ -260,9 +293,6 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { // locality much for function that access each field in order. This is also the // only (weak) signal we have for author intent concerning field layout. // -// TODO(ckennelly): Update these functions to use the optimized layout order -// for their access patterns. -// // TODO(ckennelly): If/when we have profiles available for the compiler, use // those rather than respect declaration order. // @@ -275,30 +305,32 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) { // STRING is grouped next, as our Clear/SharedCtor/SharedDtor walks it and // calls ArenaStringPtr::Destroy on each. // +// // MESSAGE is grouped next, as our Clear/SharedDtor code walks it and calls // delete on each. We initialize these fields with a NULL pointer (see -// MessageFieldGenerator::GenerateConstructorCode). -// TODO(ckennelly): memset these in SharedCtor. +// MessageFieldGenerator::GenerateConstructorCode), which allows them to be +// memset. // // ZERO_INITIALIZABLE is memset in Clear/SharedCtor // // OTHER these fields are initialized one-by-one. -void OptimizePadding(vector<const FieldDescriptor*>* fields) { +void OptimizePadding(std::vector<const FieldDescriptor*>* fields, + const Options& options) { // The sorted numeric order of Family determines the declaration order in the // memory layout. enum Family { REPEATED = 0, STRING = 1, MESSAGE = 2, - ZERO_INITIALIZABLE = 3, - OTHER = 4, + ZERO_INITIALIZABLE = 4, + OTHER = 5, kMaxFamily }; // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes. - vector<FieldGroup> aligned_to_1[kMaxFamily]; - vector<FieldGroup> aligned_to_4[kMaxFamily]; - vector<FieldGroup> aligned_to_8[kMaxFamily]; + std::vector<FieldGroup> aligned_to_1[kMaxFamily]; + std::vector<FieldGroup> aligned_to_4[kMaxFamily]; + std::vector<FieldGroup> aligned_to_8[kMaxFamily]; for (int i = 0; i < fields->size(); ++i) { const FieldDescriptor* field = (*fields)[i]; @@ -309,6 +341,7 @@ void OptimizePadding(vector<const FieldDescriptor*>* fields) { f = STRING; } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { f = MESSAGE; + } else if (CanInitializeByZeroing(field)) { f = ZERO_INITIALIZABLE; } @@ -427,23 +460,9 @@ bool HasHasMethod(const FieldDescriptor* field) { return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE; } -size_t HasBitsSize(const Descriptor* descriptor) { - // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. - size_t sizeof_has_bits = (descriptor->field_count() + 31) / 32 * 4; - if (descriptor->field_count() == 0) { - // Zero-size arrays aren't technically allowed, and MSVC in particular - // doesn't like them. We still need to declare these arrays to make - // other code compile. Since this is an uncommon case, we'll just declare - // them with size 1 and waste some space. Oh well. - sizeof_has_bits = 4; - } - - return sizeof_has_bits; -} - // Collects map entry message type information. void CollectMapInfo(const Descriptor* descriptor, - map<string, string>* variables) { + std::map<string, string>* variables) { GOOGLE_CHECK(IsMapEntryMessage(descriptor)); const FieldDescriptor* key = descriptor->FindFieldByName("key"); const FieldDescriptor* val = descriptor->FindFieldByName("value"); @@ -475,6 +494,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) { field->containing_oneof() != NULL); } + } // anonymous namespace // =================================================================== @@ -500,7 +520,33 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, optimized_order_.push_back(descriptor_->field(i)); } } - OptimizePadding(&optimized_order_); + OptimizePadding(&optimized_order_, options_); + + if (HasFieldPresence(descriptor_->file())) { + int has_bit_index = 0; + has_bit_indices_.resize(descriptor_->field_count(), -1); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + // Skip fields that do not have has bits. + if (field->is_repeated()) { + continue; + } + + has_bit_indices_[field->index()] = has_bit_index; + has_bit_index++; + } + + // Assign fields that do not use has bits to be at the end. This can be + // removed once we shrink the has bits we assign. + // + // TODO(ckennelly): Shrink the has bits for these fields. + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (has_bit_indices_[field->index()] < 0) { + has_bit_indices_[field->index()] = has_bit_index++; + } + } + } for (int i = 0; i < descriptor->nested_type_count(); i++) { nested_generators_[i].reset( @@ -534,48 +580,42 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, MessageGenerator::~MessageGenerator() {} -void MessageGenerator:: -FillMessageForwardDeclarations(map<string, const Descriptor*>* class_names) { - (*class_names)[classname_] = descriptor_; - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need forward declaration. Since map entry - // message cannot be a top level class, we just need to avoid calling - // GenerateForwardDeclaration here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->FillMessageForwardDeclarations(class_names); +size_t MessageGenerator::HasBitsSize() const { + // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. + size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4; + if (descriptor_->field_count() == 0) { + // Zero-size arrays aren't technically allowed, and MSVC in particular + // doesn't like them. We still need to declare these arrays to make + // other code compile. Since this is an uncommon case, we'll just declare + // them with size 1 and waste some space. Oh well. + sizeof_has_bits = 4; } -} -void MessageGenerator:: -FillEnumForwardDeclarations(map<string, const EnumDescriptor*>* enum_names) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->FillEnumForwardDeclarations(enum_names); - } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->FillForwardDeclaration(enum_names); - } + return sizeof_has_bits; } -void MessageGenerator:: -GenerateEnumDefinitions(io::Printer* printer) { +void MessageGenerator::Flatten(std::vector<MessageGenerator*>* list) { for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateEnumDefinitions(printer); + nested_generators_[i]->Flatten(list); } + list->push_back(this); +} +void MessageGenerator::AddGenerators( + std::vector<EnumGenerator*>* enum_generators, + std::vector<ExtensionGenerator*>* extension_generators) { for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDefinition(printer); + enum_generators->push_back(enum_generators_[i].get()); + } + for (int i = 0; i < descriptor_->extension_count(); i++) { + extension_generators->push_back(extension_generators_[i].get()); } } -void MessageGenerator:: -GenerateGetEnumDescriptorSpecializations(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } +void MessageGenerator::FillMessageForwardDeclarations( + std::map<string, const Descriptor*>* class_names) { + if (IsMapEntryMessage(descriptor_)) return; + (*class_names)[classname_] = descriptor_; } void MessageGenerator:: @@ -585,7 +625,7 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); if (use_dependent_base_ && IsFieldDependent(field)) { @@ -607,7 +647,7 @@ GenerateFieldAccessorDeclarations(io::Printer* printer) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["constant_name"] = FieldConstantName(field); @@ -679,6 +719,8 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); + if (field->options().weak()) continue; + PrintFieldComment(printer, field); // These functions are not really dependent: they are part of the @@ -688,7 +730,7 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { // See the comment in FileGenerator::GenerateInlineFunctionDefinitions // for a more complete explanation. if (use_dependent_base_ && IsFieldDependent(field)) { - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["inline"] = "inline "; if (field->containing_oneof()) { @@ -725,13 +767,16 @@ GenerateDependentFieldAccessorDefinitions(io::Printer* printer) { void MessageGenerator:: GenerateSingularFieldHasBits(const FieldDescriptor* field, - map<string, string> vars, + std::map<string, string> vars, io::Printer* printer) { if (HasFieldPresence(descriptor_->file())) { // N.B.: without field presence, we do not use has-bits or generate // has_$name$() methods. - vars["has_array_index"] = SimpleItoa(field->index() / 32); - vars["has_mask"] = StrCat(strings::Hex(1u << (field->index() % 32), + int has_bit_index = has_bit_indices_[field->index()]; + GOOGLE_CHECK_GE(has_bit_index, 0); + + vars["has_array_index"] = SimpleItoa(has_bit_index / 32); + vars["has_mask"] = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); printer->Print(vars, "$inline$" @@ -771,7 +816,7 @@ GenerateSingularFieldHasBits(const FieldDescriptor* field, void MessageGenerator:: GenerateOneofHasBits(io::Printer* printer, bool is_inline) { for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["oneof_name"] = descriptor_->oneof_decl(i)->name(); vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index()); vars["cap_oneof_name"] = @@ -793,7 +838,7 @@ GenerateOneofHasBits(io::Printer* printer, bool is_inline) { void MessageGenerator:: GenerateOneofMemberHasBits(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer) { // Singular field in a oneof // N.B.: Without field presence, we do not use has-bits or generate @@ -815,7 +860,7 @@ GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator:: GenerateFieldClear(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer) { // Generate clear_$name$() (See GenerateFieldAccessorDeclarations and // GenerateDependentFieldAccessorDeclarations, $dependent_classname$ is @@ -863,7 +908,7 @@ GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) { PrintFieldComment(printer, field); - map<string, string> vars; + std::map<string, string> vars; SetCommonFieldVariables(field, &vars, options_); vars["inline"] = is_inline ? "inline " : ""; if (use_dependent_base_ && IsFieldDependent(field)) { @@ -925,7 +970,7 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) { return; } - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = DependentBaseClassTemplateName(descriptor_); vars["full_name"] = descriptor_->full_name(); vars["superclass"] = SuperClassName(descriptor_, options_); @@ -951,23 +996,13 @@ GenerateDependentBaseClassDefinition(io::Printer* printer) { void MessageGenerator:: GenerateClassDefinition(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need class definition. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateClassDefinition here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateClassDefinition(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - + if (IsMapEntryMessage(descriptor_)) return; if (use_dependent_base_) { GenerateDependentBaseClassDefinition(printer); printer->Print("\n"); } - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = classname_; vars["full_name"] = descriptor_->full_name(); vars["field_count"] = SimpleItoa(descriptor_->field_count()); @@ -1007,44 +1042,19 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n" - " return _internal_metadata_.unknown_fields();\n" - "}\n" - "\n" - "inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n" - " return _internal_metadata_.mutable_unknown_fields();\n" - "}\n" - "\n"); - } else { - if (SupportsArenas(descriptor_)) { - printer->Print( - "inline const ::std::string& unknown_fields() const {\n" - " return _unknown_fields_.Get(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n" - "inline ::std::string* mutable_unknown_fields() {\n" - " return _unknown_fields_.Mutable(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n" - "}\n" - "\n"); - } else { - printer->Print( - "inline const ::std::string& unknown_fields() const {\n" - " return _unknown_fields_.GetNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n" - "inline ::std::string* mutable_unknown_fields() {\n" - " return _unknown_fields_.MutableNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n" - "}\n" - "\n"); - } - } + string type = UseUnknownFieldSet(descriptor_->file(), options_) + ? "::google::protobuf::UnknownFieldSet" + : "::std::string"; + printer->Print( + "inline const $type$& unknown_fields() const {\n" + " return _internal_metadata_.unknown_fields();\n" + "}\n" + "\n" + "inline $type$* mutable_unknown_fields() {\n" + " return _internal_metadata_.mutable_unknown_fields();\n" + "}\n" + "\n", + "type", type ); } // N.B.: We exclude GetArena() when arena support is disabled, falling back on @@ -1054,8 +1064,10 @@ GenerateClassDefinition(io::Printer* printer) { // virtual method version of GetArenaNoVirtual(), required for generic dispatch given a // MessageLite* (e.g., in RepeatedField::AddAllocated()). printer->Print( - "inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n" - "inline void* GetMaybeArenaPointer() const {\n" + "inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL {\n" + " return GetArenaNoVirtual();\n" + "}\n" + "inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL {\n" " return MaybeArenaPtr();\n" "}\n"); } @@ -1101,7 +1113,10 @@ GenerateClassDefinition(io::Printer* printer) { // TODO(gerbens) make this private, while still granting other protos access. printer->Print( vars, - "static const $classname$* internal_default_instance();\n" + "static inline const $classname$* internal_default_instance() {\n" + " return reinterpret_cast<const $classname$*>(\n" + " &_$classname$_default_instance_);\n" + "}\n" "\n"); @@ -1124,97 +1139,76 @@ GenerateClassDefinition(io::Printer* printer) { "\n"); } + vars["new_final"] = " PROTOBUF_FINAL"; + printer->Print(vars, "void Swap($classname$* other);\n" "\n" "// implements Message ----------------------------------------------\n" "\n" - "inline $classname$* New() const { return New(NULL); }\n" + "inline $classname$* New() const$new_final$ { return New(NULL); }\n" "\n" - "$classname$* New(::google::protobuf::Arena* arena) const;\n"); + "$classname$* New(::google::protobuf::Arena* arena) const$new_final$;\n"); + + // For instances that derive from Message (rather than MessageLite), some + // methods are virtual and should be marked as final. + string use_final = HasDescriptorMethods(descriptor_->file(), options_) ? + " PROTOBUF_FINAL" : ""; if (HasGeneratedMethods(descriptor_->file(), options_)) { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print(vars, - "void CopyFrom(const ::google::protobuf::Message& from);\n" - "void MergeFrom(const ::google::protobuf::Message& from);\n"); + "void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n" + "void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;\n"); } else { printer->Print(vars, - "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);\n"); + "void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from)\n" + " PROTOBUF_FINAL;\n"); } - printer->Print(vars, - "void CopyFrom(const $classname$& from);\n" - "void MergeFrom(const $classname$& from);\n" - "void Clear();\n" - "bool IsInitialized() const;\n" - "\n" - "size_t ByteSizeLong() const;\n" - "bool MergePartialFromCodedStream(\n" - " ::google::protobuf::io::CodedInputStream* input);\n" - "void SerializeWithCachedSizes(\n" - " ::google::protobuf::io::CodedOutputStream* output) const;\n"); + vars["clear_final"] = " PROTOBUF_FINAL"; + vars["is_initialized_final"] = " PROTOBUF_FINAL"; + vars["merge_partial_final"] = " PROTOBUF_FINAL"; + + printer->Print( + vars, + "void CopyFrom(const $classname$& from);\n" + "void MergeFrom(const $classname$& from);\n" + "void Clear()$clear_final$;\n" + "bool IsInitialized() const$is_initialized_final$;\n" + "\n" + "size_t ByteSizeLong() const PROTOBUF_FINAL;\n" + "bool MergePartialFromCodedStream(\n" + " ::google::protobuf::io::CodedInputStream* input)$merge_partial_final$;\n" + "void SerializeWithCachedSizes(\n" + " ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;\n"); // DiscardUnknownFields() is implemented in message.cc using reflections. We // need to implement this function in generated code for messages. if (!UseUnknownFieldSet(descriptor_->file(), options_)) { printer->Print( - "void DiscardUnknownFields();\n"); + "void DiscardUnknownFields()$final$;\n", + "final", use_final); } if (HasFastArraySerialization(descriptor_->file(), options_)) { printer->Print( "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n" - " bool deterministic, ::google::protobuf::uint8* output) const;\n" - "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n" + " bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n" + "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n" + " const PROTOBUF_FINAL {\n" " return InternalSerializeWithCachedSizesToArray(false, output);\n" "}\n"); } } - // Check all FieldDescriptors including those in oneofs to estimate - // whether ::std::string is likely to be used, and depending on that - // estimate, set uses_string_ to true or false. That contols - // whether to force initialization of empty_string_ in SharedCtor(). - // It's often advantageous to do so to keep "is empty_string_ - // inited?" code from appearing all over the place. - vector<const FieldDescriptor*> descriptors; - for (int i = 0; i < descriptor_->field_count(); i++) { - descriptors.push_back(descriptor_->field(i)); - } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - descriptors.push_back(descriptor_->oneof_decl(i)->field(j)); - } - } - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - const Descriptor* nested_type = descriptor_->nested_type(i); - if (IsMapEntryMessage(nested_type)) { - descriptors.push_back(nested_type->FindFieldByName("key")); - descriptors.push_back(nested_type->FindFieldByName("value")); - } - } - uses_string_ = false; - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - uses_string_ = true; - } - for (int i = 0; i < descriptors.size(); i++) { - const FieldDescriptor* field = descriptors[i]; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { - switch (field->options().ctype()) { - default: uses_string_ = true; break; - } - } - } - printer->Print( - "int GetCachedSize() const { return _cached_size_; }\n" + "int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }\n" "private:\n" "void SharedCtor();\n" "void SharedDtor();\n" - "void SetCachedSize(int size) const;\n" - "void InternalSwap($classname$* other);\n" - "void UnsafeMergeFrom(const $classname$& from);\n", - "classname", classname_); + "void SetCachedSize(int size) const$final$;\n" + "void InternalSwap($classname$* other);\n", + "classname", classname_, + "final", use_final); if (SupportsArenas(descriptor_)) { printer->Print( "protected:\n" @@ -1225,7 +1219,7 @@ GenerateClassDefinition(io::Printer* printer) { "classname", classname_); } - if (UseUnknownFieldSet(descriptor_->file(), options_)) { + if (SupportsArenas(descriptor_)) { printer->Print( "private:\n" "inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n" @@ -1233,29 +1227,29 @@ GenerateClassDefinition(io::Printer* printer) { "}\n" "inline void* MaybeArenaPtr() const {\n" " return _internal_metadata_.raw_arena_ptr();\n" - "}\n" - "public:\n" - "\n"); + "}\n"); } else { printer->Print( "private:\n" "inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n" - " return _arena_ptr_;\n" - "}\n" - "inline ::google::protobuf::Arena* MaybeArenaPtr() const {\n" - " return _arena_ptr_;\n" + " return NULL;\n" "}\n" + "inline void* MaybeArenaPtr() const {\n" + " return NULL;\n" + "}\n"); + } + + printer->Print( "public:\n" "\n"); - } if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( - "::google::protobuf::Metadata GetMetadata() const;\n" + "::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;\n" "\n"); } else { printer->Print( - "::std::string GetTypeName() const;\n" + "::std::string GetTypeName() const PROTOBUF_FINAL;\n" "\n"); } @@ -1313,17 +1307,15 @@ GenerateClassDefinition(io::Printer* printer) { // messages without true field presence. if (HasFieldPresence(descriptor_->file()) || descriptor_->field(i)->containing_oneof()) { - printer->Print( - "inline void set_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); + printer->Print("void set_has_$name$();\n", "name", + FieldName(descriptor_->field(i))); } // clear_has_***() generated only for non-oneof fields // in proto1/2. if (!descriptor_->field(i)->containing_oneof() && HasFieldPresence(descriptor_->file())) { - printer->Print( - "inline void clear_has_$name$();\n", - "name", FieldName(descriptor_->field(i))); + printer->Print("void clear_has_$name$();\n", "name", + FieldName(descriptor_->field(i))); } } } @@ -1353,7 +1345,7 @@ GenerateClassDefinition(io::Printer* printer) { // TODO(kenton): Make _cached_size_ an atomic<int> when C++ supports it. const string cached_size_decl = "mutable int _cached_size_;\n"; - const size_t sizeof_has_bits = HasBitsSize(descriptor_); + const size_t sizeof_has_bits = HasBitsSize(); const string has_bits_decl = sizeof_has_bits == 0 ? "" : "::google::protobuf::internal::HasBits<" + SimpleItoa(sizeof_has_bits / 4) + "> _has_bits_;\n"; @@ -1377,9 +1369,8 @@ GenerateClassDefinition(io::Printer* printer) { "::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n"); } else { printer->Print( - "::google::protobuf::internal::ArenaStringPtr _unknown_fields_;\n" - "::google::protobuf::Arena* _arena_ptr_;\n" - "\n"); + "::google::protobuf::internal::InternalMetadataWithArenaLite " + "_internal_metadata_;\n"); } if (SupportsArenas(descriptor_)) { @@ -1404,33 +1395,12 @@ GenerateClassDefinition(io::Printer* printer) { // Field members: - // List fields which doesn't belong to any oneof - hash_map<string, int> fieldname_to_chunk; - for (int i = 0; i < descriptor_->field_count(); i++) { - if (!descriptor_->field(i)->containing_oneof()) { - const FieldDescriptor* field = descriptor_->field(i); - fieldname_to_chunk[FieldName(field)] = i / 8; - } - } - // Emit some private and static members - runs_of_fields_ = vector< vector<string> >(1); for (int i = 0; i < optimized_order_.size(); ++i) { const FieldDescriptor* field = optimized_order_[i]; const FieldGenerator& generator = field_generators_.get(field); generator.GenerateStaticMembers(printer); generator.GeneratePrivateMembers(printer); - if (CanInitializeByZeroing(field)) { - const string& fieldname = FieldName(field); - if (!runs_of_fields_.back().empty() && - (fieldname_to_chunk[runs_of_fields_.back().back()] != - fieldname_to_chunk[fieldname])) { - runs_of_fields_.push_back(vector<string>()); - } - runs_of_fields_.back().push_back(fieldname); - } else if (!runs_of_fields_.back().empty()) { - runs_of_fields_.push_back(vector<string>()); - } } // For each oneof generate a union @@ -1491,65 +1461,37 @@ GenerateClassDefinition(io::Printer* printer) { GlobalAddDescriptorsName(descriptor_->file()->name())); printer->Print( - "friend void $assigndescriptorsname$();\n" - "friend void $shutdownfilename$();\n" - "\n", - "assigndescriptorsname", - GlobalAssignDescriptorsName(descriptor_->file()->name()), - "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); - - printer->Print( - "void InitAsDefaultInstance();\n", - "classname", classname_); + "friend const ::google::protobuf::uint32* $offsetfunname$();\n" + "friend void $shutdownfilename$();\n" + "\n", + "offsetfunname", GlobalOffsetTableName(descriptor_->file()->name()), + "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); printer->Outdent(); - printer->Print("};\n"); - - // This should ideally be put into the class scope, but Visual Studio just - // refuses to compile it and complains about "use of undefined XXX": - // https://ci.appveyor.com/project/protobuf/protobuf/build/1.0.2673/job/nrdf4tb9dau0sck5 - // A program as simple as "struct X { enum { value = sizeof(X) }; };" will - // trigger the same error. - printer->Print( - "extern ::google::protobuf::internal::ExplicitlyConstructed<$classname$> " - "$classname$_default_instance_;\n", - "classname", classname_); - + printer->Print("};"); GOOGLE_DCHECK(!need_to_emit_cached_size); } void MessageGenerator:: GenerateDependentInlineMethods(io::Printer* printer) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need inline methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateInlineMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateDependentInlineMethods(printer); - printer->Print(kThinSeparator); - printer->Print("\n"); + if (IsMapEntryMessage(descriptor_)) return; + for (int i = 0; i < descriptor_->field_count(); i++) { + if (descriptor_->field(i)->options().weak()) { + field_generators_.get(descriptor_->field(i)) + .GenerateDependentInlineAccessorDefinitions(printer); + } } - GenerateDependentFieldAccessorDefinitions(printer); } void MessageGenerator:: GenerateInlineMethods(io::Printer* printer, bool is_inline) { - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need inline methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateInlineMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateInlineMethods(printer, is_inline); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - + if (IsMapEntryMessage(descriptor_)) return; GenerateFieldAccessorDefinitions(printer, is_inline); // Generate oneof_case() functions. for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["class_name"] = classname_; vars["camel_oneof_name"] = UnderscoresToCamelCase( descriptor_->oneof_decl(i)->name(), true); @@ -1565,28 +1507,10 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) { "_oneof_case_[$oneof_index$]);\n" "}\n"); } - - printer->Print( - "inline const $classname$* $classname$::internal_default_instance() {\n" - " return &$classname$_default_instance_.get();\n" - "}\n", - "classname", classname_); } void MessageGenerator:: GenerateDescriptorDeclarations(io::Printer* printer) { - if (!IsMapEntryMessage(descriptor_)) { - printer->Print( - "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n" - "const ::google::protobuf::internal::GeneratedMessageReflection*\n" - " $name$_reflection_ = NULL;\n", - "name", classname_); - } else { - printer->Print( - "const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\n", - "name", classname_); - } - // Generate oneof default instance for reflection usage. if (descriptor_->oneof_decl_count() > 0) { printer->Print("struct $name$OneofInstance {\n", @@ -1604,140 +1528,31 @@ GenerateDescriptorDeclarations(io::Printer* printer) { } } - printer->Print("}* $name$_default_oneof_instance_ = NULL;\n", - "name", classname_); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorDeclarations(printer); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - printer->Print( - "const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\n", - "name", ClassName(descriptor_->enum_type(i), false)); + printer->Print("} $name$_default_oneof_instance_;\n", "name", classname_); } } -void MessageGenerator:: -GenerateDescriptorInitializer(io::Printer* printer, int index) { - // TODO(kenton): Passing the index to this method is redundant; just use - // descriptor_->index() instead. - map<string, string> vars; - vars["classname"] = classname_; - vars["index"] = SimpleItoa(index); - - // Obtain the descriptor from the parent's descriptor. - if (descriptor_->containing_type() == NULL) { - printer->Print(vars, - "$classname$_descriptor_ = file->message_type($index$);\n"); - } else { - vars["parent"] = ClassName(descriptor_->containing_type(), false); - printer->Print(vars, - "$classname$_descriptor_ = " - "$parent$_descriptor_->nested_type($index$);\n"); - } - +void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, + int has_offset) { if (IsMapEntryMessage(descriptor_)) return; - // Generate the offsets. - GenerateOffsets(printer); + std::map<string, string> vars; - const bool pass_pool_and_factory = false; - vars["fn"] = pass_pool_and_factory ? - "new ::google::protobuf::internal::GeneratedMessageReflection" : - "::google::protobuf::internal::GeneratedMessageReflection" - "::NewGeneratedMessageReflection"; - // Construct the reflection object. - printer->Print(vars, - "$classname$_reflection_ =\n" - " $fn$(\n" - " $classname$_descriptor_,\n" - " $classname$::internal_default_instance(),\n" - " $classname$_offsets_,\n"); - if (!HasFieldPresence(descriptor_->file())) { - // If we don't have field presence, then _has_bits_ does not exist. - printer->Print(vars, - " -1,\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n"); - } - - // Unknown field offset: either points to the unknown field set if embedded - // directly, or indicates that the unknown field set is stored as part of the - // internal metadata if not. - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print(vars, - " -1,\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _unknown_fields_),\n"); - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _extensions_),\n"); - } else { - // No extensions. - printer->Print(vars, - " -1,\n"); - } - - if (descriptor_->oneof_decl_count() > 0) { - printer->Print(vars, - " $classname$_default_oneof_instance_,\n" - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _oneof_case_[0]),\n"); - } - - if (pass_pool_and_factory) { - printer->Print( - " ::google::protobuf::DescriptorPool::generated_pool(),\n"); - printer->Print(vars, - " ::google::protobuf::MessageFactory::generated_factory(),\n"); - } + vars["classname"] = classname_; + vars["offset"] = SimpleItoa(offset); + vars["has_bits_offsets"] = HasFieldPresence(descriptor_->file()) + ? SimpleItoa(offset + has_offset) + : "-1"; printer->Print(vars, - " sizeof($classname$),\n"); - - // Arena offset: either an offset to the metadata struct that contains the - // arena pointer and unknown field set (in a space-efficient way) if we use - // that implementation strategy, or an offset directly to the arena pointer if - // not (because e.g. we don't have an unknown field set). - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _internal_metadata_));\n"); - } else { - printer->Print(vars, - " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(" - "$classname$, _arena_));\n"); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDescriptorInitializer(printer, i); - } - - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateDescriptorInitializer(printer, i); - } + "{ $offset$, $has_bits_offsets$, sizeof($classname$)},\n"); } void MessageGenerator:: GenerateTypeRegistrations(io::Printer* printer) { // Register this message type with the message factory. - if (!IsMapEntryMessage(descriptor_)) { - printer->Print( - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_, " - "$classname$::internal_default_instance());\n", - "classname", classname_); - } else { - map<string, string> vars; + if (IsMapEntryMessage(descriptor_)) { + std::map<string, string> vars; CollectMapInfo(descriptor_, &vars); vars["classname"] = classname_; @@ -1750,31 +1565,27 @@ GenerateTypeRegistrations(io::Printer* printer) { vars["default_enum_value"] = "0"; } - printer->Print(vars, - "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" - " $classname$_descriptor_,\n" - " ::google::protobuf::internal::MapEntry<\n" - " $key$,\n" - " $val$,\n" - " $key_wire_type$,\n" - " $val_wire_type$,\n" - " $default_enum_value$>::CreateDefaultInstance(\n" - " $classname$_descriptor_));\n"); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateTypeRegistrations(printer); + vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); + + printer->Print( + vars, + "const ::google::protobuf::Descriptor* $classname$_descriptor = " + "file_level_metadata[$index_in_metadata$].descriptor;\n" + "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" + " $classname$_descriptor,\n" + " ::google::protobuf::internal::MapEntry<\n" + " $key$,\n" + " $val$,\n" + " $key_wire_type$,\n" + " $val_wire_type$,\n" + " $default_enum_value$>::CreateDefaultInstance(\n" + " $classname$_descriptor));\n"); } } void MessageGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) { - // Force initialization of primitive values we depend on. - printer->Print( - StrCat( - uses_string_ ? "::google::protobuf::internal::GetEmptyString();\n" : "") - .c_str()); + if (IsMapEntryMessage(descriptor_)) return; // Construct the default instances of all fields, as they will be used // when creating the default instance of the entire message. @@ -1783,64 +1594,60 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) { .GenerateDefaultInstanceAllocator(printer); } - if (IsMapEntryMessage(descriptor_)) return; - // Construct the default instance. We can't call InitAsDefaultInstance() yet // because we need to make sure all default instances that this one might // depend on are constructed first. - printer->Print("$classname$_default_instance_.DefaultConstruct();\n", + printer->Print("_$classname$_default_instance_.DefaultConstruct();\n", "classname", classname_); - - if ((descriptor_->oneof_decl_count() > 0) && - HasDescriptorMethods(descriptor_->file(), options_)) { - printer->Print( - "$classname$_default_oneof_instance_ = new $classname$OneofInstance();\n", - "classname", classname_); - } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - nested_generators_[i]->GenerateDefaultInstanceAllocator(printer); - } - } void MessageGenerator:: GenerateDefaultInstanceInitializer(io::Printer* printer) { - printer->Print( - "$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();" - "\n", - "classname", classname_); + if (IsMapEntryMessage(descriptor_)) return; - // Register extensions. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateRegistration(printer); - } + // The default instance needs all of its embedded message pointers + // cross-linked to other default instances. We can't do this initialization + // in the constructor because some other default instances may not have been + // constructed yet at that time. + // TODO(kenton): Maybe all message fields (even for non-default messages) + // should be initialized to point at default instances rather than NULL? + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need to initialize default instance manually. - // Since map entry message cannot be a top level class, we just need to - // avoid calling DefaultInstanceInitializer here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateDefaultInstanceInitializer(printer); + if (!field->is_repeated() && + field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + (field->containing_oneof() == NULL || + HasDescriptorMethods(descriptor_->file(), options_))) { + string name; + if (field->containing_oneof()) { + name = classname_ + "_default_oneof_instance_."; + } else { + name = "_" + classname_ + "_default_instance_.get_mutable()->"; + } + name += FieldName(field); + printer->Print( + "$name$_ = const_cast< $type$*>(\n" + " $type$::internal_default_instance());\n", + // Vars. + "name", name, "type", FieldMessageTypeName(field)); + } else if (field->containing_oneof() && + HasDescriptorMethods(descriptor_->file(), options_)) { + field_generators_.get(descriptor_->field(i)) + .GenerateConstructorCode(printer); + } } } void MessageGenerator:: GenerateShutdownCode(io::Printer* printer) { - printer->Print( - "$classname$_default_instance_.Shutdown();\n", - "classname", classname_); + if (IsMapEntryMessage(descriptor_)) return; + + printer->Print("_$classname$_default_instance_.Shutdown();\n", "classname", + classname_); + if (HasDescriptorMethods(descriptor_->file(), options_)) { - if (descriptor_->oneof_decl_count() > 0) { - printer->Print( - "delete $classname$_default_oneof_instance_;\n", - "classname", classname_); - } - printer->Print( - "delete $classname$_reflection_;\n", - "classname", classname_); + printer->Print("delete file_level_metadata[$index$].reflection;\n", "index", + SimpleItoa(index_in_metadata_)); } // Handle default instances of fields. @@ -1848,16 +1655,12 @@ GenerateShutdownCode(io::Printer* printer) { field_generators_.get(descriptor_->field(i)) .GenerateShutdownCode(printer); } - - // Handle nested types. - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateShutdownCode(printer); - } } void MessageGenerator:: GenerateClassMethods(io::Printer* printer) { + if (IsMapEntryMessage(descriptor_)) return; + // mutable_unknown_fields wrapper function for LazyStringOutputStream // callback. if (PreserveUnknownFields(descriptor_) && @@ -1888,21 +1691,6 @@ GenerateClassMethods(io::Printer* printer) { "classname", classname_); } - for (int i = 0; i < descriptor_->enum_type_count(); i++) { - enum_generators_[i]->GenerateMethods(printer); - } - - for (int i = 0; i < descriptor_->nested_type_count(); i++) { - // map entry message doesn't need class methods. Since map entry message - // cannot be a top level class, we just need to avoid calling - // GenerateClassMethods here. - if (IsMapEntryMessage(descriptor_->nested_type(i))) continue; - nested_generators_[i]->GenerateClassMethods(printer); - printer->Print("\n"); - printer->Print(kThinSeparator); - printer->Print("\n"); - } - // Generate non-inline field definitions. for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) @@ -1922,11 +1710,6 @@ GenerateClassMethods(io::Printer* printer) { "#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n" "\n"); - // Define extension identifiers. - for (int i = 0; i < descriptor_->extension_count(); i++) { - extension_generators_[i]->GenerateDefinition(printer); - } - GenerateStructors(printer); printer->Print("\n"); @@ -1961,12 +1744,6 @@ GenerateClassMethods(io::Printer* printer) { GenerateIsInitialized(printer); printer->Print("\n"); - } else { - printer->Print( - "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" - " MergeFrom(from);\n" - "}\n", - "classname", classname_); } GenerateSwap(printer); @@ -1974,15 +1751,12 @@ GenerateClassMethods(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( - "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" - " protobuf_AssignDescriptorsOnce();\n" - " ::google::protobuf::Metadata metadata;\n" - " metadata.descriptor = $classname$_descriptor_;\n" - " metadata.reflection = $classname$_reflection_;\n" - " return metadata;\n" - "}\n" - "\n", - "classname", classname_); + "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_metadata[$index$];\n" + "}\n" + "\n", + "classname", classname_, "index", SimpleItoa(index_in_metadata_)); } else { printer->Print( "::std::string $classname$::GetTypeName() const {\n" @@ -1995,22 +1769,49 @@ GenerateClassMethods(io::Printer* printer) { } -void MessageGenerator:: -GenerateOffsets(io::Printer* printer) { - printer->Print("static const int $classname$_offsets_[$field_count$] = {\n", - "classname", classname_, "field_count", - SimpleItoa(std::max(1, descriptor_->field_count() + - descriptor_->oneof_decl_count()))); - printer->Indent(); +std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( + io::Printer* printer) { + if (IsMapEntryMessage(descriptor_)) return std::make_pair(0, 0); + std::map<string, string> variables; + variables["classname"] = classname_; + if (HasFieldPresence(descriptor_->file())) { + printer->Print( + variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n"); + } else { + printer->Print("~0u, // no _has_bits_\n"); + } + printer->Print(variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_internal_metadata_),\n"); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _extensions_),\n"); + } else { + printer->Print("~0u, // no _extensions_\n"); + } + if (descriptor_->oneof_decl_count() > 0) { + printer->Print(variables, + "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " + "_oneof_case_[0]),\n"); + } else { + printer->Print("~0u, // no _oneof_case_\n"); + } + + const int kNumGenericOffsets = 4; // the number of fixed offsets above + const size_t offsets = kNumGenericOffsets + + descriptor_->field_count() + + descriptor_->oneof_decl_count(); + size_t entries = offsets; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->containing_oneof()) { printer->Print( "PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(" - "$classname$_default_oneof_instance_, $name$_),\n", - "classname", classname_, - "name", FieldName(field)); + "(&$classname$_default_oneof_instance_), $name$_),\n", + "classname", classname_, "name", FieldName(field)); } else { printer->Print( "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, " @@ -2028,8 +1829,14 @@ GenerateOffsets(io::Printer* printer) { "name", oneof->name()); } - printer->Outdent(); - printer->Print("};\n"); + if (HasFieldPresence(descriptor_->file())) { + entries += has_bit_indices_.size(); + for (int i = 0; i < has_bit_indices_.size(); i++) { + printer->Print("$index$,\n", "index", SimpleItoa(has_bit_indices_[i])); + } + } + + return std::make_pair(entries, offsets); } void MessageGenerator:: @@ -2043,66 +1850,26 @@ GenerateSharedConstructorCode(io::Printer* printer) { // 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(descriptor_) % 8) != 0) { + (HasBitsSize() % 8) != 0) { printer->Print("_cached_size_ = 0;\n"); need_to_clear_cached_size = false; } - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "_unknown_fields_.UnsafeSetDefault(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - - const FieldDescriptor* last_start = NULL; - // RunMap maps from fields that start each run to the number of fields in that - // run. This is optimized for the common case that there are very few runs in - // a message and that most of the eligible fields appear together. - typedef hash_map<const FieldDescriptor*, size_t> RunMap; - RunMap runs; - - for (int i = 0; i < optimized_order_.size(); ++i) { - const FieldDescriptor* field = optimized_order_[i]; - // TODO(ckennelly): Scalar messages (raw pointers) can be initialized by - // zero as well. - if (CanInitializeByZeroing(field)) { - if (last_start == NULL) { - last_start = field; - } - - runs[last_start]++; - } else { - last_start = NULL; - } - } - - for (int i = 0; i < optimized_order_.size(); ++i) { - const FieldDescriptor* field = optimized_order_[i]; - RunMap::const_iterator it = runs.find(field); - - // We only apply the memset technique to runs of more than one field, as - // assignment is better than memset for generated code clarity. - if (it != runs.end() && it->second > 1) { - // Use a memset, then skip run_length fields. - const size_t run_length = it->second; - const string first_field_name = FieldName(field); - const string last_field_name = - FieldName(optimized_order_[i + run_length - 1]); - + // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer?? + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + if (HasDescriptorMethods(descriptor_->file(), options_) && + IsMapEntryMessage(descriptor_->nested_type(i))) { printer->Print( - "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n", - "first", first_field_name, - "last", last_field_name); - - i += run_length - 1; - // ++i at the top of the loop. - } else { - field_generators_.get(field).GenerateConstructorCode(printer); + "const ::google::protobuf::Descriptor*& $type$_descriptor = " + "file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_)); } } + std::vector<bool> processed(optimized_order_.size(), false); + GenerateConstructorBody(printer, processed, false); + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { printer->Print( "clear_has_$oneof_name$();\n", @@ -2133,21 +1900,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "\n"); } - // Write the desctructor for _unknown_fields_ in lite runtime. - if (PreserveUnknownFields(descriptor_) && - !UseUnknownFieldSet(descriptor_->file(), options_)) { - if (SupportsArenas(descriptor_)) { - printer->Print( - "_unknown_fields_.Destroy(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " arena);\n"); - } else { - printer->Print( - "_unknown_fields_.DestroyNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - } - // Write the destructors for each field except oneof members. // optimized_order_ does not contain oneof fields. for (int i = 0; i < optimized_order_.size(); i++) { @@ -2164,35 +1916,6 @@ GenerateSharedDestructorCode(io::Printer* printer) { "oneof_name", descriptor_->oneof_decl(i)->name()); } - // We need to delete all embedded messages. - // TODO(kenton): If we make unset messages point at default instances - // instead of NULL, then it would make sense to move this code into - // MessageFieldGenerator::GenerateDestructorCode(). - bool need_delete_message_field = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - // Skip oneof members - if (!field->containing_oneof()) { - if (!need_delete_message_field) { - need_delete_message_field = true; - printer->Print( - "if (this != &$classname$_default_instance_.get()) {\n", - "classname", classname_); - printer->Indent(); - } - printer->Print("delete $name$_;\n", "name", FieldName(field)); - } - } - } - if (need_delete_message_field) { - printer->Outdent(); - printer->Print( - "}\n"); - } - printer->Outdent(); printer->Print( "}\n" @@ -2219,12 +1942,31 @@ GenerateArenaDestructorCode(io::Printer* printer) { "classname", classname_); bool need_registration = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - if (field_generators_.get(descriptor_->field(i)) + // Process non-oneof fields first. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (field_generators_.get(field) .GenerateArenaDestructorCode(printer)) { need_registration = true; } } + + // Process oneof fields. + // + // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything + // and returns false for oneof fields. + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + if (field_generators_.get(field) + .GenerateArenaDestructorCode(printer)) { + need_registration = true; + } + } + } + printer->Outdent(); printer->Print( "}\n"); @@ -2245,6 +1987,75 @@ GenerateArenaDestructorCode(io::Printer* printer) { } } +void MessageGenerator::GenerateConstructorBody(io::Printer* printer, + std::vector<bool> processed, + bool copy_constructor) const { + const FieldDescriptor* last_start = NULL; + // RunMap maps from fields that start each run to the number of fields in that + // run. This is optimized for the common case that there are very few runs in + // a message and that most of the eligible fields appear together. + typedef hash_map<const FieldDescriptor*, size_t> RunMap; + RunMap runs; + + for (int i = 0; i < optimized_order_.size(); ++i) { + const FieldDescriptor* field = optimized_order_[i]; + if ((copy_constructor && IsPOD(field)) || + (!copy_constructor && CanConstructByZeroing(field, options_))) { + if (last_start == NULL) { + last_start = field; + } + + runs[last_start]++; + } else { + last_start = NULL; + } + } + + string pod_template; + if (copy_constructor) { + pod_template = + "::memcpy(&$first$_, &from.$first$_,\n" + " reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + } else { + pod_template = + "::memset(&$first$_, 0, reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_) + sizeof($last$_));\n"; + } + + for (int i = 0; i < optimized_order_.size(); ++i) { + if (processed[i]) { + continue; + } + + const FieldDescriptor* field = optimized_order_[i]; + RunMap::const_iterator it = runs.find(field); + + // We only apply the memset technique to runs of more than one field, as + // assignment is better than memset for generated code clarity. + if (it != runs.end() && it->second > 1) { + // Use a memset, then skip run_length fields. + const size_t run_length = it->second; + const string first_field_name = FieldName(field); + const string last_field_name = + FieldName(optimized_order_[i + run_length - 1]); + + printer->Print(pod_template.c_str(), + "first", first_field_name, + "last", last_field_name); + + i += run_length - 1; + // ++i at the top of the loop. + } else { + if (copy_constructor) { + field_generators_.get(field).GenerateCopyConstructorCode(printer); + } else { + field_generators_.get(field).GenerateConstructorCode(printer); + } + } + } +} + void MessageGenerator:: GenerateStructors(io::Printer* printer) { string superclass; @@ -2260,11 +2071,7 @@ GenerateStructors(io::Printer* printer) { initializer_with_arena += ",\n _extensions_(arena)"; } - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - initializer_with_arena += ",\n _internal_metadata_(arena)"; - } else { - initializer_with_arena += ",\n _arena_ptr_(arena)"; - } + initializer_with_arena += ",\n _internal_metadata_(arena)"; // Initialize member variables with arena constructor. for (int i = 0; i < optimized_order_.size(); i++) { @@ -2282,8 +2089,7 @@ GenerateStructors(io::Printer* printer) { } string initializer_null; - initializer_null = (UseUnknownFieldSet(descriptor_->file(), options_) ? - ", _internal_metadata_(NULL)" : ", _arena_ptr_(NULL)"); + initializer_null = ", _internal_metadata_(NULL)"; if (IsAnyMessage(descriptor_)) { initializer_null += ", _any_metadata_(&type_url_, &value_)"; } @@ -2291,7 +2097,9 @@ GenerateStructors(io::Printer* printer) { printer->Print( "$classname$::$classname$()\n" " : $superclass$()$initializer$ {\n" - " if (this != internal_default_instance()) $initdefaultsname$();\n" + " if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n" + " $initdefaultsname$();\n" + " }\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", @@ -2318,44 +2126,6 @@ GenerateStructors(io::Printer* printer) { GlobalInitDefaultsName(descriptor_->file()->name())); } - printer->Print( - "\n" - "void $classname$::InitAsDefaultInstance() {\n", - "classname", classname_); - - // The default instance needs all of its embedded message pointers - // cross-linked to other default instances. We can't do this initialization - // in the constructor because some other default instances may not have been - // constructed yet at that time. - // TODO(kenton): Maybe all message fields (even for non-default messages) - // should be initialized to point at default instances rather than NULL? - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && - field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - (field->containing_oneof() == NULL || - HasDescriptorMethods(descriptor_->file(), options_))) { - string name; - if (field->containing_oneof()) { - name = classname_ + "_default_oneof_instance_->"; - } - name += FieldName(field); - printer->Print( - " $name$_ = const_cast< $type$*>(\n" - " $type$::internal_default_instance());\n", - // Vars. - "name", name, "type", FieldMessageTypeName(field)); - } else if (field->containing_oneof() && - HasDescriptorMethods(descriptor_->file(), options_)) { - field_generators_.get(descriptor_->field(i)) - .GenerateConstructorCode(printer); - } - } - printer->Print( - "}\n" - "\n"); - // Generate the copy constructor. printer->Print( "$classname$::$classname$(const $classname$& from)\n" @@ -2363,24 +2133,113 @@ GenerateStructors(io::Printer* printer) { "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name()); - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - ",\n _internal_metadata_(NULL)"); - } else if (!UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print(",\n _arena_ptr_(NULL)"); + printer->Indent(); + printer->Indent(); + printer->Indent(); + + printer->Print( + ",\n_internal_metadata_(NULL)"); + + 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; } + + 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; + } + + 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 (IsAnyMessage(descriptor_)) { - printer->Print(",\n _any_metadata_(&type_url_, &value_)"); + printer->Print(",\n_any_metadata_(&type_url_, &value_)"); } + + printer->Outdent(); + printer->Outdent(); printer->Print(" {\n"); + + printer->Print( + "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + + if (descriptor_->extension_range_count() > 0) { + printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); + } + + // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer?? + for (int i = 0; i < descriptor_->nested_type_count(); i++) { + if (HasDescriptorMethods(descriptor_->file(), options_) && + IsMapEntryMessage(descriptor_->nested_type(i))) { + printer->Print( + "const ::google::protobuf::Descriptor*& $type$_descriptor = " + "file_level_metadata[$index$].descriptor;\n", + "type", ClassName(descriptor_->nested_type(i), false), "index", + SimpleItoa(nested_generators_[i]->index_in_metadata_)); + } + } + + 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); + 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( + "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->Outdent(); printer->Print( - " SharedCtor();\n" - " UnsafeMergeFrom(from);\n" " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" "}\n" "\n", - "classname", classname_, - "superclass", superclass, "full_name", descriptor_->full_name()); // Generate the shared constructor code. @@ -2419,28 +2278,20 @@ GenerateStructors(io::Printer* printer) { printer->Print( "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" + " return file_level_metadata[$index$].descriptor;\n" "}\n" "\n", - "classname", classname_, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); + "index", SimpleItoa(index_in_metadata_), "classname", classname_); } printer->Print( "const $classname$& $classname$::default_instance() {\n" " $initdefaultsname$();\n" " return *internal_default_instance();\n" - "}\n", + "}\n\n", "classname", classname_, "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); - printer->Print( - "\n" - "::google::protobuf::internal::ExplicitlyConstructed<$classname$> " - "$classname$_default_instance_;\n" - "\n", - "classname", classname_); - if (SupportsArenas(descriptor_)) { printer->Print( "$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\n" @@ -2484,154 +2335,173 @@ GenerateClear(io::Printer* printer) { printer->Print("_extensions_.Clear();\n"); } - // Step 2: Everything but extensions, repeateds, unions. - // These are handled in chunks of 8. The first chunk is - // the non-extensions-non-repeateds-non-unions in - // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), - // and the second chunk is the same for - // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15), - // etc. - set<int> step2_indices; - hash_map<string, int> fieldname_to_chunk; - hash_map<int, string> memsets_for_chunk; - hash_map<int, int> memset_field_count_for_chunk; - hash_set<string> handled; // fields that appear anywhere in memsets_for_chunk - hash_map<int, uint32> fields_mask_for_chunk; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_repeated() && !field->containing_oneof()) { - step2_indices.insert(i); - int chunk = i / 8; - fieldname_to_chunk[FieldName(field)] = chunk; - fields_mask_for_chunk[chunk] |= static_cast<uint32>(1) << (i % 32); - } - } - - // Step 2a: Greedily seek runs of fields that can be cleared by memset-to-0. - // The generated code uses two macros to help it clear runs of fields: - // ZR_HELPER_(f1) - ZR_HELPER_(f0) computes the difference, in bytes, of the - // positions of two fields in the Message. - // ZR_ zeroes a non-empty range of fields via memset. - const char* macros = - "#if defined(__clang__)\n" - "#define ZR_HELPER_(f) \\\n" - " _Pragma(\"clang diagnostic push\") \\\n" - " _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n" - " __builtin_offsetof($classname$, f) \\\n" - " _Pragma(\"clang diagnostic pop\")\n" - "#else\n" - "#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n" - " &reinterpret_cast<$classname$*>(16)->f)\n" - "#endif\n\n" - "#define ZR_(first, last) do {\\\n" - " ::memset(&(first), 0,\\\n" - " ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n" - "} while (0)\n\n"; - for (int i = 0; i < runs_of_fields_.size(); i++) { - const vector<string>& run = runs_of_fields_[i]; - if (run.size() < 2) continue; - const string& first_field_name = run[0]; - const string& last_field_name = run.back(); - int chunk = fieldname_to_chunk[run[0]]; - memsets_for_chunk[chunk].append( - "ZR_(" + first_field_name + "_, " + last_field_name + "_);\n"); - for (int j = 0; j < run.size(); j++) { - GOOGLE_DCHECK_EQ(chunk, fieldname_to_chunk[run[j]]); - handled.insert(run[j]); - } - memset_field_count_for_chunk[chunk] += run.size(); - } - const bool macros_are_needed = handled.size() > 0; - if (macros_are_needed) { - printer->Outdent(); - printer->Print(macros, - "classname", classname_); - printer->Indent(); - } - // Step 2b: Finish step 2, ignoring fields handled in step 2a. - int last_index = -1; - bool chunk_block_in_progress = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - if (step2_indices.count(i) == 0) continue; - const FieldDescriptor* field = descriptor_->field(i); - const string fieldname = FieldName(field); - if (i / 8 != last_index / 8 || last_index < 0) { - // End previous chunk, if there was one. - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - chunk_block_in_progress = false; + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // 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 (!field->is_repeated()) { + break; } - // Start chunk. - const string& memsets = memsets_for_chunk[i / 8]; - uint32 mask = fields_mask_for_chunk[i / 8]; - int count = popcnt(mask); - GOOGLE_DCHECK_GE(count, 1); - if (count == 1 || - count == memset_field_count_for_chunk[i / 8]) { - // No "if" here because the chunk is trivial. + + if (use_dependent_base_ && IsFieldDependent(field)) { + printer->Print("clear_$name$();\n", "name", FieldName(field)); } else { - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(i / 8 * 8), - "mask", SimpleItoa(mask)); - printer->Indent(); - chunk_block_in_progress = true; - } + generator.GenerateMessageClearingCode(printer); } - printer->Print(memsets.c_str()); - } - last_index = i; - if (handled.count(fieldname) > 0) continue; - - // 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())) { - printer->Print("if (has_$name$()) {\n", "name", fieldname); - printer->Indent(); - have_enclosing_if = true; } - if (use_dependent_base_ && IsFieldDependent(field)) { - printer->Print("clear_$name$();\n", "name", fieldname); - } else { - field_generators_.get(field).GenerateClearingCode(printer); + // 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; + + 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; + } + + memset_run_end = i; + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); } - if (have_enclosing_if) { - printer->Outdent(); - printer->Print("}\n"); + // 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; + } + + // "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; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); } - } - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - } - if (macros_are_needed) { - printer->Outdent(); - printer->Print("\n#undef ZR_HELPER_\n#undef ZR_\n\n"); - printer->Indent(); - } + 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); - // Step 3: Repeated fields don't use _has_bits_; emit code to clear them here. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + const int count = popcnt(last_chunk_mask); + const bool have_outer_if = HasFieldPresence(descriptor_->file()) && + (last_chunk_start != last_chunk_end); - if (field->is_repeated()) { - if (use_dependent_base_ && IsFieldDependent(field)) { - printer->Print("clear_$name$();\n", "name", FieldName(field)); - } else { - field_generators_.get(field).GenerateClearingCode(printer); + 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); + + printer->Print( + "if (_has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "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, 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; + } + + // 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); + + // 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())) { + printer->Print("if (has_$name$()) {\n", "name", fieldname); + printer->Indent(); + have_enclosing_if = true; + } + + generator.GenerateMessageClearingCode(printer); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print("}\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); } } } @@ -2649,23 +2519,7 @@ GenerateClear(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " mutable_unknown_fields()->Clear();\n" - "}\n"); - } else { - if (SupportsArenas(descriptor_)) { - printer->Print( - "_unknown_fields_.ClearToEmpty(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n" - " GetArenaNoVirtual());\n"); - } else { - printer->Print( - "_unknown_fields_.ClearToEmptyNoArena(\n" - " &::google::protobuf::internal::GetEmptyStringAlreadyInited());\n"); - } - } + printer->Print("_internal_metadata_.Clear();\n"); } printer->Outdent(); @@ -2676,7 +2530,7 @@ void MessageGenerator:: GenerateOneofClear(io::Printer* printer) { // Generated function clears the active field and union case (e.g. foo_case_). for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - map<string, string> oneof_vars; + std::map<string, string> oneof_vars; oneof_vars["classname"] = classname_; oneof_vars["oneofname"] = descriptor_->oneof_decl(i)->name(); oneof_vars["full_name"] = descriptor_->full_name(); @@ -2742,10 +2596,13 @@ GenerateSwap(io::Printer* printer) { " if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n" " InternalSwap(other);\n" " } else {\n" - " $classname$ temp;\n" - " temp.UnsafeMergeFrom(*this);\n" - " CopyFrom(*other);\n" - " other->CopyFrom(temp);\n" + " $classname$* temp = New(GetArenaNoVirtual());\n" + " temp->MergeFrom(*other);\n" + " other->CopyFrom(*this);\n" + " InternalSwap(temp);\n" + " if (GetArenaNoVirtual() == NULL) {\n" + " delete temp;\n" + " }\n" " }\n" "}\n" "void $classname$::UnsafeArenaSwap($classname$* other) {\n" @@ -2769,8 +2626,10 @@ GenerateSwap(io::Printer* printer) { printer->Indent(); if (HasGeneratedMethods(descriptor_->file(), options_)) { - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + // optimized_order_ does not contain oneof fields, but the field + // generators for these fields do not emit swapping code on their own. + const FieldDescriptor* field = optimized_order_[i]; field_generators_.get(field).GenerateSwappingCode(printer); } @@ -2789,13 +2648,8 @@ GenerateSwap(io::Printer* printer) { } } - // Ignore PreserveUnknownFields here - always swap internal_metadata as it - // may contain more than just unknown fields. - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "_internal_metadata_.Swap(&other->_internal_metadata_);\n"); - } else { - printer->Print("_unknown_fields_.Swap(&other->_unknown_fields_);\n"); + if (PreserveUnknownFields(descriptor_)) { + printer->Print("_internal_metadata_.Swap(&other->_internal_metadata_);\n"); } printer->Print("std::swap(_cached_size_, other->_cached_size_);\n"); @@ -2819,7 +2673,7 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\n" "// @@protoc_insertion_point(generalized_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);\n", + " GOOGLE_DCHECK_NE(&from, this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); @@ -2838,7 +2692,7 @@ GenerateMergeFrom(io::Printer* printer) { "} else {\n" "// @@protoc_insertion_point(generalized_merge_from_cast_success:" "$full_name$)\n" - " UnsafeMergeFrom(*source);\n" + " MergeFrom(*source);\n" "}\n", "classname", classname_, "full_name", descriptor_->full_name()); @@ -2860,25 +2714,118 @@ GenerateMergeFrom(io::Printer* printer) { "void $classname$::MergeFrom(const $classname$& from) {\n" "// @@protoc_insertion_point(class_specific_merge_from_start:" "$full_name$)\n" - " if (GOOGLE_PREDICT_TRUE(&from != this)) {\n" - " UnsafeMergeFrom(from);\n" - " } else {\n" - " MergeFromFail(__LINE__);\n" - " }\n" - "}\n" - "\n" - "void $classname$::UnsafeMergeFrom(const $classname$& from) {\n" - " GOOGLE_DCHECK(&from != this);\n", + " GOOGLE_DCHECK_NE(&from, this);\n", "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); - // Merge Repeated fields. These fields do not require a - // check as we can simply iterate over them. - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); + if (descriptor_->extension_range_count() > 0) { + printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); + } - if (field->is_repeated()) { - field_generators_.get(field).GenerateUnsafeMergingCode(printer); + printer->Print( + "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"); + + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // Merge Repeated fields. These fields do not require a + // check as we can simply iterate over them. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (!field->is_repeated()) { + break; + } + + const FieldGenerator& generator = field_generators_.get(field); + generator.GenerateMergingCode(printer); + } + + // Merge Optional and Required fields (after a _has_bit check). + 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()) { + 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; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); + } + + 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); + + 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); + + printer->Print( + "if (from._has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "mask", SimpleItoa(last_chunk_mask)); + printer->Indent(); + } + + // 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 FieldGenerator& generator = field_generators_.get(field); + + bool have_enclosing_if = false; + if (HasFieldPresence(descriptor_->file())) { + printer->Print( + "if (from.has_$name$()) {\n", + "name", FieldName(field)); + printer->Indent(); + have_enclosing_if = true; + } else { + // Merge semantics without true field presence: primitive fields are + // merged only if non-zero (numeric) or non-empty (string). + have_enclosing_if = EmitFieldNonDefaultCondition( + printer, "from.", field); + } + + generator.GenerateMergingCode(printer); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print("}\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); + } } } @@ -2912,78 +2859,6 @@ GenerateMergeFrom(io::Printer* printer) { "}\n"); } - // Merge Optional and Required fields (after a _has_bit check). - int last_index = -1; - - for (int i = 0; i < descriptor_->field_count(); ++i) { - const FieldDescriptor* field = descriptor_->field(i); - - if (!field->is_repeated() && !field->containing_oneof()) { - if (HasFieldPresence(descriptor_->file())) { - // See above in GenerateClear for an explanation of this. - if (i / 8 != last_index / 8 || last_index < 0) { - if (last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - printer->Print( - "if (from._has_bits_[$index$ / 32] & " - "(0xffu << ($index$ % 32))) {\n", - "index", SimpleItoa(field->index())); - printer->Indent(); - } - } - - last_index = i; - - bool have_enclosing_if = false; - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (from.has_$name$()) {\n", - "name", FieldName(field)); - printer->Indent(); - have_enclosing_if = true; - } else { - // Merge semantics without true field presence: primitive fields are - // merged only if non-zero (numeric) or non-empty (string). - have_enclosing_if = EmitFieldNonDefaultCondition( - printer, "from.", field); - } - - field_generators_.get(field).GenerateMergingCode(printer); - - if (have_enclosing_if) { - printer->Outdent(); - printer->Print("}\n"); - } - } - } - - if (HasFieldPresence(descriptor_->file()) && - last_index >= 0) { - printer->Outdent(); - printer->Print("}\n"); - } - - if (descriptor_->extension_range_count() > 0) { - printer->Print("_extensions_.MergeFrom(from._extensions_);\n"); - } - - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (from._internal_metadata_.have_unknown_fields()) {\n" - " ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(\n" - " from.unknown_fields(), &_internal_metadata_);\n" - "}\n"); - } else { - printer->Print( - "if (!from.unknown_fields().empty()) {\n" - " mutable_unknown_fields()->append(from.unknown_fields());\n" - "}\n"); - } - } - printer->Outdent(); printer->Print("}\n"); } @@ -3020,7 +2895,7 @@ GenerateCopyFrom(io::Printer* printer) { printer->Print( "if (&from == this) return;\n" "Clear();\n" - "UnsafeMergeFrom(from);\n"); + "MergeFrom(from);\n"); printer->Outdent(); printer->Print("}\n"); @@ -3061,7 +2936,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // on the CodedOutputStream. printer->Print( " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n" - " ::google::protobuf::NewPermanentCallback(\n" + " NewPermanentCallback(\n" " &MutableUnknownFieldsFor$classname$, this));\n" " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" " &unknown_fields_string, false);\n", @@ -3082,13 +2957,41 @@ GenerateMergeFromCodedStream(io::Printer* printer) { WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]); const int kCutoff0 = 127; // fits in 1-byte varint const int kCutoff1 = (127 << 7) + 127; // fits in 2-byte varint + + // We need to capture the last tag when parsing if this is a Group type, as + // our caller will verify (via CodedInputStream::LastTagWas) that the correct + // closing tag was received. + bool capture_last_tag = false; + const Descriptor* parent = descriptor_->containing_type(); + if (parent) { + for (int i = 0; i < parent->field_count(); i++) { + const FieldDescriptor* field = parent->field(i); + if (field->type() == FieldDescriptor::TYPE_GROUP && + field->message_type() == descriptor_) { + capture_last_tag = true; + break; + } + } + } + + for (int i = 0; i < descriptor_->file()->extension_count(); i++) { + const FieldDescriptor* field = descriptor_->file()->extension(i); + if (field->type() == FieldDescriptor::TYPE_GROUP && + field->message_type() == descriptor_) { + capture_last_tag = true; + break; + } + } + printer->Print("::std::pair< ::google::protobuf::uint32, bool> p = " - "input->ReadTagWithCutoff($max$);\n" + "input->ReadTagWithCutoff$lasttag$($max$u);\n" "tag = p.first;\n" "if (!p.second) goto handle_unusual;\n", "max", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 : (maxtag <= kCutoff1 ? kCutoff1 : - maxtag))); + maxtag)), + "lasttag", !capture_last_tag ? "NoLastTag" : ""); + if (descriptor_->field_count() > 0) { // We don't even want to print the switch() if we have no fields because // MSVC dislikes switch() statements that contain only a default value. @@ -3098,6 +3001,13 @@ GenerateMergeFromCodedStream(io::Printer* printer) { // of each case. However, this is actually a bit slower in practice as it // creates a jump table that is 8x larger and sparser, and meanwhile the // if()s are highly predictable. + // + // Historically, we inserted checks to peek at the next tag on the wire and + // jump directly to the next case statement. While this avoids the jump + // table that the switch uses, it greatly increases code size (20-60%) and + // inserts branches that may fail (especially for real world protos that + // interleave--in field number order--hot and cold fields). Loadtests + // confirmed that removing this optimization is performance neutral. printer->Print("switch (::google::protobuf::internal::WireFormatLite::" "GetTagFieldNumber(tag)) {\n"); @@ -3114,19 +3024,9 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } } - // need_label is true if we generated "goto parse_$name$" while handling the - // previous field. - bool need_label = false; - // Pay attention to whether we are in a run of fields from the same oneof. - // Motivation: it would be unusual to parse multiple values for a single - // oneof, since only the last would be used. - const FieldDescriptor* last_of_current_oneof = NULL; - // The following is valid iff last_of_current_oneof is non-NULL. - int index_of_last_of_current_oneof = -1; for (int i = 0; i < ordered_fields.size(); i++) { const FieldDescriptor* field = ordered_fields[i]; const bool loops = fields_with_parse_loop.count(i) > 0; - const bool next_field_loops = fields_with_parse_loop.count(i + 1) > 0; PrintFieldComment(printer, field); @@ -3137,20 +3037,11 @@ GenerateMergeFromCodedStream(io::Printer* printer) { const FieldGenerator& field_generator = field_generators_.get(field); // Emit code to parse the common, expected case. - printer->Print("if (tag == $commontag$) {\n", + printer->Print("if (tag == $commontag$u) {\n", "commontag", SimpleItoa(WireFormat::MakeTag(field))); - if (need_label || - (field->is_repeated() && !field->is_packed() && !loops)) { - printer->Print( - " parse_$name$:\n", - "name", field->name()); - } if (loops) { - printer->Print( - " DO_(input->IncrementRecursionDepth());\n" - " parse_loop_$name$:\n", - "name", field->name()); + printer->Print(" DO_(input->IncrementRecursionDepth());\n"); } printer->Indent(); @@ -3165,7 +3056,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { if (field->is_packed()) { internal::WireFormatLite::WireType wiretype = WireFormat::WireTypeForFieldType(field->type()); - printer->Print("} else if (tag == $uncommontag$) {\n", + printer->Print("} else if (tag == $uncommontag$u) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3175,7 +3066,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } else if (field->is_packable() && !field->is_packed()) { internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - printer->Print("} else if (tag == $uncommontag$) {\n", + printer->Print("} else if (tag == $uncommontag$u) {\n", "uncommontag", SimpleItoa( internal::WireFormatLite::MakeTag( field->number(), wiretype))); @@ -3189,87 +3080,10 @@ GenerateMergeFromCodedStream(io::Printer* printer) { " goto handle_unusual;\n" "}\n"); - // switch() is slow since it can't be predicted well. Insert some if()s - // here that attempt to predict the next tag. - // For non-packed repeated fields, expect the same tag again. + // For repeated messages/groups, we need to decrement recursion depth. if (loops) { printer->Print( - "if (input->ExpectTag($tag$)) goto parse_loop_$name$;\n", - "tag", SimpleItoa(WireFormat::MakeTag(field)), - "name", field->name()); - } else if (field->is_repeated() && !field->is_packed()) { - printer->Print( - "if (input->ExpectTag($tag$)) goto parse_$name$;\n", - "tag", SimpleItoa(WireFormat::MakeTag(field)), - "name", field->name()); - } - - // Have we emitted "if (input->ExpectTag($next_tag$)) ..." yet? - bool emitted_goto_next_tag = false; - - // For repeated messages/groups, we need to decrement recursion depth, - // unless the next tag is also for a repeated message/group. - if (loops) { - if (next_field_loops) { - const FieldDescriptor* next_field = ordered_fields[i + 1]; - printer->Print( - "if (input->ExpectTag($next_tag$)) goto parse_loop_$next_name$;\n", - "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), - "next_name", next_field->name()); - emitted_goto_next_tag = true; - } - printer->Print( - "input->UnsafeDecrementRecursionDepth();\n"); - } - - // If there are more fields, expect the next one, unless we just parsed - // a oneof and the next field would be from the same oneof. (There's no - // reason to expect something that makes what we just read irrelevant, - // so guess something after the current string of fields from this oneof.) - need_label = false; - if (!emitted_goto_next_tag) { - // delta is the distance in ordered_fields[] from the current field to - // the field we'll guess is next. - int delta = last_of_current_oneof == NULL - ? 1 - : std::max(index_of_last_of_current_oneof - i, 1); - if (i == index_of_last_of_current_oneof) { - printer->Outdent(); - printer->Print( - " after_$last$:\n", - "last", FieldName(last_of_current_oneof)); - printer->Indent(); - last_of_current_oneof = NULL; - } else if (last_of_current_oneof == NULL) { - delta = 1; - // Check for the unlikely case that delta > 1 is better. - if (field->containing_oneof() != NULL) { - while (i + delta < ordered_fields.size() && - ordered_fields[i + delta]->containing_oneof() == - field->containing_oneof()) { - index_of_last_of_current_oneof = i + delta; - last_of_current_oneof = ordered_fields[i + delta]; - ++delta; - } - } - } - if (delta > 1) { - printer->Print( - "goto after_$last$;\n", - "last", FieldName(last_of_current_oneof)); - } else if (i + delta == descriptor_->field_count()) { - // Expect EOF. - // TODO(kenton): Expect group end-tag? - printer->Print( - "if (input->ExpectAtEnd()) goto success;\n"); - } else { - const FieldDescriptor* next_field = ordered_fields[i + delta]; - printer->Print( - "if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\n", - "next_tag", SimpleItoa(WireFormat::MakeTag(next_field)), - "next_name", next_field->name()); - need_label = delta == 1; - } + "input->UnsafeDecrementRecursionDepth();\n"); } printer->Print( @@ -3382,7 +3196,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { } void MessageGenerator::GenerateSerializeOneofFields( - io::Printer* printer, const vector<const FieldDescriptor*>& fields, + io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, bool to_array) { GOOGLE_CHECK(!fields.empty()); if (fields.size() == 1) { @@ -3450,7 +3264,7 @@ void MessageGenerator::GenerateSerializeOneField( void MessageGenerator::GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, bool to_array) { - map<string, string> vars; + std::map<string, string> vars; vars["start"] = SimpleItoa(range->start); vars["end"] = SimpleItoa(range->end); printer->Print(vars, @@ -3600,7 +3414,7 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { io::Printer* printer_; const bool to_array_; const bool eager_; - vector<const FieldDescriptor*> v_; + std::vector<const FieldDescriptor*> v_; }; std::vector<const FieldDescriptor*> ordered_fields = @@ -3663,30 +3477,29 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) { } } -static vector<uint32> RequiredFieldsBitMask(const Descriptor* desc) { - vector<uint32> result; - uint32 mask = 0; - for (int i = 0; i < desc->field_count(); i++) { - if (i > 0 && i % 32 == 0) { - result.push_back(mask); - mask = 0; - } - if (desc->field(i)->is_required()) { - mask |= (1 << (i & 31)); +std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const { + const int array_size = HasBitsSize(); + std::vector<uint32> masks(array_size, 0); + + for (int i = 0; i < descriptor_->field_count(); i++) { + const FieldDescriptor* field = descriptor_->field(i); + if (!field->is_required()) { + continue; } + + const int has_bit_index = has_bit_indices_[field->index()]; + masks[has_bit_index / 32] |= + static_cast<uint32>(1) << (has_bit_index % 32); } - if (mask != 0) { - result.push_back(mask); - } - return result; + return masks; } // Create an expression that evaluates to // "for all i, (_has_bits_[i] & masks[i]) == masks[i]" // masks is allowed to be shorter than _has_bits_, but at least one element of // masks must be non-zero. -static string ConditionalToCheckBitmasks(const vector<uint32>& masks) { - vector<string> parts; +static string ConditionalToCheckBitmasks(const std::vector<uint32>& masks) { + std::vector<string> parts; for (int i = 0; i < masks.size(); i++) { if (masks[i] == 0) continue; string m = StrCat("0x", strings::Hex(masks[i], strings::ZERO_PAD_8)); @@ -3735,8 +3548,8 @@ GenerateByteSize(io::Printer* printer) { "classname", classname_, "full_name", descriptor_->full_name()); printer->Indent(); printer->Print("size_t total_size = 0;\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (field->is_required()) { printer->Print("\n" "if (has_$name$()) {\n", @@ -3763,18 +3576,41 @@ GenerateByteSize(io::Printer* printer) { "size_t total_size = 0;\n" "\n"); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + "total_size += _extensions_.ByteSize();\n" + "\n"); + } + + if (PreserveUnknownFields(descriptor_)) { + if (UseUnknownFieldSet(descriptor_->file(), options_)) { + printer->Print( + "if (_internal_metadata_.have_unknown_fields()) {\n" + " total_size +=\n" + " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" + " unknown_fields());\n" + "}\n"); + } else { + printer->Print( + "total_size += unknown_fields().size();\n" + "\n"); + } + } + // Handle required fields (if any). We expect all of them to be // present, so emit one conditional that checks for that. If they are all // present then the fast path executes; otherwise the slow path executes. if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) { // The fast path works if all required fields are present. - vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(descriptor_); + const std::vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(); printer->Print((string("if (") + ConditionalToCheckBitmasks(masks_for_has_bits) + ") { // All required fields are present.\n").c_str()); printer->Indent(); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + // Oneof fields cannot be required, so optimized_order_ contains all of the + // fields that we need to potentially emit. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (!field->is_required()) continue; PrintFieldComment(printer, field); field_generators_.get(field).GenerateByteSize(printer); @@ -3786,8 +3622,8 @@ GenerateByteSize(io::Printer* printer) { "}\n"); } else { // num_required_fields_ <= 1: no need to be tricky - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; if (!field->is_required()) continue; PrintFieldComment(printer, field); printer->Print("if (has_$name$()) {\n", @@ -3799,98 +3635,125 @@ GenerateByteSize(io::Printer* printer) { } } - // Handle optional fields (worry below about repeateds, oneofs, etc.). - // These are handled in chunks of 8. The first chunk is - // the non-requireds-non-repeateds-non-unions-non-extensions in - // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), - // and the second chunk is the same for - // descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15), - // etc. - hash_map<int, uint32> fields_mask_for_chunk; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_required() && !field->is_repeated() && - !field->containing_oneof()) { - fields_mask_for_chunk[i / 8] |= static_cast<uint32>(1) << (i % 32); + int last_i = -1; + for (int i = 0; i < optimized_order_.size(); ) { + // Detect infinite loops. + GOOGLE_CHECK_NE(i, last_i); + last_i = i; + + // Skip required fields. + for (; i < optimized_order_.size() && + optimized_order_[i]->is_required(); i++) { } - } - int last_index = -1; - bool chunk_block_in_progress = false; - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (!field->is_required() && !field->is_repeated() && - !field->containing_oneof()) { - // See above in GenerateClear for an explanation of this. - // TODO(kenton): Share code? Unclear how to do so without - // over-engineering. - if (i / 8 != last_index / 8 || last_index < 0) { - // End previous chunk, if there was one. - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - chunk_block_in_progress = false; - } - // Start chunk. - uint32 mask = fields_mask_for_chunk[i / 8]; - int count = popcnt(mask); - GOOGLE_DCHECK_GE(count, 1); - if (count == 1) { - // No "if" here because the chunk is trivial. - } else { - if (HasFieldPresence(descriptor_->file())) { - printer->Print( - "if (_has_bits_[$index$ / 32] & $mask$u) {\n", - "index", SimpleItoa(i), - "mask", SimpleItoa(mask)); - printer->Indent(); - chunk_block_in_progress = true; - } - } + // Handle repeated fields. + for (; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + if (!field->is_repeated()) { + break; } - last_index = i; PrintFieldComment(printer, field); + const FieldGenerator& generator = field_generators_.get(field); + generator.GenerateByteSize(printer); + printer->Print("\n"); + } - 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); + // Handle optional (non-repeated/oneof) fields. + // + // These are handled in chunks of 8. The first chunk is + // the non-requireds-non-repeateds-non-unions-non-extensions in + // descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7), + // and the second chunk is the same for + // 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; } - field_generators_.get(field).GenerateByteSize(printer); + // "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; + } + + last_chunk_end = i; + last_chunk_mask |= static_cast<uint32>(1) << (index % 32); + } + + 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); + + 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 (have_enclosing_if) { - printer->Outdent(); printer->Print( - "}\n" - "\n"); + "if (_has_bits_[$index$ / 32] & $mask$u) {\n", + "index", SimpleItoa(last_chunk * 8), + "mask", SimpleItoa(last_chunk_mask)); + printer->Indent(); } - } - } - if (chunk_block_in_progress) { - printer->Outdent(); - printer->Print("}\n"); - } + // 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); - // Repeated fields don't use _has_bits_ so we count them in a separate - // pass. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + PrintFieldComment(printer, field); - if (field->is_repeated()) { - PrintFieldComment(printer, field); - field_generators_.get(field).GenerateByteSize(printer); - printer->Print("\n"); + 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); + + if (have_enclosing_if) { + printer->Outdent(); + printer->Print( + "}\n" + "\n"); + } + } + + if (have_outer_if) { + printer->Outdent(); + printer->Print("}\n"); + } } } @@ -3926,27 +3789,6 @@ GenerateByteSize(io::Printer* printer) { "}\n"); } - if (descriptor_->extension_range_count() > 0) { - printer->Print( - "total_size += _extensions_.ByteSize();\n" - "\n"); - } - - if (PreserveUnknownFields(descriptor_)) { - if (UseUnknownFieldSet(descriptor_->file(), options_)) { - printer->Print( - "if (_internal_metadata_.have_unknown_fields()) {\n" - " total_size +=\n" - " ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n" - " unknown_fields());\n" - "}\n"); - } else { - printer->Print( - "total_size += unknown_fields().size();\n" - "\n"); - } - } - // We update _cached_size_ even though this is a const method. In theory, // this is not thread-compatible, because concurrent writes have undefined // results. In practice, since any concurrent writes will be writing the @@ -3970,35 +3812,38 @@ GenerateIsInitialized(io::Printer* printer) { "classname", classname_); printer->Indent(); + if (descriptor_->extension_range_count() > 0) { + printer->Print( + "if (!_extensions_.IsInitialized()) {\n" + " return false;\n" + "}\n\n"); + } + if (HasFieldPresence(descriptor_->file())) { // Check that all required fields in this message are set. We can do this // most efficiently by checking 32 "has bits" at a time. - int has_bits_array_size = (descriptor_->field_count() + 31) / 32; - for (int i = 0; i < has_bits_array_size; i++) { - uint32 mask = 0; - for (int bit = 0; bit < 32; bit++) { - int index = i * 32 + bit; - if (index >= descriptor_->field_count()) break; - const FieldDescriptor* field = descriptor_->field(index); - - if (field->is_required()) { - mask |= 1 << bit; - } - } + const std::vector<uint32> masks = RequiredFieldsBitMask(); - if (mask != 0) { - printer->Print( - "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n", - "i", SimpleItoa(i), - "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8))); + for (int i = 0; i < masks.size(); i++) { + uint32 mask = masks[i]; + if (mask == 0) { + continue; } + + // TODO(ckennelly): Consider doing something similar to ByteSizeLong(), + // where we check all of the required fields in a single branch (assuming + // that we aren't going to benefit from early termination). + printer->Print( + "if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\n", + "i", SimpleItoa(i), + "mask", StrCat(strings::Hex(mask, strings::ZERO_PAD_8))); } } - // Now check that all embedded messages are initialized. - printer->Print("\n"); - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); + // Now check that all non-oneof embedded messages are initialized. + for (int i = 0; i < optimized_order_.size(); i++) { + const FieldDescriptor* field = optimized_order_[i]; + // TODO(ckennelly): Push this down into a generator? if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !ShouldIgnoreRequiredFieldCheck(field, options_) && HasRequiredFields(field->message_type(), options_)) { @@ -4008,7 +3853,56 @@ GenerateIsInitialized(io::Printer* printer) { " return false;\n", "name", FieldName(field)); } else { - if (field->options().weak() || !field->containing_oneof()) { + GOOGLE_CHECK(field->options().weak() || !field->containing_oneof()); + // For weak fields, use the data member (::google::protobuf::Message*) instead + // of the getter to avoid a link dependency on the weak message type + // which is only forward declared. + printer->Print( + "if (has_$name$()) {\n" + " if (!this->$name$_->IsInitialized()) return false;\n" + "}\n", + "name", FieldName(field)); + } + } + } + + // Go through the oneof fields, emitting a switch if any might have required + // fields. + for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + + bool has_required_fields = false; + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !ShouldIgnoreRequiredFieldCheck(field, options_) && + HasRequiredFields(field->message_type(), options_)) { + has_required_fields = true; + break; + } + } + + if (!has_required_fields) { + continue; + } + + printer->Print( + "switch ($oneofname$_case()) {\n", + "oneofname", oneof->name()); + printer->Indent(); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); + printer->Print( + "case k$field_name$: {\n", + "field_name", UnderscoresToCamelCase(field->name(), true)); + printer->Indent(); + + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !ShouldIgnoreRequiredFieldCheck(field, options_) && + HasRequiredFields(field->message_type(), options_)) { + GOOGLE_CHECK(!(field->options().weak() || !field->containing_oneof())); + if (field->options().weak()) { // For weak fields, use the data member (::google::protobuf::Message*) instead // of the getter to avoid a link dependency on the weak message type // which is only forward declared. @@ -4025,15 +3919,22 @@ GenerateIsInitialized(io::Printer* printer) { "name", FieldName(field)); } } - } - } - if (descriptor_->extension_range_count() > 0) { + printer->Print( + "break;\n"); + printer->Outdent(); + printer->Print( + "}\n"); + } printer->Print( - "\n" - "if (!_extensions_.IsInitialized()) {\n" - " return false;\n" - "}\n"); + "case $cap_oneof_name$_NOT_SET: {\n" + " break;\n" + "}\n", + "cap_oneof_name", + ToUpper(oneof->name())); + printer->Outdent(); + printer->Print( + "}\n"); } printer->Outdent(); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index 3bdc0ed3..c5efff12 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -64,6 +64,12 @@ class MessageGenerator { MessageGenerator(const Descriptor* descriptor, const Options& options); ~MessageGenerator(); + // Appends the pre-order walk of the nested generators to list. + void Flatten(std::vector<MessageGenerator*>* list); + // Append the two types of nested generators to the corresponding vector. + void AddGenerators(std::vector<EnumGenerator*>* enum_generators, + std::vector<ExtensionGenerator*>* extension_generators); + // Header stuff. // Return names for forward declarations of this class and all its nested @@ -71,17 +77,7 @@ class MessageGenerator { // descriptor that was responsible for its inclusion in the map. This can be // used to associate the descriptor with the code generated for it. void FillMessageForwardDeclarations( - map<string, const Descriptor*>* class_names); - void FillEnumForwardDeclarations( - map<string, const EnumDescriptor*>* enum_names); - - // Generate definitions of all nested enums (must come before class - // definitions because those classes use the enums definitions). - void GenerateEnumDefinitions(io::Printer* printer); - - // Generate specializations of GetEnumDescriptor<MyEnum>(). - // Precondition: in ::google::protobuf namespace. - void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); + std::map<string, const Descriptor*>* class_names); // Generate definitions for this class and all its nested types. void GenerateClassDefinition(io::Printer* printer); @@ -99,10 +95,6 @@ class MessageGenerator { // will be initialized by the methods below. void GenerateDescriptorDeclarations(io::Printer* printer); - // Generate code that initializes the global variable storing the message's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() // for all types. void GenerateTypeRegistrations(io::Printer* printer); @@ -130,8 +122,10 @@ class MessageGenerator { void GenerateDependentFieldAccessorDefinitions(io::Printer* printer); void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline); - // Generate the field offsets array. - void GenerateOffsets(io::Printer* printer); + // Generate the field offsets array. Returns the a pair of the total numer + // of entries generated and the index of the first has_bit entry. + std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); + void GenerateSchema(io::Printer* printer, int offset, int has_offset); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -168,7 +162,7 @@ class MessageGenerator { // Generate a switch statement to serialize 2+ fields from the same oneof. // Or, if fields.size() == 1, just call GenerateSerializeOneField(). void GenerateSerializeOneofFields( - io::Printer* printer, const vector<const FieldDescriptor*>& fields, + io::Printer* printer, const std::vector<const FieldDescriptor*>& fields, bool to_array); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, @@ -177,19 +171,26 @@ class MessageGenerator { // Generates has_foo() functions and variables for singular field has-bits. void GenerateSingularFieldHasBits(const FieldDescriptor* field, - map<string, string> vars, + std::map<string, string> vars, io::Printer* printer); // Generates has_foo() functions and variables for oneof field has-bits. void GenerateOneofHasBits(io::Printer* printer, bool is_inline); // Generates has_foo_bar() functions for oneof members. void GenerateOneofMemberHasBits(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer); // Generates the clear_foo() method for a field. void GenerateFieldClear(const FieldDescriptor* field, - const map<string, string>& vars, + const std::map<string, string>& vars, io::Printer* printer); + void GenerateConstructorBody(io::Printer* printer, + std::vector<bool> already_processed, + bool copy_constructor) const; + + size_t HasBitsSize() const; + std::vector<uint32> RequiredFieldsBitMask() const; + const Descriptor* descriptor_; string classname_; Options options_; @@ -198,15 +199,17 @@ class MessageGenerator { // This is reused to initialize the fields in-order for cache efficiency. // // optimized_order_ excludes oneof fields. - vector<const FieldDescriptor *> optimized_order_; - vector< vector<string> > runs_of_fields_; // that might be trivially cleared + std::vector<const FieldDescriptor *> optimized_order_; + std::vector<int> has_bit_indices_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; int num_required_fields_; - bool uses_string_; bool use_dependent_base_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index ca7bae02..91449657 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -45,7 +45,7 @@ namespace cpp { namespace { void SetMessageVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = FieldMessageTypeName(descriptor); @@ -218,7 +218,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { return; } - map<string, string> variables(variables_); + 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"] = @@ -349,7 +349,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, // for dependent fields we cannot access its internal_default_instance, // because the type is incomplete. // TODO(gerbens) deprecate dependent base class. - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" @@ -360,7 +360,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const $type$& $classname$::$name$() const {\n" @@ -469,7 +469,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != @@ -486,6 +486,26 @@ GenerateClearingCode(io::Printer* printer) const { } void MessageFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + std::map<string, string> variables(variables_); + variables["type"] = FieldMessageTypeName(descriptor_); + + if (!HasFieldPresence(descriptor_->file())) { + // If we don't have has-bits, message presence is indicated only by ptr != + // NULL. Thus on clear, we need to delete the object. + printer->Print(variables_, + "if (GetArenaNoVirtual() == NULL && $name$_ != NULL) {\n" + " delete $name$_;\n" + "}\n" + "$name$_ = NULL;\n"); + } else { + printer->Print(variables_, + "GOOGLE_DCHECK($name$_ != NULL);\n" + "$name$_->$type$::Clear();\n"); + } +} + +void MessageFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { printer->Print(variables_, "mutable_$name$()->$type$::MergeFrom(from.$name$());\n"); @@ -497,11 +517,51 @@ GenerateSwappingCode(io::Printer* printer) const { } void MessageFieldGenerator:: +GenerateDestructorCode(io::Printer* printer) const { + // In google3 a default instance will never get deleted so we don't need to + // worry about that but in opensource protobuf default instances are deleted + // in shutdown process and we need to take special care when handling them. + printer->Print(variables_, + "if (this != internal_default_instance()) {\n" + " delete $name$_;\n" + "}\n"); +} + +void MessageFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print(variables_, "$name$_ = NULL;\n"); } 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. + + printer->Print(variables_, + "if (from.has_$name$()) {\n" + " $name$_ = new $type$(*from.$name$_);\n" + "} else {\n" + " $name$_ = NULL;\n" + "}\n"); +} + +void MessageFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) { printer->Print(variables_, @@ -581,7 +641,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { if (!dependent_base_) { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = "inline "; variables["dependent_classname"] = DependentBaseClassTemplateName(descriptor_->containing_type()) + "<T>"; @@ -601,7 +661,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, if (dependent_base_) { return; } - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; variables["dependent_classname"] = variables["classname"]; variables["this_message"] = ""; @@ -615,16 +675,15 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void MessageOneofFieldGenerator:: GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["field_member"] = variables["oneof_prefix"] + variables["name"] + "_"; //printer->Print(variables, } -void MessageOneofFieldGenerator:: -InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables, - io::Printer* printer) const { +void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions( + const std::map<string, string>& variables, io::Printer* printer) const { printer->Print(variables, "$tmpl$" "$inline$ " @@ -794,7 +853,7 @@ InternalGenerateInlineAccessorDefinitions(const map<string, string>& variables, void MessageOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; if (SupportsArenas(descriptor_)) { printer->Print(variables, @@ -808,11 +867,22 @@ GenerateClearingCode(io::Printer* printer) const { } void MessageOneofFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); +} + +void MessageOneofFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. } void MessageOneofFieldGenerator:: +GenerateDestructorCode(io::Printer* printer) const { + // We inherit from MessageFieldGenerator, so we need to override the default + // behavior. +} + +void MessageOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { // Don't print any constructor code. The field is in a union. We allocate // space only when this field is used. @@ -884,7 +954,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { if (!dependent_field_) { return; } - map<string, string> variables(variables_); + 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"] = @@ -915,7 +985,6 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { " return $this_message$$name$_.Add();\n" "}\n"); - if (dependent_getter_) { printer->Print(variables, "template <class T>\n" @@ -939,7 +1008,7 @@ GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const { void RepeatedMessageFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (!dependent_getter_) { @@ -989,7 +1058,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, void RepeatedMessageFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["this_message"] = dependent_field_ ? DependentBaseDownCast() : ""; printer->Print(variables, "$this_message$$name$_.Clear();\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h index d8d9279c..9ca91153 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -59,23 +59,26 @@ class MessageFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; protected: - void GenerateArenaManipulationCode(const map<string, string>& variables, + void GenerateArenaManipulationCode(const std::map<string, string>& variables, io::Printer* printer) const; virtual void GenerateGetterDeclaration(io::Printer* printer) const; const FieldDescriptor* descriptor_; const bool dependent_field_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); @@ -94,7 +97,12 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + + // MessageFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; protected: @@ -102,7 +110,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { private: void InternalGenerateInlineAccessorDefinitions( - const map<string, string>& variables, io::Printer* printer) const; + const std::map<string, string>& variables, io::Printer* printer) const; const bool dependent_base_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator); @@ -125,6 +133,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -137,7 +146,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { const FieldDescriptor* descriptor_; const bool dependent_field_; const bool dependent_getter_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 54b3d24a..240a6e0a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -80,7 +80,7 @@ int FixedSize(FieldDescriptor::Type type) { } void SetPrimitiveVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = PrimitiveTypeName(descriptor->cpp_type()); @@ -122,7 +122,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void PrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -157,6 +157,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void PrimitiveFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_ = from.$name$_;\n"); +} + +void PrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "$set_hasbit$\n" @@ -206,7 +211,7 @@ PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {} void PrimitiveOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$() const {\n" @@ -240,7 +245,7 @@ void PrimitiveOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - " $classname$_default_oneof_instance_->$name$_ = $default$;\n"); + " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); } void PrimitiveOneofFieldGenerator:: @@ -297,7 +302,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$$type$ $classname$::$name$(int index) const {\n" @@ -336,11 +341,6 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedPrimitiveFieldGenerator:: -GenerateUnsafeMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); -} - -void RepeatedPrimitiveFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } @@ -351,11 +351,16 @@ GenerateConstructorCode(io::Printer* printer) const { } void RepeatedPrimitiveFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);\n"); +} + +void RepeatedPrimitiveFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n" " $type$, $wire_format_field_type$>(\n" - " $tag_size$, $tag$, input, this->mutable_$name$())));\n"); + " $tag_size$, $tag$u, input, this->mutable_$name$())));\n"); } void RepeatedPrimitiveFieldGenerator:: diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index 23cc697e..44c9ff3e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -59,6 +59,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -66,7 +67,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator); @@ -103,9 +104,9 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; - virtual void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; @@ -114,7 +115,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_service.cc b/src/google/protobuf/compiler/cpp/cpp_service.cc index 6030f7ce..d6b1ddc5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -143,7 +143,7 @@ void ServiceGenerator::GenerateMethodSignatures( VirtualOrNon virtual_or_non, io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["name"] = method->name(); sub_vars["input_type"] = ClassName(method->input_type(), true); sub_vars["output_type"] = ClassName(method->output_type(), true); @@ -161,7 +161,7 @@ void ServiceGenerator::GenerateMethodSignatures( void ServiceGenerator::GenerateDescriptorInitializer( io::Printer* printer, int index) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["index"] = SimpleItoa(index); @@ -172,19 +172,20 @@ void ServiceGenerator::GenerateDescriptorInitializer( // =================================================================== void ServiceGenerator::GenerateImplementation(io::Printer* printer) { - printer->Print(vars_, - "$classname$::~$classname$() {}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n" - "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return $classname$_descriptor_;\n" - "}\n" - "\n"); + vars_["index"] = SimpleItoa(index_in_metadata_); + printer->Print( + vars_, + "$classname$::~$classname$() {}\n" + "\n" + "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" + " protobuf_AssignDescriptorsOnce();\n" + " return file_level_service_descriptors[$index$];\n" + "}\n" + "\n" + "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" + " return descriptor();\n" + "}\n" + "\n"); // Generate methods of the interface. GenerateNotImplementedMethods(printer); @@ -212,7 +213,7 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) { void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["classname"] = descriptor_->name(); sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); @@ -232,18 +233,20 @@ void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) { } void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { - printer->Print(vars_, - "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" - " ::google::protobuf::RpcController* controller,\n" - " const ::google::protobuf::Message* request,\n" - " ::google::protobuf::Message* response,\n" - " ::google::protobuf::Closure* done) {\n" - " GOOGLE_DCHECK_EQ(method->service(), $classname$_descriptor_);\n" - " switch(method->index()) {\n"); + printer->Print( + vars_, + "void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\n" + " ::google::protobuf::RpcController* controller,\n" + " const ::google::protobuf::Message* request,\n" + " ::google::protobuf::Message* response,\n" + " ::google::protobuf::Closure* done) {\n" + " GOOGLE_DCHECK_EQ(method->service(), " + "file_level_service_descriptors[$index$]);\n" + " switch(method->index()) {\n"); for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); sub_vars["input_type"] = ClassName(method->input_type(), true); @@ -289,7 +292,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, const Descriptor* type = (which == REQUEST) ? method->input_type() : method->output_type(); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["index"] = SimpleItoa(i); sub_vars["type"] = ClassName(type, true); @@ -312,7 +315,7 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which, void ServiceGenerator::GenerateStubMethods(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> sub_vars; + std::map<string, string> sub_vars; sub_vars["classname"] = descriptor_->name(); sub_vars["name"] = method->name(); sub_vars["index"] = SimpleItoa(i); diff --git a/src/google/protobuf/compiler/cpp/cpp_service.h b/src/google/protobuf/compiler/cpp/cpp_service.h index ede2fd80..33c02547 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.h +++ b/src/google/protobuf/compiler/cpp/cpp_service.h @@ -105,8 +105,11 @@ class ServiceGenerator { void GenerateStubMethods(io::Printer* printer); const ServiceDescriptor* descriptor_; - map<string, string> vars_; + std::map<string, string> vars_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index aee3d1ea..a9505e3d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -46,20 +46,19 @@ namespace cpp { namespace { void SetStringVariables(const FieldDescriptor* descriptor, - map<string, string>* variables, + std::map<string, string>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["default"] = DefaultValue(descriptor); (*variables)["default_length"] = SimpleItoa(descriptor->default_value_string().length()); - string default_variable_string = + string default_variable_string = "_default_" + FieldName(descriptor) + "_"; + (*variables)["default_variable_name"] = default_variable_string; + (*variables)["default_variable"] = descriptor->default_value_string().empty() ? "&::google::protobuf::internal::GetEmptyStringAlreadyInited()" - : "_default_" + FieldName(descriptor) + "_"; - (*variables)["default_variable"] = default_variable_string; - (*variables)["default_value_init"] = - descriptor->default_value_string().empty() - ? "" : "*" + default_variable_string; + : "&" + (*variables)["classname"] + "::" + default_variable_string + + ".get()"; (*variables)["pointer_type"] = descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char"; // NOTE: Escaped here to unblock proto1->proto2 migration. @@ -104,7 +103,9 @@ GeneratePrivateMembers(io::Printer* printer) const { void StringFieldGenerator:: GenerateStaticMembers(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { - printer->Print(variables_, "static ::std::string* $default_variable$;\n"); + printer->Print(variables_, + "static ::google::protobuf::internal::ExplicitlyConstructed< ::std::string>" + " $default_variable_name$;\n"); } } @@ -165,117 +166,121 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void StringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_.Get($default_variable$);\n" - "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" - " $set_hasbit$\n" - " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" - " $set_hasbit$\n" - " $name$_.Set($default_variable$, $string_piece$(value),\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - " $set_hasbit$\n" - " $name$_.Set($default_variable$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n" - "}\n" - "$inline$::std::string* $classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " $clear_hasbit$\n" - " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n" - "}\n" - "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" - " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " $clear_hasbit$\n" - " return $name$_.UnsafeArenaRelease($default_variable$,\n" - " GetArenaNoVirtual());\n" - "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" - " ::std::string* $name$) {\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.UnsafeArenaSetAllocated($default_variable$,\n" - " $name$, GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" - "$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$inline$const ::std::string& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.Get();\n" + "}\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + " $set_hasbit$\n" + " $name$_.Set($default_variable$, value, GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" + " $set_hasbit$\n" + " $name$_.Set($default_variable$, $string_piece$(value),\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value,\n" + " size_t size) {\n" + " $set_hasbit$\n" + " $name$_.Set($default_variable$, $string_piece$(\n" + " reinterpret_cast<const char*>(value), size), " + "GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " $set_hasbit$\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\n" + "}\n" + "$inline$::std::string* $classname$::$release_name$() {\n" + " // @@protoc_insertion_point(field_release:$full_name$)\n" + " $clear_hasbit$\n" + " return $name$_.Release($default_variable$, GetArenaNoVirtual());\n" + "}\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" + " // " + "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " $clear_hasbit$\n" + " return $name$_.UnsafeArenaRelease($default_variable$,\n" + " GetArenaNoVirtual());\n" + "}\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.SetAllocated($default_variable$, $name$,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(\n" + " ::std::string* $name$) {\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.UnsafeArenaSetAllocated($default_variable$,\n" + " $name$, GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" + "$full_name$)\n" + "}\n"); } else { // No-arena case. - printer->Print(variables, - "$inline$const ::std::string& $classname$::$name$() const {\n" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_.GetNoArena($default_variable$);\n" - "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" - " $set_hasbit$\n" - " $name$_.SetNoArena($default_variable$, value);\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" - " $set_hasbit$\n" - " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value, " - "size_t size) {\n" - " $set_hasbit$\n" - " $name$_.SetNoArena($default_variable$,\n" - " $string_piece$(reinterpret_cast<const char*>(value), size));\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " $set_hasbit$\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $name$_.MutableNoArena($default_variable$);\n" - "}\n" - "$inline$::std::string* $classname$::$release_name$() {\n" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - " $clear_hasbit$\n" - " return $name$_.ReleaseNoArena($default_variable$);\n" - "}\n" - "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" - " if ($name$ != NULL) {\n" - " $set_hasbit$\n" - " } else {\n" - " $clear_hasbit$\n" - " }\n" - " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$inline$const ::std::string& $classname$::$name$() const {\n" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return $name$_.GetNoArena();\n" + "}\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + " $set_hasbit$\n" + " $name$_.SetNoArena($default_variable$, value);\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" + " $set_hasbit$\n" + " $name$_.SetNoArena($default_variable$, $string_piece$(value));\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value, " + "size_t size) {\n" + " $set_hasbit$\n" + " $name$_.SetNoArena($default_variable$,\n" + " $string_piece$(reinterpret_cast<const char*>(value), size));\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " $set_hasbit$\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $name$_.MutableNoArena($default_variable$);\n" + "}\n" + "$inline$::std::string* $classname$::$release_name$() {\n" + " // @@protoc_insertion_point(field_release:$full_name$)\n" + " $clear_hasbit$\n" + " return $name$_.ReleaseNoArena($default_variable$);\n" + "}\n" + "$inline$void $classname$::set_allocated_$name$(::std::string* $name$) {\n" + " if ($name$ != NULL) {\n" + " $set_hasbit$\n" + " } else {\n" + " $clear_hasbit$\n" + " }\n" + " $name$_.SetAllocatedNoArena($default_variable$, $name$);\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } } @@ -284,7 +289,8 @@ GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { // Initialized in GenerateDefaultInstanceAllocator. printer->Print(variables_, - "::std::string* $classname$::$default_variable$ = NULL;\n"); + "::google::protobuf::internal::ExplicitlyConstructed< ::std::string> " + "$classname$::$default_variable_name$;\n"); } } @@ -314,6 +320,52 @@ GenerateClearingCode(io::Printer* printer) const { } void StringFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + // Two-dimension specialization here: supporting arenas, field presence, or + // not, and default value is the empty string or not. Complexity here ensures + // the minimal number of branches / amount of extraneous code at runtime + // (given that the below methods are inlined one-liners)! + + // If we have field presence, then the Clear() method of the protocol buffer + // will have checked that this field is set. If so, we can avoid redundant + // checks against default_variable. + const bool must_be_present = HasFieldPresence(descriptor_->file()); + + if (must_be_present) { + printer->Print(variables_, + "GOOGLE_DCHECK(!$name$_.IsDefault($default_variable$));\n"); + } + + if (SupportsArenas(descriptor_)) { + if (descriptor_->default_value_string().empty()) { + printer->Print(variables_, + "$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\n"); + } else { + printer->Print(variables_, + "$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\n"); + } + } else if (must_be_present) { + // 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"); + } else { + printer->Print(variables_, + "(*$name$_.UnsafeRawStringPointer())->assign(*$default_variable$);\n"); + } + } else { + if (descriptor_->default_value_string().empty()) { + printer->Print(variables_, + "$name$_.ClearToEmptyNoArena($default_variable$);\n"); + } else { + printer->Print(variables_, + "$name$_.ClearToDefaultNoArena($default_variable$);\n"); + } + } +} + +void StringFieldGenerator:: GenerateMergingCode(io::Printer* printer) const { if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { // TODO(gpike): improve this @@ -337,6 +389,34 @@ GenerateConstructorCode(io::Printer* printer) const { } void StringFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + GenerateConstructorCode(printer); + + if (HasFieldPresence(descriptor_->file())) { + printer->Print(variables_, + "if (from.has_$name$()) {\n"); + } else { + printer->Print(variables_, + "if (from.$name$().size() > 0) {\n"); + } + + printer->Indent(); + + if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { + // TODO(gpike): improve this + printer->Print(variables_, + "$name$_.Set($default_variable$, from.$name$(),\n" + " GetArenaNoVirtual());\n"); + } else { + printer->Print(variables_, + "$name$_.AssignWithDefault($default_variable$, from.$name$_);\n"); + } + + printer->Outdent(); + printer->Print("}\n"); +} + +void StringFieldGenerator:: GenerateDestructorCode(io::Printer* printer) const { if (SupportsArenas(descriptor_)) { // The variable |arena| is defined by the enclosing code. @@ -353,8 +433,9 @@ void StringFieldGenerator:: GenerateDefaultInstanceAllocator(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { printer->Print(variables_, - "$classname$::$default_variable$ =\n" - " new ::std::string($default$, $default_length$);\n"); + "$classname$::$default_variable_name$.DefaultConstruct();\n" + "*$classname$::$default_variable_name$.get_mutable() = " + "::std::string($default$, $default_length$);\n"); } } @@ -362,7 +443,7 @@ void StringFieldGenerator:: GenerateShutdownCode(io::Printer* printer) const { if (!descriptor_->default_value_string().empty()) { printer->Print(variables_, - "delete $classname$::$default_variable$;\n"); + "$classname$::$default_variable_name$.Shutdown();\n"); } } @@ -427,185 +508,190 @@ StringOneofFieldGenerator::~StringOneofFieldGenerator() {} void StringOneofFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; if (SupportsArenas(descriptor_)) { - printer->Print(variables, - "$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($default_variable$);\n" - " }\n" - " return *$default_variable$;\n" - "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, value,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$,\n" - " $string_piece$(value), GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value,\n" - " size_t size) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size),\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " return $oneof_prefix$$name$_.Mutable($default_variable$,\n" - " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\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$_.Release($default_variable$,\n" - " GetArenaNoVirtual());\n" - " } else {\n" - " return NULL;\n" - " }\n" - "}\n" - "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" - " // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " if (has_$name$()) {\n" - " clear_has_$oneof_name$();\n" - " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n" - " $default_variable$, GetArenaNoVirtual());\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" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$ != NULL) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n" - " GetArenaNoVirtual());\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n" - "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" - "::std::string* $name$) {\n" - " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" - " if (!has_$name$()) {\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, " - "$name$, GetArenaNoVirtual());\n" - " }\n" - " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" - "$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$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" + " }\n" + " return *$default_variable$;\n" + "}\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$, value,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$,\n" + " $string_piece$(value), GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value,\n" + " size_t size) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\n" + " reinterpret_cast<const char*>(value), size),\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " return $oneof_prefix$$name$_.Mutable($default_variable$,\n" + " GetArenaNoVirtual());\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\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$_.Release($default_variable$,\n" + " GetArenaNoVirtual());\n" + " } else {\n" + " return NULL;\n" + " }\n" + "}\n" + "$inline$::std::string* $classname$::unsafe_arena_release_$name$() {\n" + " // " + "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " if (has_$name$()) {\n" + " clear_has_$oneof_name$();\n" + " return $oneof_prefix$$name$_.UnsafeArenaRelease(\n" + " $default_variable$, GetArenaNoVirtual());\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" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$ != NULL) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\n" + " GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n" + "$inline$void $classname$::unsafe_arena_set_allocated_$name$(" + "::std::string* $name$) {\n" + " GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n" + " if (!has_$name$()) {\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, " + "$name$, GetArenaNoVirtual());\n" + " }\n" + " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:" + "$full_name$)\n" + "}\n"); } else { // No-arena case. - printer->Print(variables, - "$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($default_variable$);\n" - " }\n" - " return *$default_variable$;\n" - "}\n" - "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - "}\n" - "$inline$void $classname$::set_$name$(const char* value) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n" - " $string_piece$(value));\n" - " // @@protoc_insertion_point(field_set_char:$full_name$)\n" - "}\n" - "$inline$" - "void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " $oneof_prefix$$name$_.SetNoArena($default_variable$, $string_piece$(\n" - " reinterpret_cast<const char*>(value), size));\n" - " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" - "}\n" - "$inline$::std::string* $classname$::mutable_$name$() {\n" - " if (!has_$name$()) {\n" - " clear_$oneof_name$();\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" - " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" - " return $oneof_prefix$$name$_.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" - " } 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" - " }\n" - " clear_$oneof_name$();\n" - " if ($name$ != NULL) {\n" - " set_has_$name$();\n" - " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n" - " $name$);\n" - " }\n" - " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" - "}\n"); + printer->Print( + variables, + "$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" + " }\n" + " return *$default_variable$;\n" + "}\n" + "$inline$void $classname$::set_$name$(const ::std::string& value) {\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "$inline$void $classname$::set_$name$(const char* value) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.SetNoArena($default_variable$,\n" + " $string_piece$(value));\n" + " // @@protoc_insertion_point(field_set_char:$full_name$)\n" + "}\n" + "$inline$" + "void $classname$::set_$name$(const $pointer_type$* value, size_t " + "size) {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " $oneof_prefix$$name$_.SetNoArena($default_variable$, " + "$string_piece$(\n" + " reinterpret_cast<const char*>(value), size));\n" + " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" + "}\n" + "$inline$::std::string* $classname$::mutable_$name$() {\n" + " if (!has_$name$()) {\n" + " clear_$oneof_name$();\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\n" + " }\n" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return $oneof_prefix$$name$_.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" + " } 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" + " }\n" + " clear_$oneof_name$();\n" + " if ($name$ != NULL) {\n" + " set_has_$name$();\n" + " $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\n" + " $name$);\n" + " }\n" + " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n" + "}\n"); } } void StringOneofFieldGenerator:: GenerateClearingCode(io::Printer* printer) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); if (dependent_field_) { variables["this_message"] = DependentBaseDownCast(); // This clearing code may be in the dependent base class. If the default @@ -614,8 +700,9 @@ GenerateClearingCode(io::Printer* printer) const { // default value's global singleton instance. See SetStringVariables() for // possible values of default_variable. if (!descriptor_->default_value_string().empty()) { - variables["default_variable"] = - DependentBaseDownCast() + variables["default_variable"]; + variables["default_variable"] = "&" + DependentBaseDownCast() + + variables["default_variable_name"] + + ".get()"; } } else { variables["this_message"] = ""; @@ -632,15 +719,21 @@ GenerateClearingCode(io::Printer* printer) const { } void StringOneofFieldGenerator:: +GenerateMessageClearingCode(io::Printer* printer) const { + return GenerateClearingCode(printer); +} + +void StringOneofFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. } void StringOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { - printer->Print(variables_, - " $classname$_default_oneof_instance_->$name$_.UnsafeSetDefault(" - "$default_variable$);\n"); + printer->Print( + variables_, + "$classname$_default_oneof_instance_.$name$_.UnsafeSetDefault(\n" + " $default_variable$);\n"); } void StringOneofFieldGenerator:: @@ -733,7 +826,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { void RepeatedStringFieldGenerator:: GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const { - map<string, string> variables(variables_); + std::map<string, string> variables(variables_); variables["inline"] = is_inline ? "inline " : ""; printer->Print(variables, "$inline$const ::std::string& $classname$::$name$(int index) const {\n" @@ -800,11 +893,6 @@ GenerateMergingCode(io::Printer* printer) const { } void RepeatedStringFieldGenerator:: -GenerateUnsafeMergingCode(io::Printer* printer) const { - printer->Print(variables_, "$name$_.UnsafeMergeFrom(from.$name$_);\n"); -} - -void RepeatedStringFieldGenerator:: GenerateSwappingCode(io::Printer* printer) const { printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n"); } @@ -815,6 +903,11 @@ GenerateConstructorCode(io::Printer* printer) const { } void RepeatedStringFieldGenerator:: +GenerateCopyConstructorCode(io::Printer* printer) const { + printer->Print(variables_, "$name$_.CopyFrom(from.$name$_);"); +} + +void RepeatedStringFieldGenerator:: GenerateMergeFromCodedStream(io::Printer* printer) const { printer->Print(variables_, "DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\n" diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.h b/src/google/protobuf/compiler/cpp/cpp_string_field.h index 1dea7663..af263c1a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -58,9 +58,11 @@ class StringFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; void GenerateDefaultInstanceAllocator(io::Printer* printer) const; void GenerateShutdownCode(io::Printer* printer) const; @@ -71,7 +73,7 @@ class StringFieldGenerator : public FieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); @@ -87,6 +89,10 @@ class StringOneofFieldGenerator : public StringFieldGenerator { void GenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; + + // StringFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; @@ -110,9 +116,9 @@ class RepeatedStringFieldGenerator : public FieldGenerator { bool is_inline) const; void GenerateClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; - void GenerateUnsafeMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateSerializeWithCachedSizes(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; @@ -120,7 +126,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator); }; diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc index d214ef0a..8eaddb87 100644 --- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc +++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc @@ -67,6 +67,7 @@ #include <google/protobuf/compiler/importer.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> +#include <google/protobuf/arena.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/dynamic_message.h> @@ -199,14 +200,14 @@ TEST(GeneratedMessageTest, FloatingPointDefaults) { EXPECT_EQ(-1.5f, extreme_default.negative_float()); EXPECT_EQ(2.0e8f, extreme_default.large_float()); EXPECT_EQ(-8e-28f, extreme_default.small_negative_float()); - EXPECT_EQ(numeric_limits<double>::infinity(), + EXPECT_EQ(std::numeric_limits<double>::infinity(), extreme_default.inf_double()); - EXPECT_EQ(-numeric_limits<double>::infinity(), + EXPECT_EQ(-std::numeric_limits<double>::infinity(), extreme_default.neg_inf_double()); EXPECT_TRUE(extreme_default.nan_double() != extreme_default.nan_double()); - EXPECT_EQ(numeric_limits<float>::infinity(), + EXPECT_EQ(std::numeric_limits<float>::infinity(), extreme_default.inf_float()); - EXPECT_EQ(-numeric_limits<float>::infinity(), + EXPECT_EQ(-std::numeric_limits<float>::infinity(), extreme_default.neg_inf_float()); EXPECT_TRUE(extreme_default.nan_float() != extreme_default.nan_float()); } @@ -518,6 +519,26 @@ TEST(GeneratedMessageTest, CopyConstructor) { TestUtil::ExpectAllFieldsSet(message2); } +TEST(GeneratedMessageTest, CopyConstructorWithArenas) { + Arena arena; + unittest::TestAllTypes* message1 = + Arena::CreateMessage<unittest::TestAllTypes>(&arena); + TestUtil::SetAllFields(message1); + + unittest::TestAllTypes message2_stack(*message1); + TestUtil::ExpectAllFieldsSet(message2_stack); + + google::protobuf::scoped_ptr<unittest::TestAllTypes> message2_heap( + new unittest::TestAllTypes(*message1)); + TestUtil::ExpectAllFieldsSet(*message2_heap); + + arena.Reset(); + + // Verify that the copies are still intact. + TestUtil::ExpectAllFieldsSet(message2_stack); + TestUtil::ExpectAllFieldsSet(*message2_heap); +} + TEST(GeneratedMessageTest, CopyAssignmentOperator) { unittest::TestAllTypes message1; TestUtil::SetAllFields(&message1); @@ -600,14 +621,16 @@ TEST(GeneratedMessageTest, NonEmptyMergeFrom) { #if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \ !defined(GOOGLE_PROTOBUF_NO_RTTI) #ifdef PROTOBUF_HAS_DEATH_TEST +#ifndef NDEBUG TEST(GeneratedMessageTest, MergeFromSelf) { unittest::TestAllTypes message; - EXPECT_DEATH(message.MergeFrom(message), "Check failed:.*pb[.]cc"); + EXPECT_DEATH(message.MergeFrom(message), "pb[.]cc.*Check failed:"); EXPECT_DEATH(message.MergeFrom(implicit_cast<const Message&>(message)), - "Check failed:.*pb[.]cc"); + "pb[.]cc.*Check failed:"); } +#endif // NDEBUG #endif // PROTOBUF_HAS_DEATH_TEST #endif // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI diff --git a/src/google/protobuf/compiler/cpp/metadata_test.cc b/src/google/protobuf/compiler/cpp/metadata_test.cc index edd30780..03f6b12b 100644 --- a/src/google/protobuf/compiler/cpp/metadata_test.cc +++ b/src/google/protobuf/compiler/cpp/metadata_test.cc @@ -156,7 +156,7 @@ const char kSmallTestFile[] = // couldn't). const GeneratedCodeInfo::Annotation* FindAnnotationOnPath( const GeneratedCodeInfo& info, const string& source_file, - const vector<int>& path) { + const std::vector<int>& path) { for (int i = 0; i < info.annotation_size(); ++i) { const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i); if (annotation->source_file() != source_file || @@ -197,7 +197,7 @@ TEST_F(CppMetadataTest, CapturesEnumNames) { EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Enum", file.enum_type(0).name()); - vector<int> enum_path; + std::vector<int> enum_path; enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber); enum_path.push_back(0); const GeneratedCodeInfo::Annotation* enum_annotation = @@ -226,7 +226,7 @@ TEST_F(CppMetadataTest, CapturesMessageNames) { EXPECT_TRUE( CaptureMetadata("test.proto", &file, &pb_h, &info, NULL, NULL, NULL)); EXPECT_EQ("Message", file.message_type(0).name()); - vector<int> message_path; + std::vector<int> message_path; message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber); message_path.push_back(0); const GeneratedCodeInfo::Annotation* message_annotation = diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 0d9093c0..462748b9 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -270,8 +270,8 @@ static string CanonicalizePath(string path) { } #endif - vector<string> canonical_parts; - vector<string> parts = Split( + std::vector<string> canonical_parts; + std::vector<string> parts = Split( path, "/", true); // Note: Removes empty parts. for (int i = 0; i < parts.size(); i++) { if (parts[i] == ".") { diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h index cc8fcc39..759636e1 100644 --- a/src/google/protobuf/compiler/importer.h +++ b/src/google/protobuf/compiler/importer.h @@ -305,7 +305,7 @@ class LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree { const string& disk_path_param) : virtual_path(virtual_path_param), disk_path(disk_path_param) {} }; - vector<Mapping> mappings_; + std::vector<Mapping> mappings_; string last_error_message_; // Like Open(), but returns the on-disk path in disk_file if disk_file is diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc index 1b6e9700..00285bcc 100644 --- a/src/google/protobuf/compiler/importer_unittest.cc +++ b/src/google/protobuf/compiler/importer_unittest.cc @@ -293,7 +293,7 @@ class DiskSourceTreeTest : public testing::Test { DiskSourceTree source_tree_; // Paths of two on-disk directories to use during the test. - vector<string> dirnames_; + std::vector<string> dirnames_; }; TEST_F(DiskSourceTreeTest, MapRoot) { diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc index 6cfa14a0..b82fb3dd 100644 --- a/src/google/protobuf/compiler/java/java_context.cc +++ b/src/google/protobuf/compiler/java/java_context.cc @@ -108,7 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage( for (int i = 0; i < message->nested_type_count(); ++i) { InitializeFieldGeneratorInfoForMessage(message->nested_type(i)); } - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; for (int i = 0; i < message->field_count(); ++i) { fields.push_back(message->field(i)); } @@ -124,11 +124,11 @@ void Context::InitializeFieldGeneratorInfoForMessage( } void Context::InitializeFieldGeneratorInfoForFields( - const vector<const FieldDescriptor*>& fields) { + const std::vector<const FieldDescriptor*>& fields) { // Find out all fields that conflict with some other field in the same // message. - vector<bool> is_conflict(fields.size()); - vector<string> conflict_reason(fields.size()); + std::vector<bool> is_conflict(fields.size()); + std::vector<string> conflict_reason(fields.size()); for (int i = 0; i < fields.size(); ++i) { const FieldDescriptor* field = fields[i]; const string& name = UnderscoresToCapitalizedCamelCase(field); diff --git a/src/google/protobuf/compiler/java/java_context.h b/src/google/protobuf/compiler/java/java_context.h index f92ae87e..b22e7e3a 100644 --- a/src/google/protobuf/compiler/java/java_context.h +++ b/src/google/protobuf/compiler/java/java_context.h @@ -95,11 +95,13 @@ class Context { void InitializeFieldGeneratorInfo(const FileDescriptor* file); void InitializeFieldGeneratorInfoForMessage(const Descriptor* message); void InitializeFieldGeneratorInfoForFields( - const vector<const FieldDescriptor*>& fields); + const std::vector<const FieldDescriptor*>& fields); google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; - map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_; - map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_; + std::map<const FieldDescriptor*, FieldGeneratorInfo> + field_generator_info_map_; + std::map<const OneofDescriptor*, OneofGeneratorInfo> + oneof_generator_info_map_; Options options_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context); }; diff --git a/src/google/protobuf/compiler/java/java_doc_comment.cc b/src/google/protobuf/compiler/java/java_doc_comment.cc index 0b5caba4..59c04ad4 100644 --- a/src/google/protobuf/compiler/java/java_doc_comment.cc +++ b/src/google/protobuf/compiler/java/java_doc_comment.cc @@ -115,7 +115,7 @@ static void WriteDocCommentBodyForLocation( // HTML-escape them so that they don't accidentally close the doc comment. comments = EscapeJavadoc(comments); - vector<string> lines = Split(comments, "\n"); + std::vector<string> lines = Split(comments, "\n"); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc index b46cfe9c..b9ee00ff 100644 --- a/src/google/protobuf/compiler/java/java_enum.cc +++ b/src/google/protobuf/compiler/java/java_enum.cc @@ -49,17 +49,6 @@ namespace protobuf { namespace compiler { namespace java { -namespace { -bool EnumHasCustomOptions(const EnumDescriptor* descriptor) { - if (descriptor->options().unknown_fields().field_count() > 0) return true; - for (int i = 0; i < descriptor->value_count(); ++i) { - const EnumValueDescriptor* value = descriptor->value(i); - if (value->options().unknown_fields().field_count() > 0) return true; - } - return false; -} -} // namespace - EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api, Context* context) @@ -105,7 +94,7 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < canonical_values_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = canonical_values_[i]->name(); vars["index"] = SimpleItoa(canonical_values_[i]->index()); vars["number"] = SimpleItoa(canonical_values_[i]->number()); @@ -137,7 +126,7 @@ void EnumGenerator::Generate(io::Printer* printer) { // ----------------------------------------------------------------- for (int i = 0; i < aliases_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["name"] = aliases_[i].value->name(); vars["canonical_name"] = aliases_[i].canonical_value->name(); @@ -147,7 +136,7 @@ void EnumGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < descriptor_->value_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); WriteEnumValueDocComment(printer, descriptor_->value(i)); @@ -243,49 +232,14 @@ void EnumGenerator::Generate(io::Printer* printer) { // at module init time because it wouldn't work with descriptor.proto, but // we can cache the value the first time getDescriptor() is called. if (descriptor_->containing_type() == NULL) { - if (!MultipleJavaFiles(descriptor_->file(), immutable_api_)) { - printer->Print( - " return $file$.getDescriptor().getEnumTypes().get($index$);\n", - "file", name_resolver_->GetClassName(descriptor_->file(), - immutable_api_), - "index", SimpleItoa(descriptor_->index())); - } else { - printer->Indent(); - if (EnumHasCustomOptions(descriptor_)) { - // We need to load the immutable classes in order to parse custom - // options. However, since file level enums (no outer class) are - // shared by immutable code and mutable code, the immutable classes - // may not exist. So we try to use Java reflection to retrieve the - // descriptor from immutable classes. - printer->Print( - "try {\n" - " java.lang.Class immutableFileClass =\n" - " java.lang.Class.forName(\"$immutable_file_class_name$\");\n" - " @java.lang.SuppressWarnings(\"unchecked\")\n" - " java.lang.reflect.Method m =\n" - " immutableFileClass.getMethod(\"getDescriptor\");\n" - " com.google.protobuf.Descriptors.FileDescriptor file =\n" - " (com.google.protobuf.Descriptors.FileDescriptor)\n" - " m.invoke(immutableFileClass);\n" - " return file.getEnumTypes().get($index$);\n" - "} catch (java.lang.Exception e) {\n" - // Immutable classes cannot be found. Proceed as if custom options - // don't exist. - "}\n", - "immutable_file_class_name", - name_resolver_->GetImmutableClassName(descriptor_->file()), - "index", SimpleItoa(descriptor_->index())); - } - printer->Print( - "return $immutable_package$.$descriptor_class$.$descriptor$\n" - " .getEnumTypes().get($index$);\n", - "immutable_package", FileJavaPackage(descriptor_->file(), true), - "descriptor_class", - name_resolver_->GetDescriptorClassName(descriptor_->file()), - "descriptor", "getDescriptor()", - "index", SimpleItoa(descriptor_->index())); - printer->Outdent(); - } + // The class generated for the File fully populates the descriptor with + // extensions in both the mutable and immutable cases. (In the mutable api + // this is accomplished by attempting to load the immutable outer class). + printer->Print( + " return $file$.getDescriptor().getEnumTypes().get($index$);\n", + "file", name_resolver_->GetClassName(descriptor_->file(), + immutable_api_), + "index", SimpleItoa(descriptor_->index())); } else { printer->Print( " return $parent$.$descriptor$.getEnumTypes().get($index$);\n", diff --git a/src/google/protobuf/compiler/java/java_enum.h b/src/google/protobuf/compiler/java/java_enum.h index c33e713d..13dfc32d 100644 --- a/src/google/protobuf/compiler/java/java_enum.h +++ b/src/google/protobuf/compiler/java/java_enum.h @@ -72,13 +72,13 @@ class EnumGenerator { // considered equivalent. We treat the first defined constant for any // given numeric value as "canonical" and the rest as aliases of that // canonical value. - vector<const EnumValueDescriptor*> canonical_values_; + std::vector<const EnumValueDescriptor*> canonical_values_; struct Alias { const EnumValueDescriptor* value; const EnumValueDescriptor* canonical_value; }; - vector<Alias> aliases_; + std::vector<Alias> aliases_; bool immutable_api_; diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index 2e916c56..279b9da4 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_number"] = SimpleItoa( descriptor->default_value_enum()->number()); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor))); // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported diff --git a/src/google/protobuf/compiler/java/java_enum_field.h b/src/google/protobuf/compiler/java/java_enum_field.h index b8ff7343..924ff281 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.h +++ b/src/google/protobuf/compiler/java/java_enum_field.h @@ -82,7 +82,7 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -143,7 +143,7 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc index aa0eb5e8..f1dc47fc 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = @@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_number"] = SimpleItoa( descriptor->default_value_enum()->number()); - (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor))); // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.h b/src/google/protobuf/compiler/java/java_enum_field_lite.h index 9201b8d6..fa004720 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.h +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.h @@ -81,7 +81,7 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -142,7 +142,7 @@ class RepeatedImmutableEnumFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc index 99f52d40..96815920 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_lite.cc @@ -95,7 +95,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { printer->Indent(); for (int i = 0; i < canonical_values_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = canonical_values_[i]->name(); vars["number"] = SimpleItoa(canonical_values_[i]->number()); WriteEnumValueDocComment(printer, canonical_values_[i]); @@ -117,7 +117,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { // ----------------------------------------------------------------- for (int i = 0; i < aliases_.size(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["classname"] = descriptor_->name(); vars["name"] = aliases_[i].value->name(); vars["canonical_name"] = aliases_[i].canonical_value->name(); @@ -127,7 +127,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { } for (int i = 0; i < descriptor_->value_count(); i++) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = SimpleItoa(descriptor_->value(i)->number()); WriteEnumValueDocComment(printer, descriptor_->value(i)); diff --git a/src/google/protobuf/compiler/java/java_enum_lite.h b/src/google/protobuf/compiler/java/java_enum_lite.h index f27cb76f..b7be912c 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.h +++ b/src/google/protobuf/compiler/java/java_enum_lite.h @@ -72,13 +72,13 @@ class EnumLiteGenerator { // considered equivalent. We treat the first defined constant for any // given numeric value as "canonical" and the rest as aliases of that // canonical value. - vector<const EnumValueDescriptor*> canonical_values_; + std::vector<const EnumValueDescriptor*> canonical_values_; struct Alias { const EnumValueDescriptor* value; const EnumValueDescriptor* canonical_value; }; - vector<Alias> aliases_; + std::vector<Alias> aliases_; bool immutable_api_; diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc index 46b5faaa..cb237bf6 100644 --- a/src/google/protobuf/compiler/java/java_extension.cc +++ b/src/google/protobuf/compiler/java/java_extension.cc @@ -61,12 +61,10 @@ ImmutableExtensionGenerator::ImmutableExtensionGenerator( ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {} // Initializes the vars referenced in the generated code templates. -void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor, - const string& scope, - bool immutable, - ClassNameResolver* name_resolver, - map<string, string>* vars_pointer) { - map<string, string> &vars = *vars_pointer; +void ExtensionGenerator::InitTemplateVars( + const FieldDescriptor* descriptor, const string& scope, bool immutable, + ClassNameResolver* name_resolver, std::map<string, string>* vars_pointer) { + std::map<string, string> &vars = *vars_pointer; vars["scope"] = scope; vars["name"] = UnderscoresToCamelCase(descriptor); vars["containing_type"] = @@ -110,7 +108,7 @@ void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor, } void ImmutableExtensionGenerator::Generate(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; const bool kUseImmutableNames = true; InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_, &vars); diff --git a/src/google/protobuf/compiler/java/java_extension.h b/src/google/protobuf/compiler/java/java_extension.h index bdd42263..fb8d5201 100644 --- a/src/google/protobuf/compiler/java/java_extension.h +++ b/src/google/protobuf/compiler/java/java_extension.h @@ -79,7 +79,7 @@ class ExtensionGenerator { const string& scope, bool immutable, ClassNameResolver* name_resolver, - map<string, string>* vars_pointer); + std::map<string, string>* vars_pointer); private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); diff --git a/src/google/protobuf/compiler/java/java_extension_lite.cc b/src/google/protobuf/compiler/java/java_extension_lite.cc index 23261bac..c48c92e9 100644 --- a/src/google/protobuf/compiler/java/java_extension_lite.cc +++ b/src/google/protobuf/compiler/java/java_extension_lite.cc @@ -57,7 +57,7 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator( ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {} void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) { - map<string, string> vars; + std::map<string, string> vars; const bool kUseImmutableNames = true; InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_, &vars); diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index 3c7bc5c4..04917296 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -290,7 +290,7 @@ FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {} void SetCommonFieldVariables(const FieldDescriptor* descriptor, const FieldGeneratorInfo* info, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["field_name"] = descriptor->name(); (*variables)["name"] = info->name; (*variables)["capitalized_name"] = info->capitalized_name; @@ -301,7 +301,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, void SetCommonOneofVariables(const FieldDescriptor* descriptor, const OneofGeneratorInfo* info, - map<string, string>* variables) { + std::map<string, string>* variables) { (*variables)["oneof_name"] = info->name; (*variables)["oneof_capitalized_name"] = info->capitalized_name; (*variables)["oneof_index"] = @@ -314,9 +314,9 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor, "Case_ == " + SimpleItoa(descriptor->number()); } -void PrintExtraFieldInfo(const map<string, string>& variables, +void PrintExtraFieldInfo(const std::map<string, string>& variables, io::Printer* printer) { - const map<string, string>::const_iterator it = + const std::map<string, string>::const_iterator it = variables.find("disambiguated_reason"); if (it != variables.end() && !it->second.empty()) { printer->Print( diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h index 4dd4f57f..434e610c 100644 --- a/src/google/protobuf/compiler/java/java_field.h +++ b/src/google/protobuf/compiler/java/java_field.h @@ -169,7 +169,7 @@ struct FieldGeneratorInfo { string disambiguated_reason; }; -// Oneof information used in OneofFieldGeneartors. +// Oneof information used in OneofFieldGenerators. struct OneofGeneratorInfo { string name; string capitalized_name; @@ -178,15 +178,15 @@ struct OneofGeneratorInfo { // Set some common variables used in variable FieldGenerators. void SetCommonFieldVariables(const FieldDescriptor* descriptor, const FieldGeneratorInfo* info, - map<string, string>* variables); + std::map<string, string>* variables); // Set some common oneof variables used in OneofFieldGenerators. void SetCommonOneofVariables(const FieldDescriptor* descriptor, const OneofGeneratorInfo* info, - map<string, string>* variables); + std::map<string, string>* variables); // Print useful comments before a field's accessors. -void PrintExtraFieldInfo(const map<string, string>& variables, +void PrintExtraFieldInfo(const std::map<string, string>& variables, io::Printer* printer); } // namespace java diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 3cbc530e..cb4503f6 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -90,7 +90,7 @@ bool CollectExtensions(const Message& message, // There are unknown fields that could be extensions, thus this call fails. if (reflection->GetUnknownFields(message).field_count() > 0) return false; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { @@ -541,8 +541,8 @@ static void GenerateSibling(const string& package_dir, const string& java_package, const DescriptorClass* descriptor, GeneratorContext* context, - vector<string>* file_list, bool annotate_code, - vector<string>* annotation_list, + std::vector<string>* file_list, bool annotate_code, + std::vector<string>* annotation_list, const string& name_suffix, GeneratorClass* generator, void (GeneratorClass::*pfn)(io::Printer* printer)) { @@ -581,8 +581,8 @@ static void GenerateSibling(const string& package_dir, void FileGenerator::GenerateSiblings(const string& package_dir, GeneratorContext* context, - vector<string>* file_list, - vector<string>* annotation_list) { + std::vector<string>* file_list, + std::vector<string>* annotation_list) { if (MultipleJavaFiles(file_, immutable_api_)) { for (int i = 0; i < file_->enum_type_count(); i++) { if (HasDescriptorMethods(file_, context_->EnforceLite())) { diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h index 1e643f79..e95aef09 100644 --- a/src/google/protobuf/compiler/java/java_file.h +++ b/src/google/protobuf/compiler/java/java_file.h @@ -84,8 +84,8 @@ class FileGenerator { // service type). void GenerateSiblings(const string& package_dir, GeneratorContext* generator_context, - vector<string>* file_list, - vector<string>* annotation_list); + std::vector<string>* file_list, + std::vector<string>* annotation_list); const string& java_package() { return java_package_; } const string& classname() { return classname_; } diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc index b1ab4043..2c02d996 100644 --- a/src/google/protobuf/compiler/java/java_generator.cc +++ b/src/google/protobuf/compiler/java/java_generator.cc @@ -66,7 +66,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file, // parse generator options - vector<pair<string, string> > options; + std::vector<std::pair<string, string> > options; ParseGeneratorParameter(parameter, &options); Options file_options; @@ -105,11 +105,11 @@ bool JavaGenerator::Generate(const FileDescriptor* file, // ----------------------------------------------------------------- - vector<string> all_files; - vector<string> all_annotations; + std::vector<string> all_files; + std::vector<string> all_annotations; - vector<FileGenerator*> file_generators; + std::vector<FileGenerator*> file_generators; if (file_options.generate_immutable_code) { file_generators.push_back(new FileGenerator(file, file_options, /* immutable = */ true)); diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index c31df265..efb5fd45 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -360,6 +360,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) { return NULL; } + const char* FieldTypeName(FieldDescriptor::Type field_type) { switch (field_type) { case FieldDescriptor::TYPE_INT32 : return "INT32"; @@ -415,9 +416,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, "L"; case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field->default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { return "Double.POSITIVE_INFINITY"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { return "Double.NEGATIVE_INFINITY"; } else if (value != value) { return "Double.NaN"; @@ -427,9 +428,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, } case FieldDescriptor::CPPTYPE_FLOAT: { float value = field->default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { return "Float.POSITIVE_INFINITY"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { return "Float.NEGATIVE_INFINITY"; } else if (value != value) { return "Float.NaN"; diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc index dac1b51f..49070ba0 100644 --- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc @@ -446,8 +446,7 @@ GenerateMembers(io::Printer* printer) const { " for (com.google.protobuf.LazyFieldLite lf : $name$_) {\n" " list.add(($type$) lf.getValue($type$.getDefaultInstance()));\n" " }\n" - // TODO(dweis): Make this list immutable? - " return list;\n" + " return java.util.Collections.unmodifiableList(list);\n" "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc index 07aa3565..3fe68ae3 100644 --- a/src/google/protobuf/compiler/java/java_map_field.cc +++ b/src/google/protobuf/compiler/java/java_map_field.cc @@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, Context* context, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); ClassNameResolver* name_resolver = context->GetNameResolver(); @@ -308,6 +308,16 @@ GenerateMembers(io::Printer* printer) const { " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n" " $value_enum_type$.internalGetValueMap(),\n" " $unrecognized_value$);\n"); + printer->Print( + variables_, + "private static final java.util.Map<$boxed_key_type$, " + "$value_enum_type$>\n" + "internalGetAdapted$capitalized_name$Map(\n" + " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n" + " return new com.google.protobuf.Internal.MapAdapter<\n" + " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" + " map, $name$ValueConverter);\n" + "}\n"); } GenerateMapGetters(printer); } @@ -339,23 +349,23 @@ GenerateBuilderMembers(io::Printer* printer) const { " return $name$_;\n" "}\n"); GenerateMapGetters(printer); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder clear$capitalized_name$() {\n" - " getMutable$capitalized_name$().clear();\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder clear$capitalized_name$() {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .clear();\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder remove$capitalized_name$(\n" - " $key_type$ key) {\n" - " $key_null_check$\n" - " getMutable$capitalized_name$().remove(key);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder remove$capitalized_name$(\n" + " $key_type$ key) {\n" + " $key_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .remove(key);\n" + " return this;\n" + "}\n"); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -365,30 +375,28 @@ GenerateBuilderMembers(io::Printer* printer) const { "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "getMutable$capitalized_name$() {\n" - " return new com.google.protobuf.Internal.MapAdapter<\n" - " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" - " internalGetMutable$capitalized_name$().getMutableMap(),\n" - " $name$ValueConverter);\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap());\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$public Builder put$capitalized_name$(\n" - " $key_type$ key,\n" - " $value_enum_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " getMutable$capitalized_name$().put(key, value);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$public Builder put$capitalized_name$(\n" + " $key_type$ key,\n" + " $value_enum_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, $name$ValueConverter.doBackward(value));\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - // TODO(arielb): null check map keys/values here and everywhere else - // related to putAll "$deprecation$public Builder putAll$capitalized_name$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" - " getMutable$capitalized_name$().putAll(values);\n" + " internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap())\n" + " .putAll(values);\n" " return this;\n" "}\n"); if (SupportUnknownEnumValue(descriptor_->file())) { @@ -412,7 +420,8 @@ GenerateBuilderMembers(io::Printer* printer) const { " if ($value_enum_type$.forNumber(value) == null) {\n" " throw new java.lang.IllegalArgumentException();\n" " }\n" - " getMutable$capitalized_name$Value().put(key, value);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" " return this;\n" "}\n"); WriteFieldDocComment(printer, descriptor_); @@ -420,7 +429,8 @@ GenerateBuilderMembers(io::Printer* printer) const { variables_, "$deprecation$public Builder putAll$capitalized_name$Value(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" - " getMutable$capitalized_name$Value().putAll(values);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" " return this;\n" "}\n"); } @@ -436,26 +446,26 @@ GenerateBuilderMembers(io::Printer* printer) const { " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$" - "public Builder put$capitalized_name$(\n" - " $key_type$ key,\n" - " $value_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " getMutable$capitalized_name$().put(key, value);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$" + "public Builder put$capitalized_name$(\n" + " $key_type$ key,\n" + " $value_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" + " return this;\n" + "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public Builder putAll$capitalized_name$(\n" - " java.util.Map<$type_parameters$> values) {\n" - " getMutable$capitalized_name$().putAll(values);\n" - " return this;\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public Builder putAll$capitalized_name$(\n" + " java.util.Map<$type_parameters$> values) {\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" + " return this;\n" + "}\n"); } } @@ -488,16 +498,13 @@ GenerateMapGetters(io::Printer* printer) const { " return get$capitalized_name$Map();\n" "}\n"); WriteFieldDocComment(printer, descriptor_); - printer->Print( - variables_, - "$deprecation$\n" - "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "get$capitalized_name$Map() {\n" - " return new com.google.protobuf.Internal.MapAdapter<\n" - " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" - " internalGet$capitalized_name$().getMap(),\n" - " $name$ValueConverter);\n" - "}\n"); + printer->Print(variables_, + "$deprecation$\n" + "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" + "get$capitalized_name$Map() {\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGet$capitalized_name$().getMap());" + "}\n"); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, diff --git a/src/google/protobuf/compiler/java/java_map_field.h b/src/google/protobuf/compiler/java/java_map_field.h index ae7ce7c5..47021740 100644 --- a/src/google/protobuf/compiler/java/java_map_field.h +++ b/src/google/protobuf/compiler/java/java_map_field.h @@ -67,7 +67,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; ClassNameResolver* name_resolver_; void GenerateMapGetters(io::Printer* printer) const; }; diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc index 5f102e07..523052cc 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, Context* context, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); ClassNameResolver* name_resolver = context->GetNameResolver(); diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h index 555b5c5b..63dedbc2 100644 --- a/src/google/protobuf/compiler/java/java_map_field_lite.h +++ b/src/google/protobuf/compiler/java/java_map_field_lite.h @@ -66,7 +66,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; ClassNameResolver* name_resolver_; }; diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 68d28b05..df4db463 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -110,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( // the outermost class in the file. This way, they will be initialized in // a deterministic order. - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -154,7 +154,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables( int ImmutableMessageGenerator::GenerateStaticVariableInitializers( io::Printer* printer) { int bytecode_estimate = 0; - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); vars["index"] = SimpleItoa(descriptor_->index()); vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_); @@ -191,7 +191,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers( void ImmutableMessageGenerator:: GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) { - map<string, string> vars; + std::map<string, string> vars; vars["identifier"] = UniqueFileScopeIdentifier(descriptor_); if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) { // We can only make these package-private since the classes that use them @@ -299,7 +299,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { void ImmutableMessageGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); - map<string, string> variables; + std::map<string, string> variables; variables["static"] = is_own_file ? " " : " static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); @@ -409,7 +409,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; @@ -561,13 +561,12 @@ GenerateMessageSerializationMethods(io::Printer* printer) { google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( SortFieldsByNumber(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } std::sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeOrdering()); - printer->Print( "public void writeTo(com.google.protobuf.CodedOutputStream output)\n" " throws java.io.IOException {\n"); @@ -799,7 +798,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()), "identifier", UniqueFileScopeIdentifier(descriptor_)); } - vector<const FieldDescriptor*> map_fields; + std::vector<const FieldDescriptor*> map_fields; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (GetJavaType(field) == JAVATYPE_MESSAGE && @@ -1093,7 +1092,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) { "}\n" "int hash = 41;\n"); - printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + // If we output a getDescriptor() method, use that as it is more efficient. + if (descriptor_->options().no_standard_descriptor_accessor()) { + printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + } else { + printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n"); + } // hashCode non-oneofs. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1254,7 +1258,7 @@ GenerateParsingConstructor(io::Printer* printer) { printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(tag)); + "tag", SimpleItoa(static_cast<int32>(tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCode(printer); @@ -1271,7 +1275,7 @@ GenerateParsingConstructor(io::Printer* printer) { WireFormatLite::WIRETYPE_LENGTH_DELIMITED); printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); + "tag", SimpleItoa(static_cast<int32>(packed_tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCodeFromPacked(printer); @@ -1417,7 +1421,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) { "}\n" "\n" "/**\n" - " * Packs a message uisng the given type URL prefix. The type URL will\n" + " * Packs a message using the given type URL prefix. The type URL will\n" " * be constructed by concatenating the message type's full name to the\n" " * prefix with an optional \"/\" separator if the prefix doesn't end\n" " * with \"/\" already.\n" diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index cd82c51a..f5643abc 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -122,7 +122,7 @@ Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; @@ -225,7 +225,7 @@ GenerateDescriptorMethods(io::Printer* printer) { "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()), "identifier", UniqueFileScopeIdentifier(descriptor_)); } - vector<const FieldDescriptor*> map_fields; + std::vector<const FieldDescriptor*> map_fields; for (int i = 0; i < descriptor_->field_count(); i++) { const FieldDescriptor* field = descriptor_->field(i); if (GetJavaType(field) == JAVATYPE_MESSAGE && diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc index dd429dc9..7e404ba1 100644 --- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc @@ -106,7 +106,7 @@ Generate(io::Printer* printer) { GenerateCommonBuilderMethods(printer); // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { vars["oneof_name"] = context_->GetOneofGeneratorInfo( descriptor_->oneof_decl(i))->name; diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc index c9865dda..ae84db1c 100644 --- a/src/google/protobuf/compiler/java/java_message_field.cc +++ b/src/google/protobuf/compiler/java/java_message_field.cc @@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = diff --git a/src/google/protobuf/compiler/java/java_message_field.h b/src/google/protobuf/compiler/java/java_message_field.h index ea8225a5..7ee0edb2 100644 --- a/src/google/protobuf/compiler/java/java_message_field.h +++ b/src/google/protobuf/compiler/java/java_message_field.h @@ -82,7 +82,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -148,7 +148,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc index cba18360..fd78f75a 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h index 61321547..dbb263de 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.h +++ b/src/google/protobuf/compiler/java/java_message_field_lite.h @@ -81,7 +81,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -139,7 +139,7 @@ class RepeatedImmutableMessageFieldLiteGenerator protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 0c5a1f8a..8cc0f01d 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -170,7 +170,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true); - map<string, string> variables; + std::map<string, string> variables; variables["static"] = is_own_file ? " " : " static "; variables["classname"] = descriptor_->name(); variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_); @@ -236,13 +236,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { } // oneof - map<string, string> vars; + std::map<string, string> vars; for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { - vars["oneof_name"] = context_->GetOneofGeneratorInfo( - descriptor_->oneof_decl(i))->name; + const OneofDescriptor* oneof = descriptor_->oneof_decl(i); + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo( - descriptor_->oneof_decl(i))->capitalized_name; - vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index()); + oneof)->capitalized_name; + vars["oneof_index"] = SimpleItoa(oneof->index()); // oneofCase_ and oneof_ printer->Print(vars, "private int $oneof_name$Case_ = 0;\n" @@ -252,8 +252,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "public enum $oneof_capitalized_name$Case\n" " implements com.google.protobuf.Internal.EnumLite {\n"); printer->Indent(); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); printer->Print( "$field_name$($field_number$),\n", "field_name", @@ -281,8 +281,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { "\n" "public static $oneof_capitalized_name$Case forNumber(int value) {\n" " switch (value) {\n"); - for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) { - const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); + for (int j = 0; j < oneof->field_count(); j++) { + const FieldDescriptor* field = oneof->field(j); printer->Print( " case $field_number$: return $field_name$;\n", "field_number", @@ -467,7 +467,7 @@ GenerateMessageSerializationMethods(io::Printer* printer) { google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields( SortFieldsByNumber(descriptor_)); - vector<const Descriptor::ExtensionRange*> sorted_extensions; + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; for (int i = 0; i < descriptor_->extension_range_count(); ++i) { sorted_extensions.push_back(descriptor_->extension_range(i)); } @@ -523,8 +523,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - printer->Print( - "unknownFields.writeTo(output);\n"); + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "unknownFields.writeAsMessageSetTo(output);\n"); + } else { + printer->Print( + "unknownFields.writeTo(output);\n"); + } } printer->Outdent(); @@ -553,8 +558,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) { } if (PreserveUnknownFields(descriptor_)) { - printer->Print( - "size += unknownFields.getSerializedSize();\n"); + if (descriptor_->options().message_set_wire_format()) { + printer->Print( + "size += unknownFields.getSerializedSizeAsMessageSet();\n"); + } else { + printer->Print( + "size += unknownFields.getSerializedSize();\n"); + } } printer->Outdent(); @@ -939,14 +949,26 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( if (PreserveUnknownFields(descriptor_)) { if (descriptor_->extension_range_count() > 0) { - printer->Print( - "default: {\n" - " if (!parseUnknownField(getDefaultInstanceForType(),\n" - " input, extensionRegistry, tag)) {\n" - " done = true;\n" // it's an endgroup tag - " }\n" - " break;\n" - "}\n"); + 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" @@ -975,7 +997,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(tag)); + "tag", SimpleItoa(static_cast<int32>(tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCode(printer); @@ -992,7 +1014,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( WireFormatLite::WIRETYPE_LENGTH_DELIMITED); printer->Print( "case $tag$: {\n", - "tag", SimpleItoa(packed_tag)); + "tag", SimpleItoa(static_cast<int32>(packed_tag))); printer->Indent(); field_generators_.get(field).GenerateParsingCodeFromPacked(printer); diff --git a/src/google/protobuf/compiler/java/java_name_resolver.h b/src/google/protobuf/compiler/java/java_name_resolver.h index 570d8d8f..28b049d1 100644 --- a/src/google/protobuf/compiler/java/java_name_resolver.h +++ b/src/google/protobuf/compiler/java/java_name_resolver.h @@ -112,7 +112,7 @@ class ClassNameResolver { const FileDescriptor* file, bool immutable); // Caches the result to provide better performance. - map<const FileDescriptor*, string> file_immutable_outer_class_names_; + std::map<const FileDescriptor*, string> file_immutable_outer_class_names_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver); }; diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index 877baf0a..fa1047e8 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor)); @@ -75,7 +75,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, "" : ("= " + ImmutableDefaultValue(descriptor, name_resolver)); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); if (IsReferenceType(GetJavaType(descriptor))) { diff --git a/src/google/protobuf/compiler/java/java_primitive_field.h b/src/google/protobuf/compiler/java/java_primitive_field.h index d0cd12d9..7ac9bbfb 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.h +++ b/src/google/protobuf/compiler/java/java_primitive_field.h @@ -82,7 +82,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -143,7 +143,7 @@ class RepeatedImmutablePrimitiveFieldGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index ad2db30c..ac39f4cf 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); JavaType javaType = GetJavaType(descriptor); (*variables)["type"] = PrimitiveTypeName(javaType); @@ -70,7 +70,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h index 6cfbbb98..dc59f0cf 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h @@ -84,7 +84,7 @@ class ImmutablePrimitiveFieldLiteGenerator protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -146,7 +146,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc index cfa8295d..988e1942 100644 --- a/src/google/protobuf/compiler/java/java_service.cc +++ b/src/google/protobuf/compiler/java/java_service.cc @@ -208,7 +208,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( @@ -255,7 +255,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod( for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName( @@ -301,7 +301,7 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which, for (int i = 0; i < descriptor_->method_count(); i++) { const MethodDescriptor* method = descriptor_->method(i); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["type"] = name_resolver_->GetImmutableClassName( (which == REQUEST) ? method->input_type() : method->output_type()); @@ -353,7 +353,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) { printer->Print(" {\n"); printer->Indent(); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["output"] = GetOutput(method); printer->Print(vars, @@ -417,7 +417,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { printer->Print(" {\n"); printer->Indent(); - map<string, string> vars; + std::map<string, string> vars; vars["index"] = SimpleItoa(i); vars["output"] = GetOutput(method); printer->Print(vars, @@ -440,7 +440,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, const MethodDescriptor* method, IsAbstract is_abstract) { - map<string, string> vars; + std::map<string, string> vars; vars["name"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); vars["output"] = GetOutput(method); @@ -455,7 +455,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer, void ImmutableServiceGenerator::GenerateBlockingMethodSignature( io::Printer* printer, const MethodDescriptor* method) { - map<string, string> vars; + std::map<string, string> vars; vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); vars["output"] = GetOutput(method); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 18bf1f51..5fe68245 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -59,8 +59,8 @@ SharedCodeGenerator::~SharedCodeGenerator() { } void SharedCodeGenerator::Generate(GeneratorContext* context, - vector<string>* file_list, - vector<string>* annotation_file_list) { + std::vector<string>* file_list, + std::vector<string>* annotation_file_list) { string java_package = FileJavaPackage(file_); string package_dir = JavaPackageToDir(java_package); @@ -179,7 +179,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- // Find out all dependencies. - vector<pair<string, string> > dependencies; + std::vector<std::pair<string, string> > dependencies; for (int i = 0; i < file_->dependency_count(); i++) { if (ShouldIncludeDependency(file_->dependency(i))) { string filename = file_->dependency(i)->name(); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h index 7e1e1f17..c8ead47a 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.h +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h @@ -70,8 +70,9 @@ class SharedCodeGenerator { SharedCodeGenerator(const FileDescriptor* file, const Options& options); ~SharedCodeGenerator(); - void Generate(GeneratorContext* generator_context, vector<string>* file_list, - vector<string>* annotation_file_list); + void Generate(GeneratorContext* generator_context, + std::vector<string>* file_list, + std::vector<string>* annotation_file_list); void GenerateDescriptors(io::Printer* printer); diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index ff1865b1..5c2900ce 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY"; @@ -71,7 +71,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); (*variables)["null_check"] = diff --git a/src/google/protobuf/compiler/java/java_string_field.h b/src/google/protobuf/compiler/java/java_string_field.h index a3b57351..0f7c705b 100644 --- a/src/google/protobuf/compiler/java/java_string_field.h +++ b/src/google/protobuf/compiler/java/java_string_field.h @@ -83,7 +83,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -142,7 +142,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator { private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc index 0b92c021..4d2dcad8 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, int builderBitIndex, const FieldGeneratorInfo* info, ClassNameResolver* name_resolver, - map<string, string>* variables) { + std::map<string, string>* variables) { SetCommonFieldVariables(descriptor, info, variables); (*variables)["empty_list"] = @@ -72,7 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); + (*variables)["tag"] = + SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); (*variables)["null_check"] = diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h index 4148aa4d..80496c87 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.h +++ b/src/google/protobuf/compiler/java/java_string_field_lite.h @@ -82,7 +82,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator { protected: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; @@ -140,7 +140,7 @@ class RepeatedImmutableStringFieldLiteGenerator private: const FieldDescriptor* descriptor_; - map<string, string> variables_; + std::map<string, string> variables_; const int messageBitIndex_; const int builderBitIndex_; Context* context_; diff --git a/src/google/protobuf/compiler/js/embed.cc b/src/google/protobuf/compiler/js/embed.cc new file mode 100644 index 00000000..072cccad --- /dev/null +++ b/src/google/protobuf/compiler/js/embed.cc @@ -0,0 +1,111 @@ +// 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. + +#include <cstdlib> +#include <fstream> +#include <iostream> + +const char output_file[] = "well_known_types_embed.cc"; + +static bool AsciiIsPrint(unsigned char c) { + return c >= 32 && c < 127; +} + +static char ToDecimalDigit(int num) { + assert(num < 10); + return '0' + num; +} + +static std::string CEscape(const std::string& str) { + std::string dest; + + for (unsigned char ch : str) { + switch (ch) { + case '\n': dest += "\\n"; break; + case '\r': dest += "\\r"; break; + case '\t': dest += "\\t"; break; + case '\"': dest += "\\\""; break; + case '\\': dest += "\\\\"; break; + default: + if (AsciiIsPrint(ch)) { + dest += ch; + } else { + dest += "\\"; + dest += ToDecimalDigit(ch / 64); + dest += ToDecimalDigit((ch % 64) / 8); + dest += ToDecimalDigit(ch % 8); + } + break; + } + } + + return dest; +} + +static void AddFile(const char* name, std::basic_ostream<char>* out) { + std::ifstream in(name); + + if (!in.is_open()) { + std::cerr << "Couldn't open input file: " << name << "\n"; + std::exit(EXIT_FAILURE); + } + + // Make canonical name only include the final element. + for (const char *p = name; *p; p++) { + if (*p == '/') { + name = p + 1; + } + } + + *out << "{\"" << CEscape(name) << "\",\n"; + + for (std::string line; std::getline(in, line); ) { + *out << " \"" << CEscape(line) << "\\n\"\n"; + } + + *out << "},\n"; +} + +int main(int argc, char *argv[]) { + auto& out = std::cout; + + out << "#include " + "\"google/protobuf/compiler/js/well_known_types_embed.h\"\n"; + out << "struct FileToc well_known_types_js[] = {\n"; + + for (int i = 1; i < argc; i++) { + AddFile(argv[i], &out); + } + + out << " {NULL, NULL} // Terminate the list.\n"; + out << "};\n"; + + return EXIT_SUCCESS; +} diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 47ecc537..e6571f6f 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -45,6 +45,7 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stringprintf.h> +#include <google/protobuf/compiler/js/well_known_types_embed.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/descriptor.pb.h> @@ -216,8 +217,13 @@ string GetNestedMessageName(const Descriptor* descriptor) { if (descriptor == NULL) { return ""; } - return StripPrefixString(descriptor->full_name(), - descriptor->file()->package()); + string result = + StripPrefixString(descriptor->full_name(), descriptor->file()->package()); + // Add a leading dot if one is not already present. + if (!result.empty() && result[0] != '.') { + result = "." + result; + } + return result; } // Returns the path prefix for a message or enumeration that @@ -225,8 +231,8 @@ string GetNestedMessageName(const Descriptor* descriptor) { string GetPrefix(const GeneratorOptions& options, const FileDescriptor* file_descriptor, const Descriptor* containing_type) { - string prefix = GetPath(options, file_descriptor) + - GetNestedMessageName(containing_type); + string prefix = + GetPath(options, file_descriptor) + GetNestedMessageName(containing_type); if (!prefix.empty()) { prefix += "."; } @@ -278,8 +284,8 @@ string MaybeCrossFileRef(const GeneratorOptions& options, // Cross-file ref in CommonJS needs to use the module alias instead of // the global name. return ModuleAlias(to_message->file()->name()) + - GetNestedMessageName(to_message->containing_type()) + - "." + to_message->name(); + GetNestedMessageName(to_message->containing_type()) + "." + + to_message->name(); } else { // Within a single file we use a full name. return GetPath(options, to_message); @@ -309,8 +315,8 @@ char ToLowerASCII(char c) { } } -vector<string> ParseLowerUnderscore(const string& input) { - vector<string> words; +std::vector<string> ParseLowerUnderscore(const string& input) { + std::vector<string> words; string running = ""; for (int i = 0; i < input.size(); i++) { if (input[i] == '_') { @@ -328,8 +334,8 @@ vector<string> ParseLowerUnderscore(const string& input) { return words; } -vector<string> ParseUpperCamel(const string& input) { - vector<string> words; +std::vector<string> ParseUpperCamel(const string& input) { + std::vector<string> words; string running = ""; for (int i = 0; i < input.size(); i++) { if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) { @@ -344,7 +350,7 @@ vector<string> ParseUpperCamel(const string& input) { return words; } -string ToLowerCamel(const vector<string>& words) { +string ToLowerCamel(const std::vector<string>& words) { string result; for (int i = 0; i < words.size(); i++) { string word = words[i]; @@ -358,7 +364,7 @@ string ToLowerCamel(const vector<string>& words) { return result; } -string ToUpperCamel(const vector<string>& words) { +string ToUpperCamel(const std::vector<string>& words) { string result; for (int i = 0; i < words.size(); i++) { string word = words[i]; @@ -927,16 +933,10 @@ string JSTypeName(const GeneratorOptions& options, } } +// Used inside Google only -- do not remove. bool UseBrokenPresenceSemantics(const GeneratorOptions& options, const FieldDescriptor* field) { - if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { - return options.broken_proto3_semantics; - } else if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2) { - return false; - } else { - GOOGLE_LOG(FATAL) << "We can only handle syntax=proto2 and syntax=proto3."; - return false; - } + return false; } // Returns true for fields that return "null" from accessors when they are @@ -1077,22 +1077,14 @@ string JSBinaryReadWriteMethodName(const FieldDescriptor* field, string JSBinaryReaderMethodName(const GeneratorOptions& options, const FieldDescriptor* field) { - if (options.binary) { - return "jspb.BinaryReader.prototype.read" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ false); - } else { - return "null"; - } + return "jspb.BinaryReader.prototype.read" + + JSBinaryReadWriteMethodName(field, /* is_writer = */ false); } string JSBinaryWriterMethodName(const GeneratorOptions& options, const FieldDescriptor* field) { - if (options.binary) { - return "jspb.BinaryWriter.prototype.write" + - JSBinaryReadWriteMethodName(field, /* is_writer = */ true); - } else { - return "null"; - } + return "jspb.BinaryWriter.prototype.write" + + JSBinaryReadWriteMethodName(field, /* is_writer = */ true); } string JSReturnClause(const FieldDescriptor* desc) { @@ -1327,6 +1319,29 @@ bool HasExtensions(const FileDescriptor* file) { return false; } +bool HasMap(const GeneratorOptions& options, const Descriptor* desc) { + for (int i = 0; i < desc->field_count(); i++) { + if (IsMap(options, desc->field(i))) { + return true; + } + } + for (int i = 0; i < desc->nested_type_count(); i++) { + if (HasMap(options, desc->nested_type(i))) { + return true; + } + } + return false; +} + +bool FileHasMap(const GeneratorOptions& options, const FileDescriptor* desc) { + for (int i = 0; i < desc->message_type_count(); i++) { + if (HasMap(options, desc->message_type(i))) { + return true; + } + } + return false; +} + bool IsExtendable(const Descriptor* desc) { return desc->extension_range_count() > 0; } @@ -1398,19 +1413,19 @@ class FileDeduplicator { return true; } - void GetAllowedSet(set<const void*>* allowed_set) { + void GetAllowedSet(std::set<const void*>* allowed_set) { *allowed_set = allowed_descs_; } private: bool error_on_conflict_; - map<string, const void*> descs_by_filename_; - set<const void*> allowed_descs_; + std::map<string, const void*> descs_by_filename_; + std::set<const void*> allowed_descs_; }; void DepthFirstSearch(const FileDescriptor* file, - vector<const FileDescriptor*>* list, - set<const FileDescriptor*>* seen) { + std::vector<const FileDescriptor*>* list, + std::set<const FileDescriptor*>* seen) { if (!seen->insert(file).second) { return; } @@ -1428,7 +1443,7 @@ void DepthFirstSearch(const FileDescriptor* file, // FileDescriptor is not in the given set. class NotInSet { public: - explicit NotInSet(const set<const FileDescriptor*>& file_set) + explicit NotInSet(const std::set<const FileDescriptor*>& file_set) : file_set_(file_set) {} bool operator()(const FileDescriptor* file) { @@ -1436,21 +1451,21 @@ class NotInSet { } private: - const set<const FileDescriptor*>& file_set_; + const std::set<const FileDescriptor*>& file_set_; }; // This function generates an ordering of the input FileDescriptors that matches // the logic of the old code generator. The order is significant because two // different input files can generate the same output file, and the last one // needs to win. -void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input, - vector<const FileDescriptor*>* ordered) { +void GenerateJspbFileOrder(const std::vector<const FileDescriptor*>& input, + std::vector<const FileDescriptor*>* ordered) { // First generate an ordering of all reachable files (including dependencies) // with depth-first search. This mimics the behavior of --include_imports, // which is what the old codegen used. ordered->clear(); - set<const FileDescriptor*> seen; - set<const FileDescriptor*> input_set; + std::set<const FileDescriptor*> seen; + std::set<const FileDescriptor*> input_set; for (int i = 0; i < input.size(); i++) { DepthFirstSearch(input[i], ordered, &seen); input_set.insert(input[i]); @@ -1467,10 +1482,10 @@ void GenerateJspbFileOrder(const vector<const FileDescriptor*>& input, // only those to generate code. bool GenerateJspbAllowedSet(const GeneratorOptions& options, - const vector<const FileDescriptor*>& files, - set<const void*>* allowed_set, + const std::vector<const FileDescriptor*>& files, + std::set<const void*>* allowed_set, string* error) { - vector<const FileDescriptor*> files_ordered; + std::vector<const FileDescriptor*> files_ordered; GenerateJspbFileOrder(files, &files_ordered); // Choose the last descriptor for each filename. @@ -1538,7 +1553,7 @@ void Generator::FindProvidesForFile(const GeneratorOptions& options, void Generator::FindProvides(const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, std::set<string>* provided) const { for (int i = 0; i < files.size(); i++) { FindProvidesForFile(options, printer, files[i], provided); @@ -1580,7 +1595,7 @@ void Generator::FindProvidesForEnum(const GeneratorOptions& options, void Generator::FindProvidesForFields( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const { for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -1629,18 +1644,20 @@ void Generator::GenerateRequiresForMessage(const GeneratorOptions& options, GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ have_message, - /* require_extension = */ HasExtensions(desc)); + /* require_extension = */ HasExtensions(desc), + /* require_map = */ HasMap(options, desc)); } void Generator::GenerateRequiresForLibrary( const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files, + const std::vector<const FileDescriptor*>& files, std::set<string>* provided) const { GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::kImportClosure); // For Closure imports we need to import every message type individually. std::set<string> required; std::set<string> forwards; bool have_extensions = false; + bool have_map = false; bool have_message = false; for (int i = 0; i < files.size(); i++) { @@ -1656,6 +1673,10 @@ void Generator::GenerateRequiresForLibrary( have_extensions = true; } + if (!have_map && FileHasMap(options, files[i])) { + have_map = true; + } + for (int j = 0; j < files[i]->extension_count(); j++) { const FieldDescriptor* extension = files[i]->extension(j); if (IgnoreField(extension)) { @@ -1672,12 +1693,13 @@ void Generator::GenerateRequiresForLibrary( GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ have_message, - /* require_extension = */ have_extensions); + /* require_extension = */ have_extensions, + /* require_map = */ have_map); } void Generator::GenerateRequiresForExtensions( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const { std::set<string> required; std::set<string> forwards; @@ -1691,7 +1713,8 @@ void Generator::GenerateRequiresForExtensions( GenerateRequiresImpl(options, printer, &required, &forwards, provided, /* require_jspb = */ false, - /* require_extension = */ fields.size() > 0); + /* require_extension = */ fields.size() > 0, + /* require_map = */ false); } void Generator::GenerateRequiresImpl(const GeneratorOptions& options, @@ -1699,25 +1722,22 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options, std::set<string>* required, std::set<string>* forwards, std::set<string>* provided, - bool require_jspb, - bool require_extension) const { + bool require_jspb, bool require_extension, + bool require_map) const { if (require_jspb) { printer->Print( - "goog.require('jspb.Message');\n"); - if (options.binary) { - printer->Print( - "goog.require('jspb.BinaryReader');\n" - "goog.require('jspb.BinaryWriter');\n"); - } + "goog.require('jspb.Message');\n" + "goog.require('jspb.BinaryReader');\n" + "goog.require('jspb.BinaryWriter');\n"); } if (require_extension) { - if (options.binary) { - printer->Print( - "goog.require('jspb.ExtensionFieldBinaryInfo');\n"); - } + printer->Print("goog.require('jspb.ExtensionFieldBinaryInfo');\n"); printer->Print( "goog.require('jspb.ExtensionFieldInfo');\n"); } + if (require_map) { + printer->Print("goog.require('jspb.Map');\n"); + } std::set<string>::iterator it; for (it = required->begin(); it != required->end(); ++it) { @@ -1839,14 +1859,13 @@ void Generator::GenerateClass(const GeneratorOptions& options, GenerateClassToObject(options, printer, desc); - if (options.binary) { - // These must come *before* the extension-field info generation in - // GenerateClassRegistration so that references to the binary - // serialization/deserialization functions may be placed in the extension - // objects. - GenerateClassDeserializeBinary(options, printer, desc); - GenerateClassSerializeBinary(options, printer, desc); - } + // These must come *before* the extension-field info generation in + // GenerateClassRegistration so that references to the binary + // serialization/deserialization functions may be placed in the extension + // objects. + GenerateClassDeserializeBinary(options, printer, desc); + GenerateClassSerializeBinary(options, printer, desc); + GenerateClassRegistration(options, printer, desc); GenerateClassFields(options, printer, desc); if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { @@ -2143,8 +2162,20 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, "fieldname", JSObjectFieldName(options, field)); if (IsMap(options, field)) { - printer->Print("(f = msg.get$name$()) ? f.toArray() : []", - "name", JSGetterName(options, field)); + const FieldDescriptor* value_field = MapFieldValue(field); + // If the map values are of a message type, we must provide their static + // toObject() method; otherwise we pass undefined for that argument. + string value_to_object; + if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + value_to_object = + GetPath(options, value_field->message_type()) + ".toObject"; + } else { + value_to_object = "undefined"; + } + printer->Print( + "(f = msg.get$name$()) ? f.toObject(includeInstance, $valuetoobject$) " + ": []", + "name", JSGetterName(options, field), "valuetoobject", value_to_object); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field. if (field->is_repeated()) { @@ -2217,14 +2248,27 @@ void Generator::GenerateClassFieldFromObject( io::Printer* printer, const FieldDescriptor* field) const { if (IsMap(options, field)) { - // `msg` is a newly-constructed message object that has not yet built any - // map containers wrapping underlying arrays, so we can simply directly set - // the array here without fear of a stale wrapper. - printer->Print( - " goog.isDef(obj.$name$) && " - "jspb.Message.setField(msg, $index$, obj.$name$);\n", - "name", JSObjectFieldName(options, field), - "index", JSFieldIndex(field)); + const FieldDescriptor* value_field = MapFieldValue(field); + if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { + // Since the map values are of message type, we have to do some extra work + // to recursively call fromObject() on them before setting the map field. + printer->Print( + " goog.isDef(obj.$name$) && jspb.Message.setWrapperField(\n" + " msg, $index$, jspb.Map.fromObject(obj.$name$, $fieldclass$, " + "$fieldclass$.fromObject));\n", + "name", JSObjectFieldName(options, field), + "index", JSFieldIndex(field), + "fieldclass", GetPath(options, value_field->message_type())); + } else { + // `msg` is a newly-constructed message object that has not yet built any + // map containers wrapping underlying arrays, so we can simply directly + // set the array here without fear of a stale wrapper. + printer->Print( + " goog.isDef(obj.$name$) && " + "jspb.Message.setField(msg, $index$, obj.$name$);\n", + "name", JSObjectFieldName(options, field), + "index", JSFieldIndex(field)); + } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // Message field (singular or repeated) if (field->is_repeated()) { @@ -2358,7 +2402,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print(",\n" " $messageType$", "messageType", GetPath(options, value_field->message_type())); - } else if (options.binary) { + } else { printer->Print(",\n" " null"); } @@ -2711,28 +2755,26 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, "\n", "class", GetPath(options, desc)); - if (options.binary) { - printer->Print( - "\n" - "/**\n" - " * The extensions registered with this message class. This is a " - "map of\n" - " * extension field number to fieldInfo object.\n" - " *\n" - " * For example:\n" - " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " - "ctor: proto.example.MyMessage} }\n" - " *\n" - " * fieldName contains the JsCompiler renamed field name property " - "so that it\n" - " * works in OPTIMIZED mode.\n" - " *\n" - " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" - " */\n" - "$class$.extensionsBinary = {};\n" - "\n", - "class", GetPath(options, desc)); - } + printer->Print( + "\n" + "/**\n" + " * The extensions registered with this message class. This is a " + "map of\n" + " * extension field number to fieldInfo object.\n" + " *\n" + " * For example:\n" + " * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, " + "ctor: proto.example.MyMessage} }\n" + " *\n" + " * fieldName contains the JsCompiler renamed field name property " + "so that it\n" + " * works in OPTIMIZED mode.\n" + " *\n" + " * @type {!Object.<number, jspb.ExtensionFieldBinaryInfo>}\n" + " */\n" + "$class$.extensionsBinary = {};\n" + "\n", + "class", GetPath(options, desc)); } } @@ -2773,7 +2815,9 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options, "class", GetPath(options, desc)); for (int i = 0; i < desc->field_count(); i++) { - GenerateClassDeserializeBinaryField(options, printer, desc->field(i)); + if (!IgnoreField(desc->field(i))) { + GenerateClassDeserializeBinaryField(options, printer, desc->field(i)); + } } printer->Print( @@ -2873,44 +2917,36 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, const Descriptor* desc) const { printer->Print( "/**\n" - " * Class method variant: serializes the given message to binary data\n" - " * (in protobuf wire format), writing to the given BinaryWriter.\n" - " * @param {!$class$} message\n" - " * @param {!jspb.BinaryWriter} writer\n" - " */\n" - "$class$.serializeBinaryToWriter = function(message, " - "writer) {\n" - " message.serializeBinaryToWriter(writer);\n" - "};\n" - "\n" - "\n" - "/**\n" " * Serializes the message to binary data (in protobuf wire format).\n" " * @return {!Uint8Array}\n" " */\n" "$class$.prototype.serializeBinary = function() {\n" " var writer = new jspb.BinaryWriter();\n" - " this.serializeBinaryToWriter(writer);\n" + " $class$.serializeBinaryToWriter(this, writer);\n" " return writer.getResultBuffer();\n" "};\n" "\n" "\n" "/**\n" - " * Serializes the message to binary data (in protobuf wire format),\n" - " * writing to the given BinaryWriter.\n" + " * Serializes the given message to binary data (in protobuf wire\n" + " * format), writing to the given BinaryWriter.\n" + " * @param {!$class$} message\n" " * @param {!jspb.BinaryWriter} writer\n" " */\n" - "$class$.prototype.serializeBinaryToWriter = function (writer) {\n" + "$class$.serializeBinaryToWriter = function(message, " + "writer) {\n" " var f = undefined;\n", "class", GetPath(options, desc)); for (int i = 0; i < desc->field_count(); i++) { - GenerateClassSerializeBinaryField(options, printer, desc->field(i)); + if (!IgnoreField(desc->field(i))) { + GenerateClassSerializeBinaryField(options, printer, desc->field(i)); + } } if (IsExtendable(desc)) { printer->Print( - " jspb.Message.serializeBinaryExtensions(this, writer,\n" + " jspb.Message.serializeBinaryExtensions(message, writer,\n" " $extobj$Binary, $class$.prototype.getExtension);\n", "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", GetPath(options, desc)); @@ -2935,15 +2971,16 @@ void Generator::GenerateClassSerializeBinaryField( /* singular_if_not_packed = */ false, /* bytes_mode = */ BYTES_DEFAULT); printer->Print( - " f = /** @type {$type$} */ (jspb.Message.getField(this, $index$));\n", + " f = /** @type {$type$} */ " + "(jspb.Message.getField(message, $index$));\n", "index", JSFieldIndex(field), "type", typed_annotation); } else { printer->Print( - " f = this.get$name$($nolazy$);\n", + " f = message.get$name$($nolazy$);\n", "name", JSGetterName(options, field, BYTES_U8), // No lazy creation for maps containers -- fastpath the empty case. - "nolazy", (field->is_map()) ? "true" : ""); + "nolazy", IsMap(options, field) ? "true" : ""); } // Print an `if (condition)` statement that evaluates to true if the field @@ -3102,35 +3139,30 @@ void Generator::GenerateExtension(const GeneratorOptions& options, string("null")), "repeated", (field->is_repeated() ? "1" : "0")); - if (options.binary) { - printer->Print( - "\n" - "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" - " $class$.$name$,\n" - " $binaryReaderFn$,\n" - " $binaryWriterFn$,\n" - " $binaryMessageSerializeFn$,\n" - " $binaryMessageDeserializeFn$,\n", - "extendName", JSExtensionsObjectName(options, field->file(), - field->containing_type()), - "index", SimpleItoa(field->number()), - "class", extension_scope, - "name", JSObjectFieldName(options, field), - "binaryReaderFn", JSBinaryReaderMethodName(options, field), - "binaryWriterFn", JSBinaryWriterMethodName(options, field), - "binaryMessageSerializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - (SubmessageTypeRef(options, field) + - ".serializeBinaryToWriter") : "undefined", - "binaryMessageDeserializeFn", - (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ? - (SubmessageTypeRef(options, field) + - ".deserializeBinaryFromReader") : "undefined"); - - printer->Print( - " $isPacked$);\n", - "isPacked", (field->is_packed() ? "true" : "false")); - } + printer->Print( + "\n" + "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" + " $class$.$name$,\n" + " $binaryReaderFn$,\n" + " $binaryWriterFn$,\n" + " $binaryMessageSerializeFn$,\n" + " $binaryMessageDeserializeFn$,\n", + "extendName", + JSExtensionsObjectName(options, field->file(), field->containing_type()), + "index", SimpleItoa(field->number()), "class", extension_scope, "name", + JSObjectFieldName(options, field), "binaryReaderFn", + JSBinaryReaderMethodName(options, field), "binaryWriterFn", + JSBinaryWriterMethodName(options, field), "binaryMessageSerializeFn", + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) + ? (SubmessageTypeRef(options, field) + ".serializeBinaryToWriter") + : "undefined", + "binaryMessageDeserializeFn", + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) + ? (SubmessageTypeRef(options, field) + ".deserializeBinaryFromReader") + : "undefined"); + + printer->Print(" $isPacked$);\n", "isPacked", + (field->is_packed() ? "true" : "false")); printer->Print( "// This registers the extension field with the extended class, so that\n" @@ -3145,7 +3177,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, } bool GeneratorOptions::ParseFromOptions( - const vector< pair< string, string > >& options, + const std::vector< std::pair< string, string > >& options, string* error) { for (int i = 0; i < options.size(); i++) { if (options[i].first == "add_require_for_enums") { @@ -3199,12 +3231,6 @@ bool GeneratorOptions::ParseFromOptions( return false; } one_output_file_per_input_file = true; - } else if (options[i].first == "broken_proto3_semantics") { - if (!options[i].second.empty()) { - *error = "Unexpected option value for broken_proto3_semantics"; - return false; - } - broken_proto3_semantics = true; } else { // Assume any other option is an output directory, as long as it is a bare // `key` rather than a `key=value` option. @@ -3218,13 +3244,12 @@ bool GeneratorOptions::ParseFromOptions( if (import_style != kImportClosure && (add_require_for_enums || testonly || !library.empty() || - error_on_name_conflict || broken_proto3_semantics || - extension != ".js" || one_output_file_per_input_file)) { + error_on_name_conflict || extension != ".js" || + one_output_file_per_input_file)) { *error = "The add_require_for_enums, testonly, library, error_on_name_conflict, " - "broken_proto3_semantics, extension, and " - "one_output_file_per_input_file options should only be used for " - "import_style=closure"; + "extension, and one_output_file_per_input_file options should only be " + "used for import_style=closure"; return false; } @@ -3250,7 +3275,7 @@ GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { void Generator::GenerateFilesInDepOrder( const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& files) const { + const std::vector<const FileDescriptor*>& files) const { // Build a std::set over all files so that the DFS can detect when it recurses // into a dep not specified in the user's command line. std::set<const FileDescriptor*> all_files(files.begin(), files.end()); @@ -3307,8 +3332,8 @@ void Generator::GenerateFile(const GeneratorOptions& options, } } - set<string> provided; - set<const FieldDescriptor*> extensions; + std::set<string> provided; + std::set<const FieldDescriptor*> extensions; for (int i = 0; i < file->extension_count(); i++) { // We honor the jspb::ignore option here only when working with // Closure-style imports. Use of this option is discouraged and so we want @@ -3324,7 +3349,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, FindProvidesForFile(options, printer, file, &provided); GenerateProvides(options, printer, &provided); - vector<const FileDescriptor*> files; + std::vector<const FileDescriptor*> files; files.push_back(file); if (options.import_style == GeneratorOptions::kImportClosure) { GenerateRequiresForLibrary(options, printer, files, &provided); @@ -3334,7 +3359,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, // Generate code for top-level extensions. Extensions nested inside messages // are emitted inside GenerateClassesAndEnums(). - for (set<const FieldDescriptor*>::const_iterator it = extensions.begin(); + for (std::set<const FieldDescriptor*>::const_iterator it = extensions.begin(); it != extensions.end(); ++it) { GenerateExtension(options, printer, *it); } @@ -3343,13 +3368,21 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print("goog.object.extend(exports, $package$);\n", "package", GetPath(options, file)); } + + // Emit well-known type methods. + for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) { + string name = string("google/protobuf/") + toc->name; + if (name == StripProto(file->name()) + ".js") { + printer->Print(toc->data); + } + } } -bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, +bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const { - vector< pair< string, string > > option_pairs; + std::vector< std::pair< string, string > > option_pairs; ParseGeneratorParameter(parameter, &option_pairs); GeneratorOptions options; if (!options.ParseFromOptions(option_pairs, error)) { @@ -3367,7 +3400,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, // Pull out all extensions -- we need these to generate all // provides/requires. - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; for (int i = 0; i < files.size(); i++) { for (int j = 0; j < files[i]->extension_count(); j++) { const FieldDescriptor* extension = files[i]->extension(j); @@ -3396,7 +3429,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, return false; } } else if (options.output_mode() == GeneratorOptions::kOneOutputFilePerType) { - set<const void*> allowed_set; + std::set<const void*> allowed_set; if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) { return false; } @@ -3467,7 +3500,7 @@ bool Generator::GenerateAll(const vector<const FileDescriptor*>& files, GenerateHeader(options, &printer); std::set<string> provided; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; for (int j = 0; j < files[i]->extension_count(); j++) { if (ShouldGenerateExtension(files[i]->extension(j))) { diff --git a/src/google/protobuf/compiler/js/js_generator.h b/src/google/protobuf/compiler/js/js_generator.h index 4ca3493c..6e932d7f 100755 --- a/src/google/protobuf/compiler/js/js_generator.h +++ b/src/google/protobuf/compiler/js/js_generator.h @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Generates JavaScript code for a given .proto file. - +// #ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ #define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__ @@ -78,12 +78,11 @@ struct GeneratorOptions { testonly(false), library(""), error_on_name_conflict(false), - broken_proto3_semantics(false), extension(".js"), one_output_file_per_input_file(false) {} bool ParseFromOptions( - const vector< pair< string, string > >& options, + const std::vector< std::pair< string, string > >& options, string* error); // Returns the file name extension to use for generated code. @@ -115,10 +114,6 @@ struct GeneratorOptions { string library; // Error if there are two types that would generate the same output file? bool error_on_name_conflict; - // Preserve the broken proto3 semantics from the old codegen? This amounts - // to using proto2 field presence semantics even for proto3 files. DO NOT - // USE except for migrating legacy code. - bool broken_proto3_semantics; // The extension to use for output file names. string extension; // Create a separate output file for each input file? @@ -144,7 +139,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { virtual bool HasGenerateAll() const { return true; } - virtual bool GenerateAll(const vector<const FileDescriptor*>& files, + virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, const string& parameter, GeneratorContext* context, string* error) const; @@ -156,7 +151,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // Generate goog.provides() calls. void FindProvides(const GeneratorOptions& options, io::Printer* printer, - const vector<const FileDescriptor*>& file, + const std::vector<const FileDescriptor*>& file, std::set<string>* provided) const; void FindProvidesForFile(const GeneratorOptions& options, io::Printer* printer, @@ -173,7 +168,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // For extension fields at file scope. void FindProvidesForFields(const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const; // Print the goog.provides() found by the methods above. void GenerateProvides(const GeneratorOptions& options, @@ -185,10 +180,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { io::Printer* printer) const; // Generate goog.requires() calls. - void GenerateRequiresForLibrary(const GeneratorOptions& options, - io::Printer* printer, - const vector<const FileDescriptor*>& files, - std::set<string>* provided) const; + void GenerateRequiresForLibrary( + const GeneratorOptions& options, io::Printer* printer, + const std::vector<const FileDescriptor*>& files, + std::set<string>* provided) const; void GenerateRequiresForMessage(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc, @@ -196,15 +191,13 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // For extension fields at file scope. void GenerateRequiresForExtensions( const GeneratorOptions& options, io::Printer* printer, - const vector<const FieldDescriptor*>& fields, + const std::vector<const FieldDescriptor*>& fields, std::set<string>* provided) const; void GenerateRequiresImpl(const GeneratorOptions& options, - io::Printer* printer, - std::set<string>* required, + io::Printer* printer, std::set<string>* required, std::set<string>* forwards, - std::set<string>* provided, - bool require_jspb, - bool require_extension) const; + std::set<string>* provided, bool require_jspb, + bool require_extension, bool require_map) const; void FindRequiresForMessage(const GeneratorOptions& options, const Descriptor* desc, std::set<string>* required, @@ -225,9 +218,9 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { // Generate definitions for all message classes and enums in all files, // processing the files in dependence order. - void GenerateFilesInDepOrder(const GeneratorOptions& options, - io::Printer* printer, - const vector<const FileDescriptor*>& file) const; + void GenerateFilesInDepOrder( + const GeneratorOptions& options, io::Printer* printer, + const std::vector<const FileDescriptor*>& file) const; // Helper for above. void GenerateFileAndDeps(const GeneratorOptions& options, io::Printer* printer, diff --git a/src/google/protobuf/compiler/js/well_known_types/any.js b/src/google/protobuf/compiler/js/well_known_types/any.js new file mode 100644 index 00000000..22f18919 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/any.js @@ -0,0 +1,80 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/any.proto. */ + +/** + * Returns the type name contained in this instance, if any. + * @return {string|undefined} + */ +proto.google.protobuf.Any.prototype.getTypeName = function() { + return this.getTypeUrl().split('/').pop(); +}; + + +/** + * Packs the given message instance into this Any. + * @param {!Uint8Array} serialized The serialized data to pack. + * @param {string} name The type name of this message object. + * @param {string=} opt_typeUrlPrefix the type URL prefix. + */ +proto.google.protobuf.Any.prototype.pack = function(serialized, name, + opt_typeUrlPrefix) { + if (!opt_typeUrlPrefix) { + opt_typeUrlPrefix = 'type.googleapis.com/'; + } + + if (opt_typeUrlPrefix.substr(-1) != '/') { + this.setTypeUrl(opt_typeUrlPrefix + '/' + name); + } else { + this.setTypeUrl(opt_typeUrlPrefix + name); + } + + this.setValue(serialized); +}; + + +/** + * @template T + * Unpacks this Any into the given message object. + * @param {function(Uint8Array):T} deserialize Function that will deserialize + * the binary data properly. + * @param {string} name The expected type name of this message object. + * @return {?T} If the name matched the expected name, returns the deserialized + * object, otherwise returns undefined. + */ +proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) { + if (this.getTypeName() == name) { + return deserialize(this.getValue_asU8()); + } else { + return null; + } +}; diff --git a/src/google/protobuf/compiler/js/well_known_types/struct.js b/src/google/protobuf/compiler/js/well_known_types/struct.js new file mode 100644 index 00000000..30e3d02a --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/struct.js @@ -0,0 +1,168 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/struct.proto. */ + +/** + * Typedef representing plain JavaScript values that can go into a + * Struct. + * @typedef {null|number|string|boolean|Array|Object} + */ +proto.google.protobuf.JavaScriptValue; + + +/** + * Converts this Value object to a plain JavaScript value. + * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript + * value representing this Struct. + */ +proto.google.protobuf.Value.prototype.toJavaScript = function() { + var kindCase = proto.google.protobuf.Value.KindCase; + switch (this.getKindCase()) { + case kindCase.NULL_VALUE: + return null; + case kindCase.NUMBER_VALUE: + return this.getNumberValue(); + case kindCase.STRING_VALUE: + return this.getStringValue(); + case kindCase.BOOL_VALUE: + return this.getBoolValue(); + case kindCase.STRUCT_VALUE: + return this.getStructValue().toJavaScript(); + case kindCase.LIST_VALUE: + return this.getListValue().toJavaScript(); + default: + throw new Error('Unexpected struct type'); + } +}; + + +/** + * Converts this JavaScript value to a new Value proto. + * @param {!proto.google.protobuf.JavaScriptValue} value The value to + * convert. + * @return {!proto.google.protobuf.Value} The newly constructed value. + */ +proto.google.protobuf.Value.fromJavaScript = function(value) { + var ret = new proto.google.protobuf.Value(); + switch (goog.typeOf(value)) { + case 'string': + ret.setStringValue(/** @type {string} */ (value)); + break; + case 'number': + ret.setNumberValue(/** @type {number} */ (value)); + break; + case 'boolean': + ret.setBoolValue(/** @type {boolean} */ (value)); + break; + case 'null': + ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE); + break; + case 'array': + ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript( + /** @type{!Array} */ (value))); + break; + case 'object': + ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript( + /** @type{!Object} */ (value))); + break; + default: + throw new Error('Unexpected struct type.'); + } + + return ret; +}; + + +/** + * Converts this ListValue object to a plain JavaScript array. + * @return {!Array} a plain JavaScript array representing this List. + */ +proto.google.protobuf.ListValue.prototype.toJavaScript = function() { + var ret = []; + var values = this.getValuesList(); + + for (var i = 0; i < values.length; i++) { + ret[i] = values[i].toJavaScript(); + } + + return ret; +}; + + +/** + * Constructs a ListValue protobuf from this plain JavaScript array. + * @param {!Array} array a plain JavaScript array + * @return {proto.google.protobuf.ListValue} a new ListValue object + */ +proto.google.protobuf.ListValue.fromJavaScript = function(array) { + var ret = new proto.google.protobuf.ListValue(); + + for (var i = 0; i < array.length; i++) { + ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i])); + } + + return ret; +}; + + +/** + * Converts this Struct object to a plain JavaScript object. + * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain + * JavaScript object representing this Struct. + */ +proto.google.protobuf.Struct.prototype.toJavaScript = function() { + var ret = {}; + + this.getFieldsMap().forEach(function(value, key) { + ret[key] = value.toJavaScript(); + }); + + return ret; +}; + + +/** + * Constructs a Struct protobuf from this plain JavaScript object. + * @param {!Object} obj a plain JavaScript object + * @return {proto.google.protobuf.Struct} a new Struct object + */ +proto.google.protobuf.Struct.fromJavaScript = function(obj) { + var ret = new proto.google.protobuf.Struct(); + var map = ret.getFieldsMap(); + + for (var property in obj) { + var val = obj[property]; + map.set(property, proto.google.protobuf.Value.fromJavaScript(val)); + } + + return ret; +}; diff --git a/src/google/protobuf/compiler/js/well_known_types/timestamp.js b/src/google/protobuf/compiler/js/well_known_types/timestamp.js new file mode 100644 index 00000000..77c07bb4 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types/timestamp.js @@ -0,0 +1,54 @@ +// 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. + +/* This code will be inserted into generated code for + * google/protobuf/timestamp.proto. */ + +/** + * Returns a JavaScript 'Date' object corresponding to this Timestamp. + * @return {!Date} + */ +proto.google.protobuf.Timestamp.prototype.toDate = function() { + var seconds = this.getSeconds(); + var nanos = this.getNanos(); + + return new Date((seconds * 1000) + (nanos / 1000000)); +}; + + +/** + * Sets the value of this Timestamp object to be the given Date. + * @param {!Date} value The value to set. + */ +proto.google.protobuf.Timestamp.prototype.fromDate = function(value) { + var millis = value.getTime(); + this.setSeconds(Math.floor(value.getTime() / 1000)); + this.setNanos(value.getMilliseconds() * 1000000); +}; diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.cc b/src/google/protobuf/compiler/js/well_known_types_embed.cc new file mode 100755 index 00000000..b589ccb5 --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types_embed.cc @@ -0,0 +1,314 @@ +#include "google/protobuf/compiler/js/well_known_types_embed.h" +struct FileToc well_known_types_js[] = { +{"any.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/any.proto. */\n" + "\n" + "/**\n" + " * Returns the type name contained in this instance, if any.\n" + " * @return {string|undefined}\n" + " */\n" + "proto.google.protobuf.Any.prototype.getTypeName = function() {\n" + " return this.getTypeUrl().split('/').pop();\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Packs the given message instance into this Any.\n" + " * @param {!Uint8Array} serialized The serialized data to pack.\n" + " * @param {string} name The type name of this message object.\n" + " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n" + " */\n" + "proto.google.protobuf.Any.prototype.pack = function(serialized, name,\n" + " opt_typeUrlPrefix) {\n" + " if (!opt_typeUrlPrefix) {\n" + " opt_typeUrlPrefix = 'type.googleapis.com/';\n" + " }\n" + "\n" + " if (opt_typeUrlPrefix.substr(-1) != '/') {\n" + " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n" + " } else {\n" + " this.setTypeUrl(opt_typeUrlPrefix + name);\n" + " }\n" + "\n" + " this.setValue(serialized);\n" + "};\n" + "\n" + "\n" + "/**\n" + " * @template T\n" + " * Unpacks this Any into the given message object.\n" + " * @param {function(Uint8Array):T} deserialize Function that will deserialize\n" + " * the binary data properly.\n" + " * @param {string} name The expected type name of this message object.\n" + " * @return {?T} If the name matched the expected name, returns the deserialized\n" + " * object, otherwise returns undefined.\n" + " */\n" + "proto.google.protobuf.Any.prototype.unpack = function(deserialize, name) {\n" + " if (this.getTypeName() == name) {\n" + " return deserialize(this.getValue_asU8());\n" + " } else {\n" + " return null;\n" + " }\n" + "};\n" +}, +{"timestamp.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/timestamp.proto. */\n" + "\n" + "/**\n" + " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n" + " * @return {!Date}\n" + " */\n" + "proto.google.protobuf.Timestamp.prototype.toDate = function() {\n" + " // The '|| 0' clauses are necessary for as long as\n" + " // broken_proto3_semantics are specified for this rule inside Google.\n" + " var seconds = this.getSeconds() || 0;\n" + " var nanos = this.getNanos() || 0;\n" + "\n" + " return new Date((seconds * 1000) + (nanos / 1000000));\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Sets the value of this Timestamp object to be the given Date.\n" + " * @param {!Date} value The value to set.\n" + " */\n" + "proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {\n" + " var millis = value.getTime();\n" + " this.setSeconds(Math.floor(value.getTime() / 1000));\n" + " this.setNanos(value.getMilliseconds() * 1000000);\n" + "};\n" +}, +{"struct.js", + "// Protocol Buffers - Google's data interchange format\n" + "// Copyright 2008 Google Inc. All rights reserved.\n" + "// https://developers.google.com/protocol-buffers/\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the names of its\n" + "// contributors may be used to endorse or promote products derived from\n" + "// this software without specific prior written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + "// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "\n" + "/* This code will be inserted into generated code for\n" + " * google/protobuf/struct.proto. */\n" + "\n" + "/**\n" + " * Typedef representing plain JavaScript values that can go into a\n" + " * Struct.\n" + " * @typedef {null|number|string|boolean|Array|Object}\n" + " */\n" + "proto.google.protobuf.JavaScriptValue;\n" + "\n" + "\n" + "/**\n" + " * Converts this Value object to a plain JavaScript value.\n" + " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n" + " * value representing this Struct.\n" + " */\n" + "proto.google.protobuf.Value.prototype.toJavaScript = function() {\n" + " var kindCase = proto.google.protobuf.Value.KindCase;\n" + " switch (this.getKindCase()) {\n" + " case kindCase.NULL_VALUE:\n" + " return null;\n" + " case kindCase.NUMBER_VALUE:\n" + " return this.getNumberValue();\n" + " case kindCase.STRING_VALUE:\n" + " return this.getStringValue();\n" + " case kindCase.BOOL_VALUE:\n" + " return this.getBoolValue();\n" + " case kindCase.STRUCT_VALUE:\n" + " return this.getStructValue().toJavaScript();\n" + " case kindCase.LIST_VALUE:\n" + " return this.getListValue().toJavaScript();\n" + " default:\n" + " throw new Error('Unexpected struct type');\n" + " }\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this JavaScript value to a new Value proto.\n" + " * @param {!proto.google.protobuf.JavaScriptValue} value The value to\n" + " * convert.\n" + " * @return {!proto.google.protobuf.Value} The newly constructed value.\n" + " */\n" + "proto.google.protobuf.Value.fromJavaScript = function(value) {\n" + " var ret = new proto.google.protobuf.Value();\n" + " switch (goog.typeOf(value)) {\n" + " case 'string':\n" + " ret.setStringValue(/** @type {string} */ (value));\n" + " break;\n" + " case 'number':\n" + " ret.setNumberValue(/** @type {number} */ (value));\n" + " break;\n" + " case 'boolean':\n" + " ret.setBoolValue(/** @type {boolean} */ (value));\n" + " break;\n" + " case 'null':\n" + " ret.setNullValue(proto.google.protobuf.NullValue.NULL_VALUE);\n" + " break;\n" + " case 'array':\n" + " ret.setListValue(proto.google.protobuf.ListValue.fromJavaScript(\n" + " /** @type{!Array} */ (value)));\n" + " break;\n" + " case 'object':\n" + " ret.setStructValue(proto.google.protobuf.Struct.fromJavaScript(\n" + " /** @type{!Object} */ (value)));\n" + " break;\n" + " default:\n" + " throw new Error('Unexpected struct type.');\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this ListValue object to a plain JavaScript array.\n" + " * @return {!Array} a plain JavaScript array representing this List.\n" + " */\n" + "proto.google.protobuf.ListValue.prototype.toJavaScript = function() {\n" + " var ret = [];\n" + " var values = this.getValuesList();\n" + "\n" + " for (var i = 0; i < values.length; i++) {\n" + " ret[i] = values[i].toJavaScript();\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a ListValue protobuf from this plain JavaScript array.\n" + " * @param {!Array} array a plain JavaScript array\n" + " * @return {proto.google.protobuf.ListValue} a new ListValue object\n" + " */\n" + "proto.google.protobuf.ListValue.fromJavaScript = function(array) {\n" + " var ret = new proto.google.protobuf.ListValue();\n" + "\n" + " for (var i = 0; i < array.length; i++) {\n" + " ret.addValues(proto.google.protobuf.Value.fromJavaScript(array[i]));\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this Struct object to a plain JavaScript object.\n" + " * @return {!Object<string, !proto.google.protobuf.JavaScriptValue>} a plain\n" + " * JavaScript object representing this Struct.\n" + " */\n" + "proto.google.protobuf.Struct.prototype.toJavaScript = function() {\n" + " var ret = {};\n" + "\n" + " this.getFieldsMap().forEach(function(value, key) {\n" + " ret[key] = value.toJavaScript();\n" + " });\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a Struct protobuf from this plain JavaScript object.\n" + " * @param {!Object} obj a plain JavaScript object\n" + " * @return {proto.google.protobuf.Struct} a new Struct object\n" + " */\n" + "proto.google.protobuf.Struct.fromJavaScript = function(obj) {\n" + " var ret = new proto.google.protobuf.Struct();\n" + " var map = ret.getFieldsMap();\n" + "\n" + " for (var property in obj) {\n" + " var val = obj[property];\n" + " map.set(property, proto.google.protobuf.Value.fromJavaScript(val));\n" + " }\n" + "\n" + " return ret;\n" + "};\n" +}, + {NULL, NULL} // Terminate the list. +}; diff --git a/src/google/protobuf/compiler/js/well_known_types_embed.h b/src/google/protobuf/compiler/js/well_known_types_embed.h new file mode 100644 index 00000000..174c665e --- /dev/null +++ b/src/google/protobuf/compiler/js/well_known_types_embed.h @@ -0,0 +1,43 @@ +// 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. + +#ifndef GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ +#define GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ + +#include <stddef.h> + +struct FileToc { + const char* name; + const char* data; +}; + +extern struct FileToc well_known_types_js[]; + +#endif // GOOGLE_PROTOBUF_COMPILER_JS_WELL_KNOWN_TYPES_EMBED_H__ diff --git a/src/google/protobuf/compiler/main.cc b/src/google/protobuf/compiler/main.cc index aca2a5b9..680d6428 100644 --- a/src/google/protobuf/compiler/main.cc +++ b/src/google/protobuf/compiler/main.cc @@ -39,12 +39,12 @@ #endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP #ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP +#include <google/protobuf/compiler/csharp/csharp_generator.h> #include <google/protobuf/compiler/javanano/javanano_generator.h> +#include <google/protobuf/compiler/js/js_generator.h> +#include <google/protobuf/compiler/objectivec/objectivec_generator.h> #include <google/protobuf/compiler/php/php_generator.h> #include <google/protobuf/compiler/ruby/ruby_generator.h> -#include <google/protobuf/compiler/csharp/csharp_generator.h> -#include <google/protobuf/compiler/objectivec/objectivec_generator.h> -#include <google/protobuf/compiler/js/js_generator.h> #endif // ! OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP int main(int argc, char* argv[]) { @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) { #ifndef OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP // Proto2 Java google::protobuf::compiler::java::JavaGenerator java_generator; - cli.RegisterGenerator("--java_out", &java_generator, + cli.RegisterGenerator("--java_out", "--java_opt", &java_generator, "Generate Java source file."); #endif // !OPENSOURCE_PROTOBUF_CPP_BOOTSTRAP diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index 1cc932dd..e82e6ae1 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -40,6 +40,7 @@ #endif #include <vector> +#include <google/protobuf/compiler/plugin.pb.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/testing/file.h> @@ -59,8 +60,8 @@ namespace compiler { // Returns the list of the names of files in all_files in the form of a // comma-separated string. -string CommaSeparatedList(const vector<const FileDescriptor*> all_files) { - vector<string> names; +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()); } @@ -92,7 +93,8 @@ void MockCodeGenerator::ExpectGenerated( File::GetContents(output_directory + "/" + GetOutputFileName(name, file), &content, true)); - vector<string> lines = Split(content, "\n", true); + std::vector<string> lines = + Split(content, "\n", true); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); @@ -101,7 +103,7 @@ void MockCodeGenerator::ExpectGenerated( lines[i] += "\n"; } - vector<string> insertion_list; + std::vector<string> insertion_list; if (!insertions.empty()) { SplitStringUsing(insertions, ",", &insertion_list); } @@ -159,6 +161,15 @@ bool MockCodeGenerator::Generate( std::cerr << "Saw json_name: " << field_descriptor_proto.has_json_name() << std::endl; abort(); + } else if (command == "ShowVersionNumber") { + Version compiler_version; + context->GetCompilerVersion(&compiler_version); + std::cerr << "Saw compiler_version: " + << compiler_version.major() * 1000000 + + compiler_version.minor() * 1000 + + compiler_version.patch() + << " " << compiler_version.suffix() << std::endl; + abort(); } else { GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command; } @@ -166,7 +177,7 @@ bool MockCodeGenerator::Generate( } if (HasPrefixString(parameter, "insert=")) { - vector<string> insert_into; + std::vector<string> insert_into; SplitStringUsing(StripPrefixString(parameter, "insert="), ",", &insert_into); @@ -230,7 +241,7 @@ string MockCodeGenerator::GetOutputFileContent( const string& parameter, const FileDescriptor* file, GeneratorContext *context) { - vector<const FileDescriptor*> all_files; + std::vector<const FileDescriptor*> all_files; context->ListParsedFiles(&all_files); return GetOutputFileContent( generator_name, parameter, file->name(), diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 34e17823..02d60b3e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -74,7 +74,7 @@ void EnumGenerator::GenerateHeader(io::Printer* printer) { printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n", "comments", enum_comments, - "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_), + "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()), "name", name_); printer->Indent(); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index d0de1eca..7073173c 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -67,9 +67,12 @@ void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { } else { vars["comments"] = ""; } + // Unlike normal message fields, check if the file for the extension was + // deprecated. + vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, descriptor_->file()); printer->Print(vars, "$comments$" - "+ (GPBExtensionDescriptor *)$method_name$;\n"); + "+ (GPBExtensionDescriptor *)$method_name$$deprecated_attribute$;\n"); } void ExtensionGenerator::GenerateStaticVariablesInitialization( diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 316069e1..a2179446 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -150,8 +150,18 @@ enum FlagType { }; template<class TDescriptor> -string GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpace = true, bool postNewline = false) { - if (descriptor->options().deprecated()) { +string GetOptionalDeprecatedAttribute( + const TDescriptor* descriptor, + const FileDescriptor* file = NULL, + bool preSpace = true, bool postNewline = false) { + bool isDeprecated = descriptor->options().deprecated(); + // The file is only passed when checking Messages & Enums, so those types + // get tagged. At the moment, it doesn't seem to make sense to tag every + // field or enum value with when the file is deprecated. + if (!isDeprecated && file) { + isDeprecated = file->options().deprecated(); + } + if (isDeprecated) { string result = "DEPRECATED_ATTRIBUTE"; if (preSpace) { result.insert(0, " "); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index 4c6e1b55..e0bd3dac 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -180,7 +180,10 @@ MessageGenerator::MessageGenerator(const string& root_classname, : root_classname_(root_classname), descriptor_(descriptor), field_generators_(descriptor, options), - class_name_(ClassName(descriptor_)) { + class_name_(ClassName(descriptor_)), + deprecated_attribute_( + GetOptionalDeprecatedAttribute(descriptor, descriptor->file(), false, true)) { + for (int i = 0; i < descriptor_->extension_count(); i++) { extension_generators_.push_back( new ExtensionGenerator(class_name_, descriptor_->extension(i))); @@ -339,7 +342,7 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) { printer->Print( "$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\n\n", "classname", class_name_, - "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, false, true), + "deprecated_attribute", deprecated_attribute_, "comments", message_comments); vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0); @@ -396,6 +399,14 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "\n", "classname", class_name_); + if (!deprecated_attribute_.empty()) { + // No warnings when compiling the impl of this deprecated class. + printer->Print( + "#pragma clang diagnostic push\n" + "#pragma clang diagnostic ignored \"-Wdeprecated-implementations\"\n" + "\n"); + } + printer->Print("@implementation $classname$\n\n", "classname", class_name_); @@ -601,6 +612,12 @@ void MessageGenerator::GenerateSource(io::Printer* printer) { "}\n\n" "@end\n\n"); + if (!deprecated_attribute_.empty()) { + printer->Print( + "#pragma clang diagnostic pop\n" + "\n"); + } + for (int i = 0; i < descriptor_->field_count(); i++) { field_generators_.get(descriptor_->field(i)) .GenerateCFunctionImplementations(printer); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h index 910535ac..0fb78bc0 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h @@ -85,6 +85,7 @@ class MessageGenerator { const Descriptor* descriptor_; FieldGeneratorMap field_generators_; const string class_name_; + const string deprecated_attribute_; vector<ExtensionGenerator*> extension_generators_; vector<EnumGenerator*> enum_generators_; vector<MessageGenerator*> nested_message_generators_; diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index 0f80e78b..dd8b6586 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -257,7 +257,7 @@ class LIBPROTOBUF_EXPORT Parser { // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for // why this is const. void AttachComments(string* leading, string* trailing, - vector<string>* detached_comments) const; + std::vector<string>* detached_comments) const; private: // Indexes of parent and current location in the parent @@ -520,7 +520,7 @@ class LIBPROTOBUF_EXPORT Parser { // detached comments will be put into the leading_detached_comments field for // the next element (See SourceCodeInfo.Location in descriptor.proto), when // ConsumeEndOfDeclaration() is called. - vector<string> upcoming_detached_comments_; + std::vector<string> upcoming_detached_comments_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser); }; @@ -556,9 +556,9 @@ class LIBPROTOBUF_EXPORT SourceLocationTable { void Clear(); private: - typedef map< - pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, - pair<int, int> > LocationMap; + typedef std::map< + std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>, + std::pair<int, int> > LocationMap; LocationMap location_map_; }; diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 1d623dd9..20140f8e 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -2218,7 +2218,7 @@ class SourceInfoTest : public ParserTest { const char* expected_leading_comments, const char* expected_trailing_comments, const char* expected_leading_detached_comments) { - pair<SpanMap::iterator, SpanMap::iterator> range = + std::pair<SpanMap::iterator, SpanMap::iterator> range = spans_.equal_range(SpanKey(descriptor_proto, field, index)); if (start_marker == '\0') { @@ -2229,8 +2229,8 @@ class SourceInfoTest : public ParserTest { return true; } } else { - pair<int, int> start_pos = FindOrDie(markers_, start_marker); - pair<int, int> end_pos = FindOrDie(markers_, end_marker); + std::pair<int, int> start_pos = FindOrDie(markers_, start_marker); + std::pair<int, int> end_pos = FindOrDie(markers_, end_marker); RepeatedField<int> expected_span; expected_span.Add(start_pos.first); @@ -2295,9 +2295,9 @@ class SourceInfoTest : public ParserTest { } }; - typedef multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap; + typedef std::multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap; SpanMap spans_; - map<char, pair<int, int> > markers_; + std::map<char, std::pair<int, int> > markers_; string text_without_markers_; void ExtractMarkers(const char* text) { diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 83e629b9..6634680d 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -43,6 +43,11 @@ using google::protobuf::internal::scoped_ptr; const std::string kDescriptorFile = "google/protobuf/descriptor.proto"; +const std::string kEmptyFile = "google/protobuf/empty.proto"; +const std::string kEmptyMetadataFile = "GPBMetadata/Google/Protobuf/GPBEmpty.php"; +const std::string kDescriptorMetadataFile = + "GPBMetadata/Google/Protobuf/Internal/Descriptor.php"; +const std::string kDescriptorDirName = "Google/Protobuf/Internal"; const std::string kDescriptorPackageName = "Google\\Protobuf\\Internal"; namespace google { @@ -52,25 +57,34 @@ namespace php { // Forward decls. std::string PhpName(const std::string& full_name, bool is_descriptor); -std::string DefaultForField(google::protobuf::FieldDescriptor* field); +std::string DefaultForField(FieldDescriptor* field); std::string IntToString(int32 value); -std::string GeneratedFileName(const std::string& proto_file, - bool is_descriptor); -std::string LabelForField(google::protobuf::FieldDescriptor* field); -std::string TypeName(google::protobuf::FieldDescriptor* field); +std::string FilenameToClassname(const string& filename); +std::string GeneratedMetadataFileName(const std::string& proto_file, + bool is_descriptor); +std::string LabelForField(FieldDescriptor* field); +std::string TypeName(FieldDescriptor* field); std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter); std::string EscapeDollor(const string& to_escape); std::string BinaryToHex(const string& binary); -void GenerateMessage(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer); -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer); -void Indent(google::protobuf::io::Printer* printer); -void Outdent(google::protobuf::io::Printer* printer); - -std::string MessagePrefix(const google::protobuf::Descriptor* message) { +void Indent(io::Printer* printer); +void Outdent(io::Printer* printer); +void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message); +void GenerateFieldDocComment(io::Printer* printer, + const FieldDescriptor* field); +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); +void GenerateEnumValueDocComment(io::Printer* printer, + const EnumValueDescriptor* value); + +std::string RenameEmpty(const std::string& name) { + if (name == "Empty") { + return "GPBEmpty"; + } else { + return name; + } +} + +std::string MessagePrefix(const Descriptor* message) { // Empty cannot be php class name. if (message->name() == "Empty" && message->file()->package() == "google.protobuf") { @@ -80,10 +94,9 @@ std::string MessagePrefix(const google::protobuf::Descriptor* message) { } } -std::string MessageName(const google::protobuf::Descriptor* message, - bool is_descriptor) { +std::string MessageName(const Descriptor* message, bool is_descriptor) { string message_name = message->name(); - const google::protobuf::Descriptor* descriptor = message->containing_type(); + const Descriptor* descriptor = message->containing_type(); while (descriptor != NULL) { message_name = descriptor->name() + '_' + message_name; descriptor = descriptor->containing_type(); @@ -94,8 +107,7 @@ std::string MessageName(const google::protobuf::Descriptor* message, message_name; } -std::string MessageFullName(const google::protobuf::Descriptor* message, - bool is_descriptor) { +std::string MessageFullName(const Descriptor* message, bool is_descriptor) { if (is_descriptor) { return StringReplace(message->full_name(), "google.protobuf", @@ -105,8 +117,7 @@ std::string MessageFullName(const google::protobuf::Descriptor* message, } } -std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, - bool is_descriptor) { +std::string EnumFullName(const EnumDescriptor* envm, bool is_descriptor) { if (is_descriptor) { return StringReplace(envm->full_name(), "google.protobuf", @@ -116,9 +127,9 @@ std::string EnumFullName(const google::protobuf::EnumDescriptor* envm, } } -std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { +std::string EnumClassName(const EnumDescriptor* envm) { string enum_class_name = envm->name(); - const google::protobuf::Descriptor* descriptor = envm->containing_type(); + const Descriptor* descriptor = envm->containing_type(); while (descriptor != NULL) { enum_class_name = descriptor->name() + '_' + enum_class_name; descriptor = descriptor->containing_type(); @@ -126,8 +137,7 @@ std::string EnumClassName(const google::protobuf::EnumDescriptor* envm) { return enum_class_name; } -std::string EnumName(const google::protobuf::EnumDescriptor* envm, - bool is_descriptor) { +std::string EnumName(const EnumDescriptor* envm, bool is_descriptor) { string enum_name = EnumClassName(envm); return PhpName(envm->file()->package(), is_descriptor) + '\\' + enum_name; } @@ -154,7 +164,7 @@ std::string PhpName(const std::string& full_name, bool is_descriptor) { return result; } -std::string DefaultForField(const google::protobuf::FieldDescriptor* field) { +std::string DefaultForField(const FieldDescriptor* field) { switch (field->type()) { case FieldDescriptor::TYPE_INT32: case FieldDescriptor::TYPE_INT64: @@ -178,14 +188,66 @@ std::string DefaultForField(const google::protobuf::FieldDescriptor* field) { } } -std::string GeneratedFileName(const std::string& proto_file, - bool is_descriptor) { +std::string GeneratedMetadataFileName(const std::string& proto_file, + bool is_descriptor) { + int start_index = 0; + int first_index = proto_file.find_first_of("/", start_index); + std::string result = "GPBMetadata/"; + + if (proto_file == kEmptyFile) { + return kEmptyMetadataFile; + } if (is_descriptor) { - return "descriptor_internal.pb.php"; + return kDescriptorMetadataFile; + } + + // Append directory name. + std::string file_no_suffix; + int lastindex = proto_file.find_last_of("."); + if (proto_file == kEmptyFile) { + return kEmptyMetadataFile; } else { - int lastindex = proto_file.find_last_of("."); - return proto_file.substr(0, lastindex) + ".pb.php"; + file_no_suffix = proto_file.substr(0, lastindex); + } + + while (first_index != string::npos) { + result += UnderscoresToCamelCase( + file_no_suffix.substr(start_index, first_index - start_index), true); + result += "/"; + GOOGLE_LOG(INFO) << start_index << " " << first_index; + GOOGLE_LOG(INFO) << file_no_suffix.substr(start_index, + first_index - start_index); + start_index = first_index + 1; + first_index = file_no_suffix.find_first_of("/", start_index); } + + // Append file name. + result += RenameEmpty(UnderscoresToCamelCase( + file_no_suffix.substr(start_index, first_index - start_index), true)); + + return result += ".php"; +} + +std::string GeneratedMessageFileName(const Descriptor* message, + bool is_descriptor) { + std::string result = MessageName(message, is_descriptor); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } + } + return result + ".php"; +} + +std::string GeneratedEnumFileName(const EnumDescriptor* en, + bool is_descriptor) { + std::string result = EnumName(en, is_descriptor); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '\\') { + result[i] = '/'; + } + } + return result + ".php"; } std::string IntToString(int32 value) { @@ -194,7 +256,7 @@ std::string IntToString(int32 value) { return os.str(); } -std::string LabelForField(const google::protobuf::FieldDescriptor* field) { +std::string LabelForField(const FieldDescriptor* field) { switch (field->label()) { case FieldDescriptor::LABEL_OPTIONAL: return "optional"; case FieldDescriptor::LABEL_REQUIRED: return "required"; @@ -203,7 +265,7 @@ std::string LabelForField(const google::protobuf::FieldDescriptor* field) { } } -std::string TypeName(const google::protobuf::FieldDescriptor* field) { +std::string TypeName(const FieldDescriptor* field) { switch (field->type()) { case FieldDescriptor::TYPE_INT32: return "int32"; case FieldDescriptor::TYPE_INT64: return "int64"; @@ -228,7 +290,7 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) { } std::string EnumOrMessageSuffix( - const google::protobuf::FieldDescriptor* field, bool is_descriptor) { + const FieldDescriptor* field, bool is_descriptor) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { return ", '" + MessageFullName(field->message_type(), is_descriptor) + "'"; } @@ -299,74 +361,77 @@ std::string BinaryToHex(const string& src) { return dest; } -void Indent(google::protobuf::io::Printer* printer) { +void Indent(io::Printer* printer) { printer->Indent(); printer->Indent(); } -void Outdent(google::protobuf::io::Printer* printer) { +void Outdent(io::Printer* printer) { printer->Outdent(); printer->Outdent(); } -void GenerateField(const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer, bool is_descriptor) { +void GenerateField(const FieldDescriptor* field, io::Printer* printer, + bool is_descriptor) { if (field->is_repeated()) { + GenerateFieldDocComment(printer, field); printer->Print( - "private $@name@;\n", + "private $^name^;\n", "name", field->name()); } else if (field->containing_oneof()) { // Oneof fields are handled by GenerateOneofField. return; } else { + GenerateFieldDocComment(printer, field); printer->Print( - "private $@name@ = @default@;\n", + "private $^name^ = ^default^;\n", "name", field->name(), "default", DefaultForField(field)); } if (is_descriptor) { printer->Print( - "private $has_@name@ = false;\n", + "private $has_^name^ = false;\n", "name", field->name()); } } -void GenerateOneofField(const google::protobuf::OneofDescriptor* oneof, - google::protobuf::io::Printer* printer) { +void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) { // Oneof property needs to be protected in order to be accessed by parent // class in implementation. printer->Print( - "protected $@name@;\n", + "protected $^name^;\n", "name", oneof->name()); } -void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, - bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor, + io::Printer* printer) { const OneofDescriptor* oneof = field->containing_oneof(); // Generate getter. if (oneof != NULL) { + GenerateFieldDocComment(printer, field); printer->Print( - "public function get@camel_name@()\n" + "public function get^camel_name^()\n" "{\n" - " return $this->readOneof(@number@);\n" + " return $this->readOneof(^number^);\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "number", IntToString(field->number())); } else { + GenerateFieldDocComment(printer, field); printer->Print( - "public function get@camel_name@()\n" + "public function get^camel_name^()\n" "{\n" - " return $this->@name@;\n" + " return $this->^name^;\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "name", field->name()); } // Generate setter. + GenerateFieldDocComment(printer, field); printer->Print( - "public function set@camel_name@(@var@)\n" + "public function set^camel_name^(^var^)\n" "{\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "var", (field->is_repeated() || @@ -379,16 +444,17 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, if (field->is_map()) { } else if (field->is_repeated()) { printer->Print( - "GPBUtil::checkRepeatedField($var, GPBType::@type@", + "GPBUtil::checkRepeatedField($var, " + "\\Google\\Protobuf\\Internal\\GPBType::^type^", "type", ToUpper(field->type_name())); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print( - ", \\@class_name@);\n", + ", \\^class_name^);\n", "class_name", MessageName(field->message_type(), is_descriptor) + "::class"); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( - ", @class_name@);\n", + ", ^class_name^);\n", "class_name", EnumName(field->enum_type(), is_descriptor) + "::class"); } else { @@ -396,37 +462,37 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { printer->Print( - "GPBUtil::checkMessage($var, \\@class_name@::class);\n", + "GPBUtil::checkMessage($var, \\^class_name^::class);\n", "class_name", MessageName(field->message_type(), is_descriptor)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) { printer->Print( - "GPBUtil::checkEnum($var, \\@class_name@::class);\n", + "GPBUtil::checkEnum($var, \\^class_name^::class);\n", "class_name", EnumName(field->enum_type(), is_descriptor)); } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { printer->Print( - "GPBUtil::checkString($var, @utf8@);\n", + "GPBUtil::checkString($var, ^utf8^);\n", "utf8", field->type() == FieldDescriptor::TYPE_STRING ? "True": "False"); } else { printer->Print( - "GPBUtil::check@type@($var);\n", + "GPBUtil::check^type^($var);\n", "type", UnderscoresToCamelCase(field->cpp_type_name(), true)); } if (oneof != NULL) { printer->Print( - "$this->writeOneof(@number@, $var);\n", + "$this->writeOneof(^number^, $var);\n", "number", IntToString(field->number())); } else { printer->Print( - "$this->@name@ = $var;\n", + "$this->^name^ = $var;\n", "name", field->name()); } // Set has bit for proto2 only. if (is_descriptor) { printer->Print( - "$this->has_@field_name@ = true;\n", + "$this->has_^field_name^ = true;\n", "field_name", field->name()); } @@ -438,127 +504,27 @@ void GenerateFieldAccessor(const google::protobuf::FieldDescriptor* field, // Generate has method for proto2 only. if (is_descriptor) { printer->Print( - "public function has@camel_name@()\n" + "public function has^camel_name^()\n" "{\n" - " return $this->has_@field_name@;\n" + " return $this->has_^field_name^;\n" "}\n\n", "camel_name", UnderscoresToCamelCase(field->name(), true), "field_name", field->name()); } } -void GenerateRepeatedFieldDecode( - const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "if ($input->read@cap_wire_type@($var)) return False;\n" - "$this->get@cap_field_name@() []= $var;\n", - "cap_field_name", UnderscoresToCamelCase(field->name(), true), - "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); -} - -void GeneratePrimitiveFieldDecode( - const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "if ($input->read@cap_wire_type@($var)) return False;\n" - "$this->set@cap_field_name@($var);\n", - "cap_field_name", UnderscoresToCamelCase(field->name(), true), - "cap_wire_type", UnderscoresToCamelCase(field->type_name(), true)); -} - -void GenerateFieldDecode(const google::protobuf::FieldDescriptor* field, - google::protobuf::io::Printer* printer) { - printer->Print( - "case @number@:\n", - "number", IntToString(field->number())); - Indent(printer); - - if (field->is_repeated()) { - GenerateRepeatedFieldDecode(field, printer); - } else { - GeneratePrimitiveFieldDecode(field, printer); - } - - printer->Print( - "break;\n"); - Outdent(printer); -} - -void GenerateMessage(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer) { - // Don't generate MapEntry messages -- we use the PHP extension's native - // support for map fields instead. - if (message->options().map_entry()) { - return; - } - - string message_name = - name_prefix.empty() - ? message->name() - : name_prefix + "_" + MessagePrefix(message) + message->name(); - - printer->Print( - "class @name@ extends \\Google\\Protobuf\\Internal\\Message\n" - "{\n", - "name", message_name); - Indent(printer); - - // Field and oneof definitions. - for (int i = 0; i < message->field_count(); i++) { - const FieldDescriptor* field = message->field(i); - GenerateField(field, printer, is_descriptor); - } - for (int i = 0; i < message->oneof_decl_count(); i++) { - const OneofDescriptor* oneof = message->oneof_decl(i); - GenerateOneofField(oneof, printer); - } - printer->Print("\n"); - - // Field and oneof accessors. - for (int i = 0; i < message->field_count(); i++) { - const FieldDescriptor* field = message->field(i); - GenerateFieldAccessor(field, is_descriptor, printer); - } - for (int i = 0; i < message->oneof_decl_count(); i++) { - const google::protobuf::OneofDescriptor* oneof = message->oneof_decl(i); - printer->Print( - "public function get@camel_name@()\n" - "{\n" - " return $this->@name@;\n" - "}\n\n", - "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name", - oneof->name()); - } - - Outdent(printer); - printer->Print("}\n\n"); - - // Nested messages and enums. - for (int i = 0; i < message->nested_type_count(); i++) { - GenerateMessage(message_name, message->nested_type(i), is_descriptor, - printer); - } - for (int i = 0; i < message->enum_type_count(); i++) { - GenerateEnum(message->enum_type(i), printer); - } -} - -void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, - bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateEnumToPool(const EnumDescriptor* en, io::Printer* printer) { printer->Print( - "$pool->addEnum('@name@', @class_name@::class)\n", - "name", EnumFullName(en, is_descriptor), + "$pool->addEnum('^name^', " + "\\Google\\Protobuf\\Internal\\^class_name^::class)\n", + "name", EnumFullName(en, true), "class_name", en->name()); Indent(printer); for (int i = 0; i < en->value_count(); i++) { const EnumValueDescriptor* value = en->value(i); printer->Print( - "->value(\"@name@\", @number@)\n", + "->value(\"^name^\", ^number^)\n", "name", value->name(), "number", IntToString(value->number())); } @@ -566,10 +532,8 @@ void GenerateEnumToPool(const google::protobuf::EnumDescriptor* en, Outdent(printer); } -void GenerateMessageToPool(const string& name_prefix, - const google::protobuf::Descriptor* message, - bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateMessageToPool(const string& name_prefix, const Descriptor* message, + io::Printer* printer) { // Don't generate MapEntry messages -- we use the PHP extension's native // support for map fields instead. if (message->options().map_entry()) { @@ -579,8 +543,9 @@ void GenerateMessageToPool(const string& name_prefix, message->name() : name_prefix + "_" + message->name(); printer->Print( - "$pool->addMessage('@message@', @class_name@::class)\n", - "message", MessageFullName(message, is_descriptor), + "$pool->addMessage('^message^', " + "\\Google\\Protobuf\\Internal\\^class_name^::class)\n", + "message", MessageFullName(message, true), "class_name", class_name); Indent(printer); @@ -593,38 +558,40 @@ void GenerateMessageToPool(const string& name_prefix, const FieldDescriptor* val = field->message_type()->FindFieldByName("value"); printer->Print( - "->map('@field@', GPBType::@key@, " - "GPBType::@value@, @number@@other@)\n", + "->map('^field^', \\Google\\Protobuf\\Internal\\GPBType::^key^, " + "\\Google\\Protobuf\\Internal\\GPBType::^value^, ^number^^other^)\n", "field", field->name(), "key", ToUpper(key->type_name()), "value", ToUpper(val->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(val, is_descriptor)); + "other", EnumOrMessageSuffix(val, true)); } else if (!field->containing_oneof()) { printer->Print( - "->@label@('@field@', GPBType::@type@, @number@@other@)\n", + "->^label^('^field^', " + "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "label", LabelForField(field), "type", ToUpper(field->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(field, is_descriptor)); + "other", EnumOrMessageSuffix(field, true)); } } // oneofs. for (int i = 0; i < message->oneof_decl_count(); i++) { const OneofDescriptor* oneof = message->oneof_decl(i); - printer->Print("->oneof(@name@)\n", + printer->Print("->oneof(^name^)\n", "name", oneof->name()); Indent(printer); for (int index = 0; index < oneof->field_count(); index++) { const FieldDescriptor* field = oneof->field(index); printer->Print( - "->value('@field@', GPBType::@type@, @number@@other@)\n", + "->value('^field^', " + "\\Google\\Protobuf\\Internal\\GPBType::^type^, ^number^^other^)\n", "field", field->name(), "type", ToUpper(field->type_name()), "number", SimpleItoa(field->number()), - "other", EnumOrMessageSuffix(field, is_descriptor)); + "other", EnumOrMessageSuffix(field, true)); } printer->Print("->finish()\n"); Outdent(printer); @@ -639,33 +606,48 @@ void GenerateMessageToPool(const string& name_prefix, "\n"); for (int i = 0; i < message->nested_type_count(); i++) { - GenerateMessageToPool(class_name, message->nested_type(i), is_descriptor, - printer); + GenerateMessageToPool(class_name, message->nested_type(i), printer); } for (int i = 0; i < message->enum_type_count(); i++) { - GenerateEnumToPool(message->enum_type(i), is_descriptor, printer); + GenerateEnumToPool(message->enum_type(i), printer); } } -void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, - bool is_descriptor, - google::protobuf::io::Printer* printer) { - if (is_descriptor) { - printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n"); +void GenerateAddFileToPool(const FileDescriptor* file, bool is_descriptor, + io::Printer* printer) { + printer->Print( + "public static $is_initialized = false;\n\n" + "public static function initOnce() {\n"); + Indent(printer); + printer->Print( + "$pool = \\Google\\Protobuf\\Internal\\" + "DescriptorPool::getGeneratedPool();\n\n" + "if (static::$is_initialized == true) {\n" + " return;\n" + "}\n"); + + if (is_descriptor) { for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessageToPool("", file->message_type(i), is_descriptor, printer); + GenerateMessageToPool("", file->message_type(i), printer); } for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnumToPool(file->enum_type(i), is_descriptor, printer); + GenerateEnumToPool(file->enum_type(i), printer); } printer->Print( "$pool->finish();\n"); } else { - // Add messages and enums to descriptor pool. - printer->Print("$pool = DescriptorPool::getGeneratedPool();\n\n"); + for (int i = 0; i < file->dependency_count(); i++) { + const std::string& name = file->dependency(i)->name(); + std::string dependency_filename = + GeneratedMetadataFileName(name, is_descriptor); + printer->Print( + "\\^name^::initOnce();\n", + "name", FilenameToClassname(dependency_filename)); + } + // Add messages and enums to descriptor pool. FileDescriptorSet files; FileDescriptorProto* file_proto = files.add_file(); file->CopyTo(file_proto); @@ -679,7 +661,7 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, static const int kBytesPerLine = 30; for (int i = 0; i < files_data.size(); i += kBytesPerLine) { printer->Print( - "\"@data@\"@dot@\n", + "\"^data^\"^dot^\n", "data", BinaryToHex(files_data.substr(i, kBytesPerLine)), "dot", i + kBytesPerLine < files_data.size() ? " ." : ""); } @@ -688,38 +670,20 @@ void GenerateAddFileToPool(const google::protobuf::FileDescriptor* file, printer->Print( "));\n\n"); } - -} - -void GenerateEnum(const google::protobuf::EnumDescriptor* en, - google::protobuf::io::Printer* printer) { printer->Print( - "class @name@\n" - "{\n", - "name", EnumClassName(en)); - Indent(printer); - - for (int i = 0; i < en->value_count(); i++) { - const EnumValueDescriptor* value = en->value(i); - printer->Print("const @name@ = @number@;\n", - "name", value->name(), - "number", IntToString(value->number())); - } + "static::$is_initialized = true;\n"); Outdent(printer); - printer->Print("}\n\n"); + printer->Print("}\n"); } -void GenerateUseDeclaration(bool is_descriptor, - google::protobuf::io::Printer* printer) { +void GenerateUseDeclaration(bool is_descriptor, io::Printer* printer) { if (!is_descriptor) { printer->Print( - "use Google\\Protobuf\\Internal\\DescriptorPool;\n" "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" "use Google\\Protobuf\\Internal\\GPBUtil;\n\n"); } else { printer->Print( - "use Google\\Protobuf\\Internal\\DescriptorPool;\n" "use Google\\Protobuf\\Internal\\GPBType;\n" "use Google\\Protobuf\\Internal\\GPBWire;\n" "use Google\\Protobuf\\Internal\\RepeatedField;\n" @@ -728,42 +692,377 @@ void GenerateUseDeclaration(bool is_descriptor, } } -void GenerateFile(const google::protobuf::FileDescriptor* file, - bool is_descriptor, google::protobuf::io::Printer* printer) { +void GenerateHead(const FileDescriptor* file, io::Printer* printer) { printer->Print( "<?php\n" "# Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "# source: @filename@\n" + "# source: ^filename^\n" "\n", "filename", file->name()); +} + +std::string FilenameToClassname(const string& filename) { + int lastindex = filename.find_last_of("."); + std::string result = filename.substr(0, lastindex); + for (int i = 0; i < result.size(); i++) { + if (result[i] == '/') { + result[i] = '\\'; + } + } + return result; +} + +void GenerateMetadataFile(const FileDescriptor* file, + bool is_descriptor, + GeneratorContext* generator_context) { + std::string filename = GeneratedMetadataFileName(file->name(), is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + + if (lastindex != string::npos) { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + GenerateAddFileToPool(file, is_descriptor, &printer); + + Outdent(&printer); + printer.Print("}\n\n"); +} + +void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, + bool is_descriptor, GeneratorContext* generator_context) { + std::string filename = GeneratedEnumFileName(en, is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + + GenerateEnumDocComment(&printer, en); + if (lastindex != string::npos) { + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + for (int i = 0; i < en->value_count(); i++) { + const EnumValueDescriptor* value = en->value(i); + GenerateEnumValueDocComment(&printer, value); + printer.Print("const ^name^ = ^number^;\n", + "name", value->name(), + "number", IntToString(value->number())); + } + + Outdent(&printer); + printer.Print("}\n\n"); +} + +void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message, + bool is_descriptor, + GeneratorContext* generator_context) { + // Don't generate MapEntry messages -- we use the PHP extension's native + // support for map fields instead. + if (message->options().map_entry()) { + return; + } + + std::string filename = GeneratedMessageFileName(message, is_descriptor); + scoped_ptr<io::ZeroCopyOutputStream> output( + generator_context->Open(filename)); + io::Printer printer(output.get(), '^'); + + GenerateHead(file, &printer); + + std::string fullname = FilenameToClassname(filename); + int lastindex = fullname.find_last_of("\\"); + if (!file->package().empty()) { - printer->Print("namespace @name@;\n\n", - "name", PhpName(file->package(), is_descriptor)); + printer.Print( + "namespace ^name^;\n\n", + "name", fullname.substr(0, lastindex)); + } + + GenerateUseDeclaration(is_descriptor, &printer); + + GenerateMessageDocComment(&printer, message); + if (lastindex != string::npos) { + printer.Print( + "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "{\n", + "name", fullname.substr(lastindex + 1)); + } else { + printer.Print( + "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n" + "{\n", + "name", fullname); + } + Indent(&printer); + + // Field and oneof definitions. + for (int i = 0; i < message->field_count(); i++) { + const FieldDescriptor* field = message->field(i); + GenerateField(field, &printer, is_descriptor); + } + for (int i = 0; i < message->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = message->oneof_decl(i); + GenerateOneofField(oneof, &printer); } + printer.Print("\n"); - for (int i = 0; i < file->dependency_count(); i++) { - const std::string& name = file->dependency(i)->name(); - printer->Print("require_once('@name@');\n", "name", - GeneratedFileName(name, is_descriptor)); + printer.Print( + "public function __construct() {\n"); + Indent(&printer); + + std::string metadata_filename = + GeneratedMetadataFileName(file->name(), is_descriptor); + std::string metadata_fullname = FilenameToClassname(metadata_filename); + printer.Print( + "\\^fullname^::initOnce();\n" + "parent::__construct();\n", + "fullname", metadata_fullname); + + Outdent(&printer); + printer.Print("}\n\n"); + + // Field and oneof accessors. + for (int i = 0; i < message->field_count(); i++) { + const FieldDescriptor* field = message->field(i); + GenerateFieldAccessor(field, is_descriptor, &printer); + } + for (int i = 0; i < message->oneof_decl_count(); i++) { + const OneofDescriptor* oneof = message->oneof_decl(i); + printer.Print( + "public function get^camel_name^()\n" + "{\n" + " return $this->^name^;\n" + "}\n\n", + "camel_name", UnderscoresToCamelCase(oneof->name(), true), "name", + oneof->name()); } - GenerateUseDeclaration(is_descriptor, printer); + Outdent(&printer); + printer.Print("}\n\n"); + + // Nested messages and enums. + for (int i = 0; i < message->nested_type_count(); i++) { + GenerateMessageFile(file, message->nested_type(i), is_descriptor, + generator_context); + } + for (int i = 0; i < message->enum_type_count(); i++) { + GenerateEnumFile(file, message->enum_type(i), is_descriptor, + generator_context); + } +} +void GenerateFile(const FileDescriptor* file, bool is_descriptor, + GeneratorContext* generator_context) { + GenerateMetadataFile(file, is_descriptor, generator_context); for (int i = 0; i < file->message_type_count(); i++) { - GenerateMessage("", file->message_type(i), is_descriptor, printer); + GenerateMessageFile(file, file->message_type(i), is_descriptor, + generator_context); } for (int i = 0; i < file->enum_type_count(); i++) { - GenerateEnum(file->enum_type(i), printer); + GenerateEnumFile(file, file->enum_type(i), is_descriptor, + generator_context); } +} + +static string EscapePhpdoc(const string& input) { + string result; + result.reserve(input.size() * 2); + + char prev = '*'; + + for (string::size_type i = 0; i < input.size(); i++) { + char c = input[i]; + switch (c) { + case '*': + // Avoid "/*". + if (prev == '/') { + result.append("*"); + } else { + result.push_back(c); + } + break; + case '/': + // Avoid "*/". + if (prev == '*') { + result.append("/"); + } else { + result.push_back(c); + } + break; + case '@': + // '@' starts phpdoc tags including the @deprecated tag, which will + // cause a compile-time error if inserted before a declaration that + // does not have a corresponding @Deprecated annotation. + result.append("@"); + break; + case '<': + // Avoid interpretation as HTML. + result.append("<"); + break; + case '>': + // Avoid interpretation as HTML. + result.append(">"); + break; + case '&': + // Avoid interpretation as HTML. + result.append("&"); + break; + case '\\': + // Java interprets Unicode escape sequences anywhere! + result.append("\"); + break; + default: + result.push_back(c); + break; + } - GenerateAddFileToPool(file, is_descriptor, printer); + prev = c; + } + + return result; } -bool Generator::Generate( - const FileDescriptor* file, - const string& parameter, - GeneratorContext* generator_context, - string* error) const { +static void GenerateDocCommentBodyForLocation( + io::Printer* printer, const SourceLocation& location) { + string comments = location.leading_comments.empty() ? + location.trailing_comments : location.leading_comments; + if (!comments.empty()) { + // TODO(teboring): Ideally we should parse the comment text as Markdown and + // write it back as HTML, but this requires a Markdown parser. For now + // we just use <pre> to get fixed-width text formatting. + + // If the comment itself contains block comment start or end markers, + // HTML-escape them so that they don't accidentally close the doc comment. + comments = EscapePhpdoc(comments); + + vector<string> lines = Split(comments, "\n"); + while (!lines.empty() && lines.back().empty()) { + lines.pop_back(); + } + + printer->Print(" * <pre>\n"); + for (int i = 0; i < lines.size(); i++) { + // Most lines should start with a space. Watch out for lines that start + // with a /, since putting that right after the leading asterisk will + // close the comment. + if (!lines[i].empty() && lines[i][0] == '/') { + printer->Print(" * ^line^\n", "line", lines[i]); + } else { + printer->Print(" *^line^\n", "line", lines[i]); + } + } + printer->Print( + " * </pre>\n" + " *\n"); + } +} + +template <typename DescriptorType> +static void GenerateDocCommentBody( + io::Printer* printer, const DescriptorType* descriptor) { + SourceLocation location; + if (descriptor->GetSourceLocation(&location)) { + GenerateDocCommentBodyForLocation(printer, location); + } +} + +static string FirstLineOf(const string& value) { + string result = value; + + string::size_type pos = result.find_first_of('\n'); + if (pos != string::npos) { + result.erase(pos); + } + + return result; +} + +void GenerateMessageDocComment(io::Printer* printer, + const Descriptor* message) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, message); + printer->Print( + " * Protobuf type <code>^fullname^</code>\n" + " */\n", + "fullname", EscapePhpdoc(message->full_name())); +} + +void GenerateFieldDocComment(io::Printer* printer, + const FieldDescriptor* field) { + // In theory we should have slightly different comments for setters, getters, + // etc., but in practice everyone already knows the difference between these + // so it's redundant information. + + // We start the comment with the main body based on the comments from the + // .proto file (if present). We then end with the field declaration, e.g.: + // optional string foo = 5; + // If the field is a group, the debug string might end with {. + printer->Print("/**\n"); + GenerateDocCommentBody(printer, field); + printer->Print( + " * <code>^def^</code>\n", + "def", EscapePhpdoc(FirstLineOf(field->DebugString()))); + printer->Print(" */\n"); +} + +void GenerateEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, enum_); + printer->Print( + " * Protobuf enum <code>^fullname^</code>\n" + " */\n", + "fullname", EscapePhpdoc(enum_->full_name())); +} + +void GenerateEnumValueDocComment(io::Printer* printer, + const EnumValueDescriptor* value) { + printer->Print("/**\n"); + GenerateDocCommentBody(printer, value); + printer->Print( + " * <code>^def^</code>\n" + " */\n", + "def", EscapePhpdoc(FirstLineOf(value->DebugString()))); +} + +bool Generator::Generate(const FileDescriptor* file, const string& parameter, + GeneratorContext* generator_context, + string* error) const { bool is_descriptor = parameter == "internal"; if (is_descriptor && file->name() != kDescriptorFile) { @@ -779,12 +1078,7 @@ bool Generator::Generate( return false; } - std::string filename = GeneratedFileName(file->name(), is_descriptor); - scoped_ptr<io::ZeroCopyOutputStream> output( - generator_context->Open(filename)); - io::Printer printer(output.get(), '@'); - - GenerateFile(file, is_descriptor, &printer); + GenerateFile(file, is_descriptor, generator_context); return true; } diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index e1087601..3848101d 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -62,9 +62,12 @@ namespace compiler { class GeneratorResponseContext : public GeneratorContext { public: - GeneratorResponseContext(CodeGeneratorResponse* response, - const vector<const FileDescriptor*>& parsed_files) - : response_(response), + GeneratorResponseContext( + const Version& compiler_version, + CodeGeneratorResponse* response, + const std::vector<const FileDescriptor*>& parsed_files) + : compiler_version_(compiler_version), + response_(response), parsed_files_(parsed_files) {} virtual ~GeneratorResponseContext() {} @@ -84,13 +87,18 @@ class GeneratorResponseContext : public GeneratorContext { return new io::StringOutputStream(file->mutable_content()); } - void ListParsedFiles(vector<const FileDescriptor*>* output) { + void ListParsedFiles(std::vector<const FileDescriptor*>* output) { *output = parsed_files_; } + void GetCompilerVersion(Version* version) const { + *version = compiler_version_; + } + private: + Version compiler_version_; CodeGeneratorResponse* response_; - const vector<const FileDescriptor*>& parsed_files_; + const std::vector<const FileDescriptor*>& parsed_files_; }; bool GenerateCode(const CodeGeneratorRequest& request, @@ -105,7 +113,7 @@ bool GenerateCode(const CodeGeneratorRequest& request, } } - vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; for (int i = 0; i < request.file_to_generate_size(); i++) { parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i))); if (parsed_files.back() == NULL) { @@ -116,7 +124,8 @@ bool GenerateCode(const CodeGeneratorRequest& request, } } - GeneratorResponseContext context(response, parsed_files); + GeneratorResponseContext context( + request.compiler_version(), response, parsed_files); string error; bool succeeded = generator.GenerateAll( diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index a4d4a530..bb78eff6 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -20,145 +20,157 @@ namespace google { namespace protobuf { namespace compiler { +class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> {}; +VersionDefaultTypeInternal _Version_default_instance_; +class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {}; +CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {}; +CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {}; +CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; namespace { -const ::google::protobuf::Descriptor* CodeGeneratorRequest_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorRequest_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_reflection_ = NULL; -const ::google::protobuf::Descriptor* CodeGeneratorResponse_File_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CodeGeneratorResponse_File_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[4]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/compiler/plugin.proto"); - GOOGLE_CHECK(file != NULL); - CodeGeneratorRequest_descriptor_ = file->message_type(0); - static const int CodeGeneratorRequest_offsets_[3] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_), + 1, + 2, + 3, + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_), - }; - CodeGeneratorRequest_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorRequest_descriptor_, - CodeGeneratorRequest::internal_default_instance(), - CodeGeneratorRequest_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), - -1, - -1, - sizeof(CodeGeneratorRequest), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_)); - CodeGeneratorResponse_descriptor_ = file->message_type(1); - static const int CodeGeneratorResponse_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), - }; - CodeGeneratorResponse_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorResponse_descriptor_, - CodeGeneratorResponse::internal_default_instance(), - CodeGeneratorResponse_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), - -1, - -1, - sizeof(CodeGeneratorResponse), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_)); - CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0); - static const int CodeGeneratorResponse_File_offsets_[3] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_), + 2, + 0, + 3, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_), + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), + 0, + 1, }; - CodeGeneratorResponse_File_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - CodeGeneratorResponse_File_descriptor_, - CodeGeneratorResponse_File::internal_default_instance(), - CodeGeneratorResponse_File_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), - -1, - -1, - sizeof(CodeGeneratorResponse_File), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 8, sizeof(Version)}, + { 12, 20, sizeof(CodeGeneratorRequest)}, + { 24, 31, sizeof(CodeGeneratorResponse_File)}, + { 34, 40, sizeof(CodeGeneratorResponse)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorRequest_descriptor_, CodeGeneratorRequest::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_descriptor_, CodeGeneratorResponse::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CodeGeneratorResponse_File_descriptor_, CodeGeneratorResponse_File::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - CodeGeneratorRequest_default_instance_.Shutdown(); - delete CodeGeneratorRequest_reflection_; - CodeGeneratorResponse_default_instance_.Shutdown(); - delete CodeGeneratorResponse_reflection_; - CodeGeneratorResponse_File_default_instance_.Shutdown(); - delete CodeGeneratorResponse_File_reflection_; + _Version_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _CodeGeneratorRequest_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _CodeGeneratorResponse_File_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _CodeGeneratorResponse_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); - ::google::protobuf::internal::GetEmptyString(); - CodeGeneratorRequest_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - CodeGeneratorResponse_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); - CodeGeneratorRequest_default_instance_.get_mutable()->InitAsDefaultInstance(); - CodeGeneratorResponse_default_instance_.get_mutable()->InitAsDefaultInstance(); - CodeGeneratorResponse_File_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); + ::google::protobuf::internal::InitProtobufDefaults(); + _Version_default_instance_.DefaultConstruct(); + _CodeGeneratorRequest_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); + _CodeGeneratorResponse_default_instance_.DefaultConstruct(); + _CodeGeneratorRequest_default_instance_.get_mutable()->compiler_version_ = const_cast< ::google::protobuf::compiler::Version*>( + ::google::protobuf::compiler::Version::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + static const char descriptor[] = { + "\n%google/protobuf/compiler/plugin.proto\022" + "\030google.protobuf.compiler\032 google/protob" + "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" + "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" + "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" + "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" + "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." + "FileDescriptorProto\022;\n\020compiler_version\030" + "\003 \001(\0132!.google.protobuf.compiler.Version" + "\"\252\001\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" + "\t\022B\n\004file\030\017 \003(\01324.google.protobuf.compil" + "er.CodeGeneratorResponse.File\032>\n\004File\022\014\n" + "\004name\030\001 \001(\t\022\027\n\017insertion_point\030\002 \001(\t\022\017\n\007" + "content\030\017 \001(\tB7\n\034com.google.protobuf.com" + "pilerB\014PluginProtosZ\tplugin_go" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n%google/protobuf/compiler/plugin.proto\022" - "\030google.protobuf.compiler\032 google/protob" - "uf/descriptor.proto\"}\n\024CodeGeneratorRequ" - "est\022\030\n\020file_to_generate\030\001 \003(\t\022\021\n\tparamet" - "er\030\002 \001(\t\0228\n\nproto_file\030\017 \003(\0132$.google.pr" - "otobuf.FileDescriptorProto\"\252\001\n\025CodeGener" - "atorResponse\022\r\n\005error\030\001 \001(\t\022B\n\004file\030\017 \003(" - "\01324.google.protobuf.compiler.CodeGenerat" - "orResponse.File\032>\n\004File\022\014\n\004name\030\001 \001(\t\022\027\n" - "\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(\tB" - "7\n\034com.google.protobuf.compilerB\014PluginP" - "rotosZ\tplugin_go", 456); + descriptor, 590); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); @@ -177,15 +189,500 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_; -namespace { +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int Version::kMajorFieldNumber; +const int Version::kMinorFieldNumber; +const int Version::kPatchFieldNumber; +const int Version::kSuffixFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +Version::Version() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version) +} +Version::Version(const Version& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_suffix()) { + suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_); + } + ::memcpy(&major_, &from.major_, + reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); + // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) } -} // namespace +void Version::SharedCtor() { + _cached_size_ = 0; + suffix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); +} + +Version::~Version() { + // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) + SharedDtor(); +} + +void Version::SharedDtor() { + suffix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} + +void Version::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* Version::descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[0].descriptor; +} + +const Version& Version::default_instance() { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + 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) + if (has_suffix()) { + GOOGLE_DCHECK(!suffix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*suffix_.UnsafeRawStringPointer())->clear(); + } + if (_has_bits_[0 / 32] & 14u) { + ::memset(&major_, 0, reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_) + sizeof(patch_)); + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool Version::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:google.protobuf.compiler.Version) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // optional int32 major = 1; + case 1: { + if (tag == 8u) { + set_has_major(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &major_))); + } else { + goto handle_unusual; + } + break; + } + + // optional int32 minor = 2; + case 2: { + if (tag == 16u) { + set_has_minor(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &minor_))); + } else { + goto handle_unusual; + } + break; + } + + // optional int32 patch = 3; + case 3: { + if (tag == 24u) { + set_has_patch(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( + input, &patch_))); + } else { + goto handle_unusual; + } + break; + } + + // optional string suffix = 4; + case 4: { + if (tag == 34u) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_suffix())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.compiler.Version.suffix"); + } else { + goto handle_unusual; + } + break; + } + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:google.protobuf.compiler.Version) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.Version) + return false; +#undef DO_ +} + +void Version::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.Version) + // optional int32 major = 1; + if (has_major()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->major(), output); + } + + // optional int32 minor = 2; + if (has_minor()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->minor(), output); + } + + // optional int32 patch = 3; + if (has_patch()) { + ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->patch(), output); + } + + // optional string suffix = 4; + if (has_suffix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.compiler.Version.suffix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 4, this->suffix(), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.Version) +} + +::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) + // optional int32 major = 1; + if (has_major()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->major(), target); + } + + // optional int32 minor = 2; + if (has_minor()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->minor(), target); + } + + // optional int32 patch = 3; + if (has_patch()) { + target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->patch(), target); + } + + // optional string suffix = 4; + if (has_suffix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->suffix().data(), this->suffix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.compiler.Version.suffix"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 4, this->suffix(), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) + return target; +} + +size_t Version::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + if (_has_bits_[0 / 32] & 15u) { + // optional string suffix = 4; + if (has_suffix()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->suffix()); + } + + // optional int32 major = 1; + if (has_major()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->major()); + } + + // optional int32 minor = 2; + if (has_minor()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->minor()); + } + + // optional int32 patch = 3; + if (has_patch()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->patch()); + } + + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void Version::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, this); + const Version* source = + ::google::protobuf::internal::DynamicCastToGenerated<const Version>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.Version) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.Version) + MergeFrom(*source); + } +} + +void Version::MergeFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 15u) { + if (from.has_suffix()) { + set_has_suffix(); + suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_); + } + if (from.has_major()) { + set_major(from.major()); + } + if (from.has_minor()) { + set_minor(from.minor()); + } + if (from.has_patch()) { + set_patch(from.patch()); + } + } +} + +void Version::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void Version::CopyFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Version::IsInitialized() const { + return true; +} + +void Version::Swap(Version* other) { + if (other == this) return; + InternalSwap(other); +} +void Version::InternalSwap(Version* other) { + suffix_.Swap(&other->suffix_); + std::swap(major_, other->major_); + std::swap(minor_, other->minor_); + std::swap(patch_, other->patch_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata Version::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[0]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// Version + +// optional int32 major = 1; +bool Version::has_major() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void Version::set_has_major() { + _has_bits_[0] |= 0x00000002u; +} +void Version::clear_has_major() { + _has_bits_[0] &= ~0x00000002u; +} +void Version::clear_major() { + major_ = 0; + clear_has_major(); +} +::google::protobuf::int32 Version::major() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) + return major_; +} +void Version::set_major(::google::protobuf::int32 value) { + set_has_major(); + major_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) +} + +// optional int32 minor = 2; +bool Version::has_minor() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void Version::set_has_minor() { + _has_bits_[0] |= 0x00000004u; +} +void Version::clear_has_minor() { + _has_bits_[0] &= ~0x00000004u; +} +void Version::clear_minor() { + minor_ = 0; + clear_has_minor(); +} +::google::protobuf::int32 Version::minor() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) + return minor_; +} +void Version::set_minor(::google::protobuf::int32 value) { + set_has_minor(); + minor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) +} + +// optional int32 patch = 3; +bool Version::has_patch() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void Version::set_has_patch() { + _has_bits_[0] |= 0x00000008u; +} +void Version::clear_has_patch() { + _has_bits_[0] &= ~0x00000008u; +} +void Version::clear_patch() { + patch_ = 0; + clear_has_patch(); +} +::google::protobuf::int32 Version::patch() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) + return patch_; +} +void Version::set_patch(::google::protobuf::int32 value) { + set_has_patch(); + patch_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) +} + +// optional string suffix = 4; +bool Version::has_suffix() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void Version::set_has_suffix() { + _has_bits_[0] |= 0x00000001u; +} +void Version::clear_has_suffix() { + _has_bits_[0] &= ~0x00000001u; +} +void Version::clear_suffix() { + suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_suffix(); +} +const ::std::string& Version::suffix() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) + return suffix_.GetNoArena(); +} +void Version::set_suffix(const ::std::string& value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} +void Version::set_suffix(const char* value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) +} +void Version::set_suffix(const char* value, size_t size) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) +} +::std::string* Version::mutable_suffix() { + set_has_suffix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) + return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* Version::release_suffix() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) + clear_has_suffix(); + return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void Version::set_allocated_suffix(::std::string* suffix) { + if (suffix != NULL) { + set_has_suffix(); + } else { + clear_has_suffix(); + } + suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -193,29 +690,41 @@ static void MergeFromFail(int line) { const int CodeGeneratorRequest::kFileToGenerateFieldNumber; const int CodeGeneratorRequest::kParameterFieldNumber; const int CodeGeneratorRequest::kProtoFileFieldNumber; +const int CodeGeneratorRequest::kCompilerVersionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) } - -void CodeGeneratorRequest::InitAsDefaultInstance() { -} - CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_to_generate_(from.file_to_generate_), + proto_file_(from.proto_file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_parameter()) { + parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_); + } + if (from.has_compiler_version()) { + compiler_version_ = new ::google::protobuf::compiler::Version(*from.compiler_version_); + } else { + compiler_version_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } void CodeGeneratorRequest::SharedCtor() { _cached_size_ = 0; parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + compiler_version_ = NULL; } CodeGeneratorRequest::~CodeGeneratorRequest() { @@ -225,6 +734,9 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { void CodeGeneratorRequest::SharedDtor() { parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) { + delete compiler_version_; + } } void CodeGeneratorRequest::SetCachedSize(int size) const { @@ -234,7 +746,7 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorRequest_descriptor_; + return file_level_metadata[1].descriptor; } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { @@ -242,8 +754,6 @@ const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_; - CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const { CodeGeneratorRequest* n = new CodeGeneratorRequest; if (arena != NULL) { @@ -254,15 +764,20 @@ CodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) - if (has_parameter()) { - parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } file_to_generate_.Clear(); proto_file_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + if (has_parameter()) { + GOOGLE_DCHECK(!parameter_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*parameter_.UnsafeRawStringPointer())->clear(); + } + if (has_compiler_version()) { + GOOGLE_DCHECK(compiler_version_ != NULL); + compiler_version_->::google::protobuf::compiler::Version::Clear(); + } } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool CodeGeneratorRequest::MergePartialFromCodedStream( @@ -271,14 +786,13 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorRequest) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string file_to_generate = 1; case 1: { - if (tag == 10) { - parse_file_to_generate: + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_file_to_generate())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -289,15 +803,12 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_file_to_generate; - if (input->ExpectTag(18)) goto parse_parameter; break; } // optional string parameter = 2; case 2: { - if (tag == 18) { - parse_parameter: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_parameter())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -307,24 +818,30 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_proto_file; + break; + } + + // optional .google.protobuf.compiler.Version compiler_version = 3; + case 3: { + if (tag == 26u) { + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( + input, mutable_compiler_version())); + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; case 15: { - if (tag == 122) { - parse_proto_file: + if (tag == 122u) { DO_(input->IncrementRecursionDepth()); - parse_loop_proto_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_proto_file())); } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_loop_proto_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -373,6 +890,12 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( 2, this->parameter(), output); } + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 3, *this->compiler_version_, output); + } + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -411,6 +934,13 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( 2, this->parameter(), target); } + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 3, *this->compiler_version_, false, target); + } + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -430,13 +960,11 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) size_t total_size = 0; - // optional string parameter = 2; - if (has_parameter()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->parameter()); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } - // repeated string file_to_generate = 1; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); @@ -456,10 +984,21 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string parameter = 2; + if (has_parameter()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->parameter()); + } + + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (has_compiler_version()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->compiler_version_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -470,7 +1009,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorRequest* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorRequest>( &from); @@ -479,32 +1018,24 @@ void CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorRequest) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void CodeGeneratorRequest::UnsafeMergeFrom(const CodeGeneratorRequest& from) { - GOOGLE_DCHECK(&from != this); - file_to_generate_.UnsafeMergeFrom(from.file_to_generate_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + file_to_generate_.MergeFrom(from.file_to_generate_); proto_file_.MergeFrom(from.proto_file_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_parameter()) { set_has_parameter(); parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_); } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_compiler_version()) { + mutable_compiler_version()->::google::protobuf::compiler::Version::MergeFrom(from.compiler_version()); + } } } @@ -519,11 +1050,10 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorRequest::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->proto_file())) return false; return true; } @@ -534,8 +1064,9 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) { } void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { file_to_generate_.UnsafeArenaSwap(&other->file_to_generate_); - parameter_.Swap(&other->parameter_); proto_file_.UnsafeArenaSwap(&other->proto_file_); + parameter_.Swap(&other->parameter_); + std::swap(compiler_version_, other->compiler_version_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -543,10 +1074,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorRequest_descriptor_; - metadata.reflection = CodeGeneratorRequest_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -609,13 +1137,13 @@ CodeGeneratorRequest::mutable_file_to_generate() { // optional string parameter = 2; bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -623,7 +1151,7 @@ void CodeGeneratorRequest::clear_parameter() { } const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return parameter_.GetNoArena(); } void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); @@ -691,9 +1219,51 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); +// optional .google.protobuf.compiler.Version compiler_version = 3; +bool CodeGeneratorRequest::has_compiler_version() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void CodeGeneratorRequest::set_has_compiler_version() { + _has_bits_[0] |= 0x00000002u; +} +void CodeGeneratorRequest::clear_has_compiler_version() { + _has_bits_[0] &= ~0x00000002u; +} +void CodeGeneratorRequest::clear_compiler_version() { + if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); + clear_has_compiler_version(); } +const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_ != NULL ? *compiler_version_ + : *::google::protobuf::compiler::Version::internal_default_instance(); +} +::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { + set_has_compiler_version(); + if (compiler_version_ == NULL) { + compiler_version_ = new ::google::protobuf::compiler::Version; + } + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_; +} +::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + clear_has_compiler_version(); + ::google::protobuf::compiler::Version* temp = compiler_version_; + compiler_version_ = NULL; + return temp; +} +void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { + delete compiler_version_; + compiler_version_ = compiler_version; + if (compiler_version) { + set_has_compiler_version(); + } else { + clear_has_compiler_version(); + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) +} + #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -706,19 +1276,30 @@ const int CodeGeneratorResponse_File::kContentFieldNumber; CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } - -void CodeGeneratorResponse_File::InitAsDefaultInstance() { -} - CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_insertion_point()) { + insertion_point_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.insertion_point_); + } + content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_content()) { + content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) } @@ -747,7 +1328,7 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_File_descriptor_; + return file_level_metadata[2].descriptor; } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { @@ -755,8 +1336,6 @@ const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_; - CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File; if (arena != NULL) { @@ -769,19 +1348,20 @@ void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (_has_bits_[0 / 32] & 7u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_insertion_point()) { - insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!insertion_point_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*insertion_point_.UnsafeRawStringPointer())->clear(); } if (has_content()) { - content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!content_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*content_.UnsafeRawStringPointer())->clear(); } } _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool CodeGeneratorResponse_File::MergePartialFromCodedStream( @@ -790,13 +1370,13 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse.File) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -806,14 +1386,12 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_insertion_point; break; } // optional string insertion_point = 2; case 2: { - if (tag == 18) { - parse_insertion_point: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_insertion_point())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -823,14 +1401,12 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_content; break; } // optional string content = 15; case 15: { - if (tag == 122) { - parse_content: + if (tag == 122u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_content())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -840,7 +1416,6 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -955,6 +1530,11 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; if (has_name()) { @@ -978,11 +1558,6 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -992,7 +1567,7 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorResponse_File* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse_File>( &from); @@ -1001,22 +1576,15 @@ void CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& fr ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse.File) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_File& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1030,10 +1598,6 @@ void CodeGeneratorResponse_File::UnsafeMergeFrom(const CodeGeneratorResponse_Fil content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void CodeGeneratorResponse_File::CopyFrom(const ::google::protobuf::Message& from) { @@ -1047,11 +1611,10 @@ void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse_File::IsInitialized() const { - return true; } @@ -1070,14 +1633,177 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_File_descriptor_; - metadata.reflection = CodeGeneratorResponse_File_reflection_; - return metadata; + return file_level_metadata[2]; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// CodeGeneratorResponse_File -// ------------------------------------------------------------------- +// optional string name = 1; +bool CodeGeneratorResponse_File::has_name() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void CodeGeneratorResponse_File::set_has_name() { + _has_bits_[0] |= 0x00000001u; +} +void CodeGeneratorResponse_File::clear_has_name() { + _has_bits_[0] &= ~0x00000001u; +} +void CodeGeneratorResponse_File::clear_name() { + name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name(); +} +const ::std::string& CodeGeneratorResponse_File::name() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) + return name_.GetNoArena(); +} +void CodeGeneratorResponse_File::set_name(const ::std::string& value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +void CodeGeneratorResponse_File::set_name(const char* value) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { + set_has_name(); + name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +::std::string* CodeGeneratorResponse_File::mutable_name() { + set_has_name(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) + return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* CodeGeneratorResponse_File::release_name() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) + clear_has_name(); + return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { + if (name != NULL) { + set_has_name(); + } else { + clear_has_name(); + } + name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} + +// optional string insertion_point = 2; +bool CodeGeneratorResponse_File::has_insertion_point() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void CodeGeneratorResponse_File::set_has_insertion_point() { + _has_bits_[0] |= 0x00000002u; +} +void CodeGeneratorResponse_File::clear_has_insertion_point() { + _has_bits_[0] &= ~0x00000002u; +} +void CodeGeneratorResponse_File::clear_insertion_point() { + insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_insertion_point(); +} +const ::std::string& CodeGeneratorResponse_File::insertion_point() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + return insertion_point_.GetNoArena(); +} +void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { + set_has_insertion_point(); + insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +void CodeGeneratorResponse_File::set_insertion_point(const char* value) { + set_has_insertion_point(); + insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { + set_has_insertion_point(); + insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { + set_has_insertion_point(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* CodeGeneratorResponse_File::release_insertion_point() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + clear_has_insertion_point(); + return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { + if (insertion_point != NULL) { + set_has_insertion_point(); + } else { + clear_has_insertion_point(); + } + insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} + +// optional string content = 15; +bool CodeGeneratorResponse_File::has_content() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void CodeGeneratorResponse_File::set_has_content() { + _has_bits_[0] |= 0x00000004u; +} +void CodeGeneratorResponse_File::clear_has_content() { + _has_bits_[0] &= ~0x00000004u; +} +void CodeGeneratorResponse_File::clear_content() { + content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_content(); +} +const ::std::string& CodeGeneratorResponse_File::content() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) + return content_.GetNoArena(); +} +void CodeGeneratorResponse_File::set_content(const ::std::string& value) { + set_has_content(); + content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +void CodeGeneratorResponse_File::set_content(const char* value) { + set_has_content(); + content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { + set_has_content(); + content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +::std::string* CodeGeneratorResponse_File::mutable_content() { + set_has_content(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) + return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* CodeGeneratorResponse_File::release_content() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) + clear_has_content(); + return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { + if (content != NULL) { + set_has_content(); + } else { + clear_has_content(); + } + content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CodeGeneratorResponse::kErrorFieldNumber; @@ -1086,19 +1812,23 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) } - -void CodeGeneratorResponse::InitAsDefaultInstance() { -} - CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_(from.file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_error()) { + error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } @@ -1123,7 +1853,7 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { protobuf_AssignDescriptorsOnce(); - return CodeGeneratorResponse_descriptor_; + return file_level_metadata[3].descriptor; } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { @@ -1131,8 +1861,6 @@ const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_; - CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const { CodeGeneratorResponse* n = new CodeGeneratorResponse; if (arena != NULL) { @@ -1143,14 +1871,13 @@ CodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* are void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) + file_.Clear(); if (has_error()) { - error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!error_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*error_.UnsafeRawStringPointer())->clear(); } - file_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool CodeGeneratorResponse::MergePartialFromCodedStream( @@ -1159,13 +1886,13 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string error = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_error())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1175,24 +1902,19 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_file; break; } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; case 15: { - if (tag == 122) { - parse_file: + if (tag == 122u) { DO_(input->IncrementRecursionDepth()); - parse_loop_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); } else { goto handle_unusual; } - if (input->ExpectTag(122)) goto parse_loop_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1278,13 +2000,11 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) size_t total_size = 0; - // optional string error = 1; - if (has_error()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->error()); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; { unsigned int count = this->file_size(); @@ -1296,11 +2016,13 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional string error = 1; + if (has_error()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->error()); } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -1310,7 +2032,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const CodeGeneratorResponse* source = ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse>( &from); @@ -1319,31 +2041,18 @@ void CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void CodeGeneratorResponse::UnsafeMergeFrom(const CodeGeneratorResponse& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); file_.MergeFrom(from.file_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_error()) { - set_has_error(); - error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_error()) { + set_has_error(); + error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_); } } @@ -1358,11 +2067,10 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse::IsInitialized() const { - return true; } @@ -1371,8 +2079,8 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) { InternalSwap(other); } void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { - error_.Swap(&other->error_); file_.UnsafeArenaSwap(&other->file_); + error_.Swap(&other->error_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -1380,182 +2088,10 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CodeGeneratorResponse_descriptor_; - metadata.reflection = CodeGeneratorResponse_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// CodeGeneratorResponse_File - -// optional string name = 1; -bool CodeGeneratorResponse_File::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void CodeGeneratorResponse_File::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -void CodeGeneratorResponse_File::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -void CodeGeneratorResponse_File::clear_name() { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name(); -} -const ::std::string& CodeGeneratorResponse_File::name() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_name(const ::std::string& value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -void CodeGeneratorResponse_File::set_name(const char* value) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -void CodeGeneratorResponse_File::set_name(const char* value, size_t size) { - set_has_name(); - name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} -::std::string* CodeGeneratorResponse_File::mutable_name() { - set_has_name(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_name() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name) - clear_has_name(); - return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) { - if (name != NULL) { - set_has_name(); - } else { - clear_has_name(); - } - name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name) -} - -// optional string insertion_point = 2; -bool CodeGeneratorResponse_File::has_insertion_point() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void CodeGeneratorResponse_File::set_has_insertion_point() { - _has_bits_[0] |= 0x00000002u; -} -void CodeGeneratorResponse_File::clear_has_insertion_point() { - _has_bits_[0] &= ~0x00000002u; -} -void CodeGeneratorResponse_File::clear_insertion_point() { - insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_insertion_point(); -} -const ::std::string& CodeGeneratorResponse_File::insertion_point() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -void CodeGeneratorResponse_File::set_insertion_point(const char* value) { - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) { - set_has_insertion_point(); - insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} -::std::string* CodeGeneratorResponse_File::mutable_insertion_point() { - set_has_insertion_point(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_insertion_point() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - clear_has_insertion_point(); - return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) { - if (insertion_point != NULL) { - set_has_insertion_point(); - } else { - clear_has_insertion_point(); - } - insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) -} - -// optional string content = 15; -bool CodeGeneratorResponse_File::has_content() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void CodeGeneratorResponse_File::set_has_content() { - _has_bits_[0] |= 0x00000004u; -} -void CodeGeneratorResponse_File::clear_has_content() { - _has_bits_[0] &= ~0x00000004u; -} -void CodeGeneratorResponse_File::clear_content() { - content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_content(); -} -const ::std::string& CodeGeneratorResponse_File::content() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_content(const ::std::string& value) { - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -void CodeGeneratorResponse_File::set_content(const char* value) { - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -void CodeGeneratorResponse_File::set_content(const char* value, size_t size) { - set_has_content(); - content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} -::std::string* CodeGeneratorResponse_File::mutable_content() { - set_has_content(); - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* CodeGeneratorResponse_File::release_content() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content) - clear_has_content(); - return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) { - if (content != NULL) { - set_has_content(); - } else { - clear_has_content(); - } - content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) -} - -inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() { - return &CodeGeneratorResponse_File_default_instance_.get(); -} -// ------------------------------------------------------------------- - // CodeGeneratorResponse // optional string error = 1; @@ -1574,7 +2110,7 @@ void CodeGeneratorResponse::clear_error() { } const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return error_.GetNoArena(); } void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); @@ -1642,9 +2178,6 @@ CodeGeneratorResponse::file() const { return file_; } -inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() { - return &CodeGeneratorResponse_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index f9a99e75..e1e999bc 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -24,11 +24,104 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/descriptor.pb.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class DescriptorProto; +class DescriptorProtoDefaultTypeInternal; +extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumOptions; +class EnumOptionsDefaultTypeInternal; +extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +class FieldOptions; +class FieldOptionsDefaultTypeInternal; +extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +class FileOptions; +class FileOptionsDefaultTypeInternal; +extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; +class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +class MessageOptions; +class MessageOptionsDefaultTypeInternal; +extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +class MethodOptions; +class MethodOptionsDefaultTypeInternal; +extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +class OneofOptions; +class OneofOptionsDefaultTypeInternal; +extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +namespace compiler { +class CodeGeneratorRequest; +class CodeGeneratorRequestDefaultTypeInternal; +extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse; +class CodeGeneratorResponseDefaultTypeInternal; +extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; +class CodeGeneratorResponse_File; +class CodeGeneratorResponse_FileDefaultTypeInternal; +extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; +class Version; +class VersionDefaultTypeInternal; +extern VersionDefaultTypeInternal _Version_default_instance_; +} // namespace compiler +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -37,15 +130,142 @@ namespace compiler { // Internal implementation detail -- do not call these. void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - -class CodeGeneratorRequest; -class CodeGeneratorResponse; -class CodeGeneratorResponse_File; // =================================================================== +class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { + public: + Version(); + virtual ~Version(); + + Version(const Version& from); + + inline Version& operator=(const Version& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const Version& default_instance(); + + static inline const Version* internal_default_instance() { + return reinterpret_cast<const Version*>( + &_Version_default_instance_); + } + + void Swap(Version* other); + + // implements Message ---------------------------------------------- + + inline Version* New() const PROTOBUF_FINAL { return New(NULL); } + + Version* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const Version& from); + void MergeFrom(const Version& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray(false, output); + } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(Version* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // optional int32 major = 1; + bool has_major() const; + void clear_major(); + static const int kMajorFieldNumber = 1; + ::google::protobuf::int32 major() const; + void set_major(::google::protobuf::int32 value); + + // optional int32 minor = 2; + bool has_minor() const; + void clear_minor(); + static const int kMinorFieldNumber = 2; + ::google::protobuf::int32 minor() const; + void set_minor(::google::protobuf::int32 value); + + // optional int32 patch = 3; + bool has_patch() const; + void clear_patch(); + static const int kPatchFieldNumber = 3; + ::google::protobuf::int32 patch() const; + void set_patch(::google::protobuf::int32 value); + + // optional string suffix = 4; + bool has_suffix() const; + void clear_suffix(); + static const int kSuffixFieldNumber = 4; + const ::std::string& suffix() const; + void set_suffix(const ::std::string& value); + void set_suffix(const char* value); + void set_suffix(const char* value, size_t size); + ::std::string* mutable_suffix(); + ::std::string* release_suffix(); + void set_allocated_suffix(::std::string* suffix); + + // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) + private: + void set_has_major(); + void clear_has_major(); + void set_has_minor(); + void clear_has_minor(); + void set_has_patch(); + void clear_has_patch(); + void set_has_suffix(); + void clear_has_suffix(); + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::internal::ArenaStringPtr suffix_; + ::google::protobuf::int32 major_; + ::google::protobuf::int32 minor_; + ::google::protobuf::int32 patch_; + friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + +}; +// ------------------------------------------------------------------- + class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: CodeGeneratorRequest(); @@ -69,49 +289,52 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorRequest& default_instance(); - static const CodeGeneratorRequest* internal_default_instance(); + static inline const CodeGeneratorRequest* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorRequest*>( + &_CodeGeneratorRequest_default_instance_); + } void Swap(CodeGeneratorRequest* other); // implements Message ---------------------------------------------- - inline CodeGeneratorRequest* New() const { return New(NULL); } + inline CodeGeneratorRequest* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorRequest& from); void MergeFrom(const CodeGeneratorRequest& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorRequest* other); - void UnsafeMergeFrom(const CodeGeneratorRequest& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -157,10 +380,21 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& proto_file() const; + // optional .google.protobuf.compiler.Version compiler_version = 3; + bool has_compiler_version() const; + void clear_compiler_version(); + static const int kCompilerVersionFieldNumber = 3; + const ::google::protobuf::compiler::Version& compiler_version() const; + ::google::protobuf::compiler::Version* mutable_compiler_version(); + ::google::protobuf::compiler::Version* release_compiler_version(); + void set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version); + // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest) private: - inline void set_has_parameter(); - inline void clear_has_parameter(); + void set_has_parameter(); + void clear_has_parameter(); + void set_has_compiler_version(); + void clear_has_compiler_version(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -168,15 +402,13 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; ::google::protobuf::internal::ArenaStringPtr parameter_; + ::google::protobuf::compiler::Version* compiler_version_; friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> CodeGeneratorRequest_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { @@ -202,49 +434,52 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse_File& default_instance(); - static const CodeGeneratorResponse_File* internal_default_instance(); + static inline const CodeGeneratorResponse_File* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse_File*>( + &_CodeGeneratorResponse_File_default_instance_); + } void Swap(CodeGeneratorResponse_File* other); // implements Message ---------------------------------------------- - inline CodeGeneratorResponse_File* New() const { return New(NULL); } + inline CodeGeneratorResponse_File* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse_File& from); void MergeFrom(const CodeGeneratorResponse_File& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorResponse_File* other); - void UnsafeMergeFrom(const CodeGeneratorResponse_File& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -288,12 +523,12 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_insertion_point(); - inline void clear_has_insertion_point(); - inline void set_has_content(); - inline void clear_has_content(); + void set_has_name(); + void clear_has_name(); + void set_has_insertion_point(); + void clear_has_insertion_point(); + void set_has_content(); + void clear_has_content(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -303,13 +538,10 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr content_; friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> CodeGeneratorResponse_File_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { @@ -335,49 +567,52 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const CodeGeneratorResponse& default_instance(); - static const CodeGeneratorResponse* internal_default_instance(); + static inline const CodeGeneratorResponse* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse*>( + &_CodeGeneratorResponse_default_instance_); + } void Swap(CodeGeneratorResponse* other); // implements Message ---------------------------------------------- - inline CodeGeneratorResponse* New() const { return New(NULL); } + inline CodeGeneratorResponse* New() const PROTOBUF_FINAL { return New(NULL); } - CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const CodeGeneratorResponse& from); void MergeFrom(const CodeGeneratorResponse& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(CodeGeneratorResponse* other); - void UnsafeMergeFrom(const CodeGeneratorResponse& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -411,8 +646,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: - inline void set_has_error(); - inline void clear_has_error(); + void set_has_error(); + void clear_has_error(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -421,19 +656,146 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag ::google::protobuf::internal::ArenaStringPtr error_; friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> CodeGeneratorResponse_default_instance_; - // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS +// Version + +// optional int32 major = 1; +inline bool Version::has_major() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void Version::set_has_major() { + _has_bits_[0] |= 0x00000002u; +} +inline void Version::clear_has_major() { + _has_bits_[0] &= ~0x00000002u; +} +inline void Version::clear_major() { + major_ = 0; + clear_has_major(); +} +inline ::google::protobuf::int32 Version::major() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) + return major_; +} +inline void Version::set_major(::google::protobuf::int32 value) { + set_has_major(); + major_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) +} + +// optional int32 minor = 2; +inline bool Version::has_minor() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void Version::set_has_minor() { + _has_bits_[0] |= 0x00000004u; +} +inline void Version::clear_has_minor() { + _has_bits_[0] &= ~0x00000004u; +} +inline void Version::clear_minor() { + minor_ = 0; + clear_has_minor(); +} +inline ::google::protobuf::int32 Version::minor() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) + return minor_; +} +inline void Version::set_minor(::google::protobuf::int32 value) { + set_has_minor(); + minor_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) +} + +// optional int32 patch = 3; +inline bool Version::has_patch() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void Version::set_has_patch() { + _has_bits_[0] |= 0x00000008u; +} +inline void Version::clear_has_patch() { + _has_bits_[0] &= ~0x00000008u; +} +inline void Version::clear_patch() { + patch_ = 0; + clear_has_patch(); +} +inline ::google::protobuf::int32 Version::patch() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) + return patch_; +} +inline void Version::set_patch(::google::protobuf::int32 value) { + set_has_patch(); + patch_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) +} + +// optional string suffix = 4; +inline bool Version::has_suffix() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void Version::set_has_suffix() { + _has_bits_[0] |= 0x00000001u; +} +inline void Version::clear_has_suffix() { + _has_bits_[0] &= ~0x00000001u; +} +inline void Version::clear_suffix() { + suffix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_suffix(); +} +inline const ::std::string& Version::suffix() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) + return suffix_.GetNoArena(); +} +inline void Version::set_suffix(const ::std::string& value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} +inline void Version::set_suffix(const char* value) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix) +} +inline void Version::set_suffix(const char* value, size_t size) { + set_has_suffix(); + suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) +} +inline ::std::string* Version::mutable_suffix() { + set_has_suffix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) + return suffix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* Version::release_suffix() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) + clear_has_suffix(); + return suffix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void Version::set_allocated_suffix(::std::string* suffix) { + if (suffix != NULL) { + set_has_suffix(); + } else { + clear_has_suffix(); + } + suffix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), suffix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +} + +// ------------------------------------------------------------------- + // CodeGeneratorRequest // repeated string file_to_generate = 1; @@ -493,13 +855,13 @@ CodeGeneratorRequest::mutable_file_to_generate() { // optional string parameter = 2; inline bool CodeGeneratorRequest::has_parameter() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void CodeGeneratorRequest::set_has_parameter() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void CodeGeneratorRequest::clear_has_parameter() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -507,7 +869,7 @@ inline void CodeGeneratorRequest::clear_parameter() { } inline const ::std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return parameter_.GetNoArena(); } inline void CodeGeneratorRequest::set_parameter(const ::std::string& value) { set_has_parameter(); @@ -575,9 +937,51 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -inline const CodeGeneratorRequest* CodeGeneratorRequest::internal_default_instance() { - return &CodeGeneratorRequest_default_instance_.get(); +// optional .google.protobuf.compiler.Version compiler_version = 3; +inline bool CodeGeneratorRequest::has_compiler_version() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void CodeGeneratorRequest::set_has_compiler_version() { + _has_bits_[0] |= 0x00000002u; +} +inline void CodeGeneratorRequest::clear_has_compiler_version() { + _has_bits_[0] &= ~0x00000002u; +} +inline void CodeGeneratorRequest::clear_compiler_version() { + if (compiler_version_ != NULL) compiler_version_->::google::protobuf::compiler::Version::Clear(); + clear_has_compiler_version(); +} +inline const ::google::protobuf::compiler::Version& CodeGeneratorRequest::compiler_version() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_ != NULL ? *compiler_version_ + : *::google::protobuf::compiler::Version::internal_default_instance(); +} +inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::mutable_compiler_version() { + set_has_compiler_version(); + if (compiler_version_ == NULL) { + compiler_version_ = new ::google::protobuf::compiler::Version; + } + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + return compiler_version_; +} +inline ::google::protobuf::compiler::Version* CodeGeneratorRequest::release_compiler_version() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + clear_has_compiler_version(); + ::google::protobuf::compiler::Version* temp = compiler_version_; + compiler_version_ = NULL; + return temp; +} +inline void CodeGeneratorRequest::set_allocated_compiler_version(::google::protobuf::compiler::Version* compiler_version) { + delete compiler_version_; + compiler_version_ = compiler_version; + if (compiler_version) { + set_has_compiler_version(); + } else { + clear_has_compiler_version(); + } + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) } + // ------------------------------------------------------------------- // CodeGeneratorResponse_File @@ -598,7 +1002,7 @@ inline void CodeGeneratorResponse_File::clear_name() { } inline const ::std::string& CodeGeneratorResponse_File::name() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_name(const ::std::string& value) { set_has_name(); @@ -652,7 +1056,7 @@ inline void CodeGeneratorResponse_File::clear_insertion_point() { } inline const ::std::string& CodeGeneratorResponse_File::insertion_point() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) - return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return insertion_point_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) { set_has_insertion_point(); @@ -706,7 +1110,7 @@ inline void CodeGeneratorResponse_File::clear_content() { } inline const ::std::string& CodeGeneratorResponse_File::content() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return content_.GetNoArena(); } inline void CodeGeneratorResponse_File::set_content(const ::std::string& value) { set_has_content(); @@ -744,9 +1148,6 @@ inline void CodeGeneratorResponse_File::set_allocated_content(::std::string* con // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content) } -inline const CodeGeneratorResponse_File* CodeGeneratorResponse_File::internal_default_instance() { - return &CodeGeneratorResponse_File_default_instance_.get(); -} // ------------------------------------------------------------------- // CodeGeneratorResponse @@ -767,7 +1168,7 @@ inline void CodeGeneratorResponse::clear_error() { } inline const ::std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return error_.GetNoArena(); } inline void CodeGeneratorResponse::set_error(const ::std::string& value) { set_has_error(); @@ -835,17 +1236,17 @@ CodeGeneratorResponse::file() const { return file_; } -inline const CodeGeneratorResponse* CodeGeneratorResponse::internal_default_instance() { - return &CodeGeneratorResponse_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) + } // namespace compiler } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto index acaee1f4..6e4da2c1 100644 --- a/src/google/protobuf/compiler/plugin.proto +++ b/src/google/protobuf/compiler/plugin.proto @@ -53,6 +53,16 @@ option go_package = "plugin_go"; import "google/protobuf/descriptor.proto"; +// The version number of protocol compiler. +message Version { + optional int32 major = 1; + optional int32 minor = 2; + optional int32 patch = 3; + // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should + // be empty for mainline stable releases. + optional string suffix = 4; +} + // An encoded CodeGeneratorRequest is written to the plugin's stdin. message CodeGeneratorRequest { // The .proto files that were explicitly listed on the command-line. The @@ -75,6 +85,9 @@ message CodeGeneratorRequest { // is not similarly optimized on protoc's end -- it will store all fields in // memory at once before sending them to the plugin. repeated FileDescriptorProto proto_file = 15; + + // The version number of protocol compiler. + optional Version compiler_version = 3; } // The plugin writes an encoded CodeGeneratorResponse to stdout. diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 3b1b0d1d..f5769128 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -120,7 +120,7 @@ const char* const* kKeywordsEnd = kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0])); bool ContainsPythonKeyword(const string& module_name) { - vector<string> tokens = Split(module_name, "."); + std::vector<string> tokens = Split(module_name, "."); for (int i = 0; i < tokens.size(); ++i) { if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) { return true; @@ -230,11 +230,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) { return SimpleItoa(field.default_value_uint64()); case FieldDescriptor::CPPTYPE_DOUBLE: { double value = field.default_value_double(); - if (value == numeric_limits<double>::infinity()) { + if (value == std::numeric_limits<double>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, // a numeric literal that is too big for a double will become infinity. return "1e10000"; - } else if (value == -numeric_limits<double>::infinity()) { + } else if (value == -std::numeric_limits<double>::infinity()) { // See above. return "-1e10000"; } else if (value != value) { @@ -246,11 +246,11 @@ string StringifyDefaultValue(const FieldDescriptor& field) { } case FieldDescriptor::CPPTYPE_FLOAT: { float value = field.default_value_float(); - if (value == numeric_limits<float>::infinity()) { + if (value == std::numeric_limits<float>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, // a numeric literal that is too big for a double will become infinity. return "1e10000"; - } else if (value == -numeric_limits<float>::infinity()) { + } else if (value == -std::numeric_limits<float>::infinity()) { // See above. return "-1e10000"; } else if (value != value) { @@ -405,7 +405,7 @@ void Generator::PrintImports() const { // Prints the single file descriptor for this file. void Generator::PrintFileDescriptor() const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["name"] = file_->name(); m["package"] = file_->package(); @@ -453,7 +453,7 @@ void Generator::PrintFileDescriptor() const { // Prints descriptors and module-level constants for all top-level // enums defined in |file|. void Generator::PrintTopLevelEnums() const { - vector<pair<string, int> > top_level_enum_values; + std::vector<std::pair<string, int> > top_level_enum_values; for (int i = 0; i < file_->enum_type_count(); ++i) { const EnumDescriptor& enum_descriptor = *file_->enum_type(i); PrintEnum(enum_descriptor); @@ -490,7 +490,7 @@ void Generator::PrintAllNestedEnumsInFile() const { // enum name to a Python EnumDescriptor object equivalent to // enum_descriptor. void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const { - map<string, string> m; + std::map<string, string> m; string module_level_descriptor_name = ModuleLevelDescriptorName(enum_descriptor); m["descriptor_name"] = module_level_descriptor_name; @@ -584,7 +584,7 @@ void Generator::PrintServiceDescriptor( "$service_name$ = _descriptor.ServiceDescriptor(\n", "service_name", service_name); printer_->Indent(); - map<string, string> m; + std::map<string, string> m; m["name"] = descriptor.name(); m["full_name"] = descriptor.full_name(); m["file"] = kDescriptorKey; @@ -680,7 +680,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { "descriptor_name", ModuleLevelDescriptorName(message_descriptor)); printer_->Indent(); - map<string, string> m; + std::map<string, string> m; m["name"] = message_descriptor.name(); m["full_name"] = message_descriptor.full_name(); m["file"] = kDescriptorKey; @@ -740,7 +740,7 @@ void Generator::PrintDescriptor(const Descriptor& message_descriptor) const { printer_->Indent(); for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) { const OneofDescriptor* desc = message_descriptor.oneof_decl(i); - map<string, string> m; + std::map<string, string> m; m["name"] = desc->name(); m["full_name"] = desc->full_name(); m["index"] = SimpleItoa(desc->index()); @@ -781,7 +781,7 @@ void Generator::PrintNestedDescriptors( // Prints all messages in |file|. void Generator::PrintMessages() const { for (int i = 0; i < file_->message_type_count(); ++i) { - vector<string> to_register; + std::vector<string> to_register; PrintMessage(*file_->message_type(i), "", &to_register); for (int j = 0; j < to_register.size(); ++j) { printer_->Print("_sym_db.RegisterMessage($name$)\n", "name", @@ -801,7 +801,7 @@ void Generator::PrintMessages() const { // Collect nested message names to_register for the symbol_database. void Generator::PrintMessage(const Descriptor& message_descriptor, const string& prefix, - vector<string>* to_register) const { + std::vector<string>* to_register) const { string qualified_name(prefix + message_descriptor.name()); to_register->push_back(qualified_name); printer_->Print( @@ -811,7 +811,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, printer_->Indent(); PrintNestedMessages(message_descriptor, qualified_name + ".", to_register); - map<string, string> m; + std::map<string, string> m; m["descriptor_key"] = kDescriptorKey; m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor); printer_->Print(m, "$descriptor_key$ = $descriptor_name$,\n"); @@ -827,7 +827,7 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, // Mutually recursive with PrintMessage(). void Generator::PrintNestedMessages(const Descriptor& containing_descriptor, const string& prefix, - vector<string>* to_register) const { + std::vector<string>* to_register) const { for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) { printer_->Print("\n"); PrintMessage(*containing_descriptor.nested_type(i), prefix, to_register); @@ -860,7 +860,7 @@ void Generator::FixForeignFieldsInDescriptor( FixContainingTypeInDescriptor(enum_descriptor, &descriptor); } for (int i = 0; i < descriptor.oneof_decl_count(); ++i) { - map<string, string> m; + std::map<string, string> m; const OneofDescriptor* oneof = descriptor.oneof_decl(i); m["descriptor_name"] = ModuleLevelDescriptorName(descriptor); m["oneof_name"] = oneof->name(); @@ -879,7 +879,7 @@ void Generator::FixForeignFieldsInDescriptor( } void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["message_name"] = descriptor.name(); m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor); @@ -891,7 +891,7 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { void Generator::AddEnumToFileDescriptor( const EnumDescriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["enum_name"] = descriptor.name(); m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor); @@ -903,7 +903,7 @@ void Generator::AddEnumToFileDescriptor( void Generator::AddExtensionToFileDescriptor( const FieldDescriptor& descriptor) const { - map<string, string> m; + std::map<string, string> m; m["descriptor_name"] = kDescriptorKey; m["field_name"] = descriptor.name(); const char file_descriptor_template[] = @@ -926,7 +926,7 @@ void Generator::FixForeignFieldsInField(const Descriptor* containing_type, const string& python_dict_name) const { const string field_referencing_expression = FieldReferencingExpression( containing_type, field, python_dict_name); - map<string, string> m; + std::map<string, string> m; m["field_ref"] = field_referencing_expression; const Descriptor* foreign_message_type = field.message_type(); if (foreign_message_type) { @@ -1025,7 +1025,7 @@ void Generator::FixForeignFieldsInExtension( FixForeignFieldsInField(extension_field.extension_scope(), extension_field, "extensions_by_name"); - map<string, string> m; + std::map<string, string> m; // Confusingly, for FieldDescriptors that happen to be extensions, // containing_type() means "extended type." // On the other hand, extension_scope() will give us what we normally @@ -1058,7 +1058,7 @@ void Generator::PrintEnumValueDescriptor( // More circular references. ::sigh:: string options_string; descriptor.options().SerializeToString(&options_string); - map<string, string> m; + std::map<string, string> m; m["name"] = descriptor.name(); m["index"] = SimpleItoa(descriptor.index()); m["number"] = SimpleItoa(descriptor.number()); @@ -1091,7 +1091,7 @@ void Generator::PrintFieldDescriptor( const FieldDescriptor& field, bool is_extension) const { string options_string; field.options().SerializeToString(&options_string); - map<string, string> m; + std::map<string, string> m; m["name"] = field.name(); m["full_name"] = field.full_name(); m["index"] = SimpleItoa(field.index()); diff --git a/src/google/protobuf/compiler/python/python_generator.h b/src/google/protobuf/compiler/python/python_generator.h index 7583aa65..594260af 100644 --- a/src/google/protobuf/compiler/python/python_generator.h +++ b/src/google/protobuf/compiler/python/python_generator.h @@ -97,10 +97,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { void PrintMessages() const; void PrintMessage(const Descriptor& message_descriptor, const string& prefix, - vector<string>* to_register) const; + std::vector<string>* to_register) const; void PrintNestedMessages(const Descriptor& containing_descriptor, const string& prefix, - vector<string>* to_register) const; + std::vector<string>* to_register) const; void FixForeignFieldsInDescriptors() const; void FixForeignFieldsInDescriptor( diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index e929e4fb..933450fa 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -261,9 +261,8 @@ string Subprocess::Win32ErrorMessage(DWORD error_code) { char* message; // WTF? - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error_code, 0, (LPSTR)&message, // NOT A BUG! 0, NULL); diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h index 602e508e..03db4d57 100644 --- a/src/google/protobuf/compiler/zip_writer.h +++ b/src/google/protobuf/compiler/zip_writer.h @@ -85,7 +85,7 @@ class ZipWriter { }; io::ZeroCopyOutputStream* raw_output_; - vector<FileInfo> files_; + std::vector<FileInfo> files_; }; } // namespace compiler diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index be1e1d69..7dfdb377 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -315,7 +315,7 @@ class PrefixRemover { // be a lot cleaner but we'd just have to convert it back to const char* // for the open source release. -typedef pair<const void*, const char*> PointerStringPair; +typedef std::pair<const void*, const char*> PointerStringPair; struct PointerStringPairEqual { inline bool operator()(const PointerStringPair& a, @@ -343,8 +343,8 @@ struct PointerIntegerPairHash { } }; -typedef pair<const Descriptor*, int> DescriptorIntPair; -typedef pair<const EnumDescriptor*, int> EnumIntPair; +typedef std::pair<const Descriptor*, int> DescriptorIntPair; +typedef std::pair<const EnumDescriptor*, int> EnumIntPair; struct PointerStringPairHash { size_t operator()(const PointerStringPair& p) const { @@ -452,11 +452,11 @@ typedef hash_map<EnumIntPair, const EnumValueDescriptor*, // through all the extensions that extend a given Descriptor, and an // ordered data structure that implements lower_bound is convenient // for that. -typedef map<DescriptorIntPair, const FieldDescriptor*> +typedef std::map<DescriptorIntPair, const FieldDescriptor*> ExtensionsGroupedByDescriptorMap; typedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap; -set<string>* allowed_proto3_extendees_ = NULL; +std::set<string>* allowed_proto3_extendees_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_); void DeleteAllowedProto3Extendee() { @@ -464,7 +464,7 @@ void DeleteAllowedProto3Extendee() { } void InitAllowedProto3Extendee() { - allowed_proto3_extendees_ = new set<string>; + allowed_proto3_extendees_ = new std::set<string>; const char* kOptionNames[] = { "FileOptions", "MessageOptions", "FieldOptions", "EnumOptions", "EnumValueOptions", "ServiceOptions", "MethodOptions"}; @@ -542,7 +542,7 @@ class DescriptorPool::Tables { // The stack of files which are currently being built. Used to detect // cyclic dependencies when loading files from a DescriptorDatabase. Not // used when fallback_database_ == NULL. - vector<string> pending_files_; + std::vector<string> pending_files_; // A set of files which we have tried to load from the fallback database // and encountered errors. We will not attempt to load them again during @@ -580,7 +580,7 @@ class DescriptorPool::Tables { inline const FieldDescriptor* FindExtension(const Descriptor* extendee, int number); inline void FindAllExtensions(const Descriptor* extendee, - vector<const FieldDescriptor*>* out) const; + std::vector<const FieldDescriptor*>* out) const; // ----------------------------------------------------------------- // Adding items. @@ -620,10 +620,11 @@ class DescriptorPool::Tables { FileDescriptorTables* AllocateFileTables(); private: - vector<string*> strings_; // All strings in the pool. - vector<Message*> messages_; // All messages in the pool. - vector<FileDescriptorTables*> file_tables_; // All file tables in the pool. - vector<void*> allocations_; // All other memory allocated in the pool. + std::vector<string*> strings_; // All strings in the pool. + std::vector<Message*> messages_; // All messages in the pool. + std::vector<FileDescriptorTables*> + file_tables_; // All file tables in the pool. + std::vector<void*> allocations_; // All other memory allocated in the pool. SymbolsByNameMap symbols_by_name_; FilesByNameMap files_by_name_; @@ -650,10 +651,10 @@ class DescriptorPool::Tables { int pending_files_before_checkpoint; int pending_extensions_before_checkpoint; }; - vector<CheckPoint> checkpoints_; - vector<const char* > symbols_after_checkpoint_; - vector<const char* > files_after_checkpoint_; - vector<DescriptorIntPair> extensions_after_checkpoint_; + std::vector<CheckPoint> checkpoints_; + std::vector<const char* > symbols_after_checkpoint_; + std::vector<const char* > files_after_checkpoint_; + std::vector<DescriptorIntPair> extensions_after_checkpoint_; // Allocate some bytes which will be reclaimed when the pool is // destroyed. @@ -720,14 +721,14 @@ class FileDescriptorTables { // Populates p->first->locations_by_path_ from p->second. // Unusual signature dictated by GoogleOnceDynamic. static void BuildLocationsByPath( - pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); + std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p); // Returns the location denoted by the specified path through info, // or NULL if not found. // The value of info must be that of the corresponding FileDescriptor. // (Conceptually a pure function, but stateful as an optimisation.) const SourceCodeInfo_Location* GetSourceLocation( - const vector<int>& path, const SourceCodeInfo* info) const; + const std::vector<int>& path, const SourceCodeInfo* info) const; private: SymbolsByParentMap symbols_by_parent_; @@ -1008,7 +1009,8 @@ inline const FieldDescriptor* DescriptorPool::Tables::FindExtension( } inline void DescriptorPool::Tables::FindAllExtensions( - const Descriptor* extendee, vector<const FieldDescriptor*>* out) const { + const Descriptor* extendee, + std::vector<const FieldDescriptor*>* out) const { ExtensionsGroupedByDescriptorMap::const_iterator it = extensions_.lower_bound(std::make_pair(extendee, 0)); for (; it != extensions_.end() && it->first.first == extendee; ++it) { @@ -1128,7 +1130,7 @@ void* DescriptorPool::Tables::AllocateBytes(int size) { } void FileDescriptorTables::BuildLocationsByPath( - pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) { + std::pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) { for (int i = 0, len = p->second->location_size(); i < len; ++i) { const SourceCodeInfo_Location* loc = &p->second->location().Get(i); p->first->locations_by_path_[Join(loc->path(), ",")] = loc; @@ -1136,8 +1138,8 @@ void FileDescriptorTables::BuildLocationsByPath( } const SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation( - const vector<int>& path, const SourceCodeInfo* info) const { - pair<const FileDescriptorTables*, const SourceCodeInfo*> p( + const std::vector<int>& path, const SourceCodeInfo* info) const { + std::pair<const FileDescriptorTables*, const SourceCodeInfo*> p( std::make_pair(this, info)); locations_by_path_once_.Init(&FileDescriptorTables::BuildLocationsByPath, &p); return FindPtrOrNull(locations_by_path_, Join(path, ",")); @@ -1239,6 +1241,7 @@ const DescriptorPool* DescriptorPool::generated_pool() { } + DescriptorPool* DescriptorPool::internal_generated_pool() { InitGeneratedPoolOnce(); return generated_pool_; @@ -1397,7 +1400,8 @@ const FieldDescriptor* DescriptorPool::FindExtensionByNumber( } void DescriptorPool::FindAllExtensions( - const Descriptor* extendee, vector<const FieldDescriptor*>* out) const { + const Descriptor* extendee, + std::vector<const FieldDescriptor*>* out) const { MutexLockMaybe lock(mutex_); tables_->known_bad_symbols_.clear(); tables_->known_bad_files_.clear(); @@ -1406,7 +1410,7 @@ void DescriptorPool::FindAllExtensions( // (but do this only once per descriptor). if (fallback_database_ != NULL && tables_->extensions_loaded_from_db_.count(extendee) == 0) { - vector<int> numbers; + std::vector<int> numbers; if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(), &numbers)) { for (int i = 0; i < numbers.size(); ++i) { @@ -2071,13 +2075,11 @@ void MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const { namespace { -// Used by each of the option formatters. -bool RetrieveOptions(int depth, - const Message &options, - vector<string> *option_entries) { +bool RetrieveOptionsAssumingRightPool(int depth, const Message& options, + std::vector<string>* option_entries) { option_entries->clear(); const Reflection* reflection = options.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(options, &fields); for (int i = 0; i < fields.size(); i++) { int count = 1; @@ -2114,21 +2116,56 @@ bool RetrieveOptions(int depth, return !option_entries->empty(); } +// Used by each of the option formatters. +bool RetrieveOptions(int depth, const Message& options, + const DescriptorPool* pool, + std::vector<string>* option_entries) { + // When printing custom options for a descriptor, we must use an options + // message built on top of the same DescriptorPool where the descriptor + // is coming from. This is to ensure we are interpreting custom options + // against the right pool. + if (options.GetDescriptor()->file()->pool() == pool) { + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } else { + const Descriptor* option_descriptor = + pool->FindMessageTypeByName(options.GetDescriptor()->full_name()); + if (option_descriptor == NULL) { + // google/protobuf/descriptor.proto is not in the pool. This means no + // custom options are used so we are safe to proceed with the compiled + // options message type. + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } + DynamicMessageFactory factory; + google::protobuf::scoped_ptr<Message> dynamic_options( + factory.GetPrototype(option_descriptor)->New()); + if (dynamic_options->ParseFromString(options.SerializeAsString())) { + return RetrieveOptionsAssumingRightPool(depth, *dynamic_options, + option_entries); + } else { + GOOGLE_LOG(ERROR) << "Found invalid proto option data for: " + << options.GetDescriptor()->full_name(); + return RetrieveOptionsAssumingRightPool(depth, options, option_entries); + } + } +} + // Formats options that all appear together in brackets. Does not include // brackets. -bool FormatBracketedOptions(int depth, const Message &options, string *output) { - vector<string> all_options; - if (RetrieveOptions(depth, options, &all_options)) { +bool FormatBracketedOptions(int depth, const Message& options, + const DescriptorPool* pool, string* output) { + std::vector<string> all_options; + if (RetrieveOptions(depth, options, pool, &all_options)) { output->append(Join(all_options, ", ")); } return !all_options.empty(); } // Formats options one per line -bool FormatLineOptions(int depth, const Message &options, string *output) { +bool FormatLineOptions(int depth, const Message& options, + const DescriptorPool* pool, string* output) { string prefix(depth * 2, ' '); - vector<string> all_options; - if (RetrieveOptions(depth, options, &all_options)) { + std::vector<string> all_options; + if (RetrieveOptions(depth, options, pool, &all_options)) { for (int i = 0; i < all_options.size(); i++) { strings::SubstituteAndAppend(output, "$0option $1;\n", prefix, all_options[i]); @@ -2150,7 +2187,7 @@ class SourceLocationCommentPrinter { desc->GetSourceLocation(&source_loc_); } SourceLocationCommentPrinter(const FileDescriptor* file, - const vector<int>& path, + const std::vector<int>& path, const string& prefix, const DebugStringOptions& options) : options_(options), prefix_(prefix) { @@ -2183,7 +2220,7 @@ class SourceLocationCommentPrinter { string FormatComment(const string& comment_text) { string stripped_comment = comment_text; StripWhitespace(&stripped_comment); - vector<string> lines = Split(stripped_comment, "\n"); + std::vector<string> lines = Split(stripped_comment, "\n"); string output; for (int i = 0; i < lines.size(); ++i) { const string& line = lines[i]; @@ -2211,7 +2248,7 @@ string FileDescriptor::DebugStringWithOptions( const DebugStringOptions& debug_string_options) const { string contents; { - vector<int> path; + std::vector<int> path; path.push_back(FileDescriptorProto::kSyntaxFieldNumber); SourceLocationCommentPrinter syntax_comment( this, path, "", debug_string_options); @@ -2225,8 +2262,8 @@ string FileDescriptor::DebugStringWithOptions( comment_printer(this, "", debug_string_options); comment_printer.AddPreComment(&contents); - set<int> public_dependencies; - set<int> weak_dependencies; + std::set<int> public_dependencies; + std::set<int> weak_dependencies; public_dependencies.insert(public_dependencies_, public_dependencies_ + public_dependency_count_); weak_dependencies.insert(weak_dependencies_, @@ -2246,7 +2283,7 @@ string FileDescriptor::DebugStringWithOptions( } if (!package().empty()) { - vector<int> path; + std::vector<int> path; path.push_back(FileDescriptorProto::kPackageFieldNumber); SourceLocationCommentPrinter package_comment( this, path, "", debug_string_options); @@ -2255,7 +2292,7 @@ string FileDescriptor::DebugStringWithOptions( package_comment.AddPostComment(&contents); } - if (FormatLineOptions(0, options(), &contents)) { + if (FormatLineOptions(0, options(), pool(), &contents)) { contents.append("\n"); // add some space if we had options } @@ -2266,7 +2303,7 @@ string FileDescriptor::DebugStringWithOptions( // Find all the 'group' type extensions; we will not output their nested // definitions (those will be done with their group field descriptor). - set<const Descriptor*> groups; + std::set<const Descriptor*> groups; for (int i = 0; i < extension_count(); i++) { if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) { groups.insert(extension(i)->message_type()); @@ -2336,12 +2373,12 @@ void Descriptor::DebugString(int depth, string *contents, } contents->append(" {\n"); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), file()->pool(), contents); // Find all the 'group' types for fields and extensions; we will not output // their nested definitions (those will be done with their group field // descriptor). - set<const Descriptor*> groups; + std::set<const Descriptor*> groups; for (int i = 0; i < field_count(); i++) { if (field(i)->type() == FieldDescriptor::TYPE_GROUP) { groups.insert(field(i)->message_type()); @@ -2474,8 +2511,18 @@ void FieldDescriptor::DebugString(int depth, field_type = FieldTypeNameDebugString(); } + bool print_label = true; + // Determine whether to omit label: + // 1. For an optional field, omit label if it's in oneof or in proto3. + // 2. For a repeated field, omit label if it's a map. + if (is_optional() && (print_label_flag == OMIT_LABEL || + file()->syntax() == FileDescriptor::SYNTAX_PROTO3)) { + print_label = false; + } else if (is_map()) { + print_label = false; + } string label; - if (print_label_flag == PRINT_LABEL && !is_map()) { + if (print_label) { label = kLabelToName[this->label()]; label.push_back(' '); } @@ -2511,7 +2558,8 @@ void FieldDescriptor::DebugString(int depth, } string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { + if (FormatBracketedOptions(depth, options(), file()->pool(), + &formatted_options)) { contents->append(bracketed ? ", " : " ["); bracketed = true; contents->append(formatted_options); @@ -2555,14 +2603,15 @@ void OneofDescriptor::DebugString(int depth, string* contents, SourceLocationCommentPrinter comment_printer(this, prefix, debug_string_options); comment_printer.AddPreComment(contents); - strings::SubstituteAndAppend( - contents, "$0 oneof $1 {", prefix, name()); + strings::SubstituteAndAppend(contents, "$0oneof $1 {", prefix, name()); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), containing_type()->file()->pool(), + contents); if (debug_string_options.elide_oneof_body) { contents->append(" ... }\n"); } else { + contents->append("\n"); for (int i = 0; i < field_count(); i++) { field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents, debug_string_options); @@ -2597,7 +2646,7 @@ void EnumDescriptor::DebugString(int depth, string *contents, strings::SubstituteAndAppend(contents, "$0enum $1 {\n", prefix, name()); - FormatLineOptions(depth, options(), contents); + FormatLineOptions(depth, options(), file()->pool(), contents); for (int i = 0; i < value_count(); i++) { value(i)->DebugString(depth, contents, debug_string_options); @@ -2632,7 +2681,8 @@ void EnumValueDescriptor::DebugString(int depth, string *contents, prefix, name(), number()); string formatted_options; - if (FormatBracketedOptions(depth, options(), &formatted_options)) { + if (FormatBracketedOptions(depth, options(), type()->file()->pool(), + &formatted_options)) { strings::SubstituteAndAppend(contents, " [$0]", formatted_options); } contents->append(";\n"); @@ -2661,7 +2711,7 @@ void ServiceDescriptor::DebugString(string *contents, strings::SubstituteAndAppend(contents, "service $0 {\n", name()); - FormatLineOptions(1, options(), contents); + FormatLineOptions(1, options(), file()->pool(), contents); for (int i = 0; i < method_count(); i++) { method(i)->DebugString(1, contents, debug_string_options); @@ -2702,7 +2752,8 @@ void MethodDescriptor::DebugString(int depth, string *contents, server_streaming() ? "stream " : ""); string formatted_options; - if (FormatLineOptions(depth, options(), &formatted_options)) { + if (FormatLineOptions(depth, options(), service()->file()->pool(), + &formatted_options)) { strings::SubstituteAndAppend(contents, " {\n$0$1}\n", formatted_options, prefix); } else { @@ -2715,7 +2766,7 @@ void MethodDescriptor::DebugString(int depth, string *contents, // Location methods =============================================== -bool FileDescriptor::GetSourceLocation(const vector<int>& path, +bool FileDescriptor::GetSourceLocation(const std::vector<int>& path, SourceLocation* out_location) const { GOOGLE_CHECK_NOTNULL(out_location); if (source_code_info_) { @@ -2741,7 +2792,7 @@ bool FileDescriptor::GetSourceLocation(const vector<int>& path, } bool FileDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; // empty path for root FileDescriptor + std::vector<int> path; // empty path for root FileDescriptor return GetSourceLocation(path, out_location); } @@ -2755,49 +2806,49 @@ bool FieldDescriptor::is_packed() const { } bool Descriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool OneofDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return containing_type()->file()->GetSourceLocation(path, out_location); } bool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return service()->file()->GetSourceLocation(path, out_location); } bool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return file()->GetSourceLocation(path, out_location); } bool EnumValueDescriptor::GetSourceLocation( SourceLocation* out_location) const { - vector<int> path; + std::vector<int> path; GetLocationPath(&path); return type()->file()->GetSourceLocation(path, out_location); } -void Descriptor::GetLocationPath(vector<int>* output) const { +void Descriptor::GetLocationPath(std::vector<int>* output) const { if (containing_type()) { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kNestedTypeFieldNumber); @@ -2808,7 +2859,7 @@ void Descriptor::GetLocationPath(vector<int>* output) const { } } -void FieldDescriptor::GetLocationPath(vector<int>* output) const { +void FieldDescriptor::GetLocationPath(std::vector<int>* output) const { if (is_extension()) { if (extension_scope() == NULL) { output->push_back(FileDescriptorProto::kExtensionFieldNumber); @@ -2825,13 +2876,13 @@ void FieldDescriptor::GetLocationPath(vector<int>* output) const { } } -void OneofDescriptor::GetLocationPath(vector<int>* output) const { +void OneofDescriptor::GetLocationPath(std::vector<int>* output) const { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kOneofDeclFieldNumber); output->push_back(index()); } -void EnumDescriptor::GetLocationPath(vector<int>* output) const { +void EnumDescriptor::GetLocationPath(std::vector<int>* output) const { if (containing_type()) { containing_type()->GetLocationPath(output); output->push_back(DescriptorProto::kEnumTypeFieldNumber); @@ -2842,18 +2893,18 @@ void EnumDescriptor::GetLocationPath(vector<int>* output) const { } } -void EnumValueDescriptor::GetLocationPath(vector<int>* output) const { +void EnumValueDescriptor::GetLocationPath(std::vector<int>* output) const { type()->GetLocationPath(output); output->push_back(EnumDescriptorProto::kValueFieldNumber); output->push_back(index()); } -void ServiceDescriptor::GetLocationPath(vector<int>* output) const { +void ServiceDescriptor::GetLocationPath(std::vector<int>* output) const { output->push_back(FileDescriptorProto::kServiceFieldNumber); output->push_back(index()); } -void MethodDescriptor::GetLocationPath(vector<int>* output) const { +void MethodDescriptor::GetLocationPath(std::vector<int>* output) const { service()->GetLocationPath(output); output->push_back(ServiceDescriptorProto::kMethodFieldNumber); output->push_back(index()); @@ -2908,17 +2959,17 @@ class DescriptorBuilder { // As we build descriptors we store copies of the options messages in // them. We put pointers to those copies in this vector, as we build, so we // can later (after cross-linking) interpret those options. - vector<OptionsToInterpret> options_to_interpret_; + std::vector<OptionsToInterpret> options_to_interpret_; bool had_errors_; string filename_; FileDescriptor* file_; FileDescriptorTables* file_tables_; - set<const FileDescriptor*> dependencies_; + std::set<const FileDescriptor*> dependencies_; // unused_dependency_ is used to record the unused imported files. // Note: public import is not considered. - set<const FileDescriptor*> unused_dependency_; + std::set<const FileDescriptor*> unused_dependency_; // If LookupSymbol() finds a symbol that is in a file which is not a declared // dependency of this file, it will fail, but will set @@ -3171,8 +3222,10 @@ class DescriptorBuilder { // in unknown_fields to check if field innermost_field is set on the // innermost message. Returns false and sets an error if so. bool ExamineIfOptionIsSet( - vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter, - vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_iter, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_end, const FieldDescriptor* innermost_field, const string& debug_msg_name, const UnknownFieldSet& unknown_fields); @@ -3498,7 +3551,8 @@ Symbol DescriptorBuilder::FindSymbol(const string& name) { // dependency also defines the same package. We can't really rule out this // symbol unless none of the dependencies define it. if (IsInPackage(file_, name)) return result; - for (set<const FileDescriptor*>::const_iterator it = dependencies_.begin(); + for (std::set<const FileDescriptor*>::const_iterator it = + dependencies_.begin(); it != dependencies_.end(); ++it) { // Note: A dependency may be NULL if it was not found or had errors. if (*it != NULL && IsInPackage(*it, name)) return result; @@ -3717,9 +3771,13 @@ bool DescriptorBuilder::AddSymbol( if (tables_->AddSymbol(full_name, symbol)) { if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) { - GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in " - "symbols_by_name_, but was defined in symbols_by_parent_; " - "this shouldn't be possible."; + // This is only possible if there was already an error adding something of + // the same name. + if (!had_errors_) { + GOOGLE_LOG(DFATAL) << "\"" << full_name << "\" not previously defined in " + "symbols_by_name_, but was defined in " + "symbols_by_parent_; this shouldn't be possible."; + } return false; } return true; @@ -4037,12 +4095,12 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( } // Make sure all dependencies are loaded. - set<string> seen_dependencies; + std::set<string> seen_dependencies; result->dependency_count_ = proto.dependency_size(); result->dependencies_ = tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size()); unused_dependency_.clear(); - set<int> weak_deps; + std::set<int> weak_deps; for (int i = 0; i < proto.weak_dependency_size(); ++i) { weak_deps.insert(proto.weak_dependency(i)); } @@ -4141,7 +4199,7 @@ const FileDescriptor* DescriptorBuilder::BuildFileImpl( // extension options known, so all interpretations should now succeed. if (!had_errors_) { OptionInterpreter option_interpreter(this); - for (vector<OptionsToInterpret>::iterator iter = + for (std::vector<OptionsToInterpret>::iterator iter = options_to_interpret_.begin(); iter != options_to_interpret_.end(); ++iter) { option_interpreter.InterpretOptions(&(*iter)); @@ -4289,7 +4347,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = 0; j < result->reserved_range_count(); j++) { const Descriptor::ReservedRange* range2 = result->reserved_range(j); if (range1->end > range2->start && range2->end > range1->start) { - AddError(result->full_name(), proto.extension_range(j), + AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " "reserved range $2 to $3.", @@ -4300,7 +4358,7 @@ void DescriptorBuilder::BuildMessage(const DescriptorProto& proto, for (int j = i + 1; j < result->extension_range_count(); j++) { const Descriptor::ExtensionRange* range2 = result->extension_range(j); if (range1->end > range2->start && range2->end > range1->start) { - AddError(result->full_name(), proto.extension_range(j), + AddError(result->full_name(), proto.extension_range(i), DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension range $0 to $1 overlaps with " "already-defined range $2 to $3.", @@ -4411,11 +4469,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, break; case FieldDescriptor::CPPTYPE_FLOAT: if (proto.default_value() == "inf") { - result->default_value_float_ = numeric_limits<float>::infinity(); + result->default_value_float_ = + std::numeric_limits<float>::infinity(); } else if (proto.default_value() == "-inf") { - result->default_value_float_ = -numeric_limits<float>::infinity(); + result->default_value_float_ = + -std::numeric_limits<float>::infinity(); } else if (proto.default_value() == "nan") { - result->default_value_float_ = numeric_limits<float>::quiet_NaN(); + result->default_value_float_ = + std::numeric_limits<float>::quiet_NaN(); } else { result->default_value_float_ = io::SafeDoubleToFloat( io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos)); @@ -4423,11 +4484,14 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, break; case FieldDescriptor::CPPTYPE_DOUBLE: if (proto.default_value() == "inf") { - result->default_value_double_ = numeric_limits<double>::infinity(); + result->default_value_double_ = + std::numeric_limits<double>::infinity(); } else if (proto.default_value() == "-inf") { - result->default_value_double_ = -numeric_limits<double>::infinity(); + result->default_value_double_ = + -std::numeric_limits<double>::infinity(); } else if (proto.default_value() == "nan") { - result->default_value_double_ = numeric_limits<double>::quiet_NaN(); + result->default_value_double_ = + std::numeric_limits<double>::quiet_NaN(); } else { result->default_value_double_ = io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos); @@ -4690,12 +4754,13 @@ void DescriptorBuilder::CheckEnumValueUniqueness( // NAME_TYPE_LAST_NAME = 2, // } PrefixRemover remover(result->name()); - map<string, const google::protobuf::EnumValueDescriptor*> values; + std::map<string, const google::protobuf::EnumValueDescriptor*> values; for (int i = 0; i < result->value_count(); i++) { const google::protobuf::EnumValueDescriptor* value = result->value(i); string stripped = EnumValueToPascalCase(remover.MaybeRemove(value->name())); - std::pair<map<string, const google::protobuf::EnumValueDescriptor*>::iterator, bool> + std::pair<std::map<string, const google::protobuf::EnumValueDescriptor*>::iterator, + bool> insert_result = values.insert(std::make_pair(stripped, value)); bool inserted = insert_result.second; @@ -5170,13 +5235,16 @@ void DescriptorBuilder::CrossLinkField( const FieldDescriptor* conflicting_field = file_tables_->FindFieldByNumber(field->containing_type(), field->number()); + string containing_type_name = field->containing_type() == NULL + ? "unknown" + : field->containing_type()->full_name(); if (field->is_extension()) { AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER, strings::Substitute("Extension number $0 has already been used " "in \"$1\" by extension \"$2\".", field->number(), - field->containing_type()->full_name(), + containing_type_name, conflicting_field->full_name())); } else { AddError(field->full_name(), proto, @@ -5184,7 +5252,7 @@ void DescriptorBuilder::CrossLinkField( strings::Substitute("Field number $0 has already been used in " "\"$1\" by field \"$2\".", field->number(), - field->containing_type()->full_name(), + containing_type_name, conflicting_field->name())); } } else { @@ -5378,7 +5446,7 @@ void DescriptorBuilder::ValidateProto3Message( // In proto3, we reject field names if they conflict in camelCase. // Note that we currently enforce a stricter rule: Field names must be // unique after being converted to lowercase with underscores removed. - map<string, const FieldDescriptor*> name_to_field; + std::map<string, const FieldDescriptor*> name_to_field; for (int i = 0; i < message->field_count(); ++i) { string lowercase_name = ToLowercaseWithoutUnderscores( message->field(i)->name()); @@ -5529,7 +5597,7 @@ void DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm, const EnumDescriptorProto& proto) { VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue); if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) { - map<int, string> used_values; + std::map<int, string> used_values; for (int i = 0; i < enm->value_count(); ++i) { const EnumValueDescriptor* enum_value = enm->value(i); if (used_values.find(enum_value->number()) != used_values.end()) { @@ -5656,10 +5724,10 @@ bool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field, void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, const DescriptorProto& proto) { - map<string, const Descriptor*> seen_types; + std::map<string, const Descriptor*> seen_types; for (int i = 0; i < message->nested_type_count(); ++i) { const Descriptor* nested = message->nested_type(i); - pair<map<string, const Descriptor*>::iterator, bool> result = + std::pair<std::map<string, const Descriptor*>::iterator, bool> result = seen_types.insert(std::make_pair(nested->name(), nested)); if (!result.second) { if (result.first->second->options().map_entry() || @@ -5676,7 +5744,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted field names. for (int i = 0; i < message->field_count(); ++i) { const FieldDescriptor* field = message->field(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(field->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5688,7 +5756,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted enum names. for (int i = 0; i < message->enum_type_count(); ++i) { const EnumDescriptor* enum_desc = message->enum_type(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(enum_desc->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5700,7 +5768,7 @@ void DescriptorBuilder::DetectMapConflicts(const Descriptor* message, // Check for conflicted oneof names. for (int i = 0; i < message->oneof_decl_count(); ++i) { const OneofDescriptor* oneof_desc = message->oneof_decl(i); - map<string, const Descriptor*>::iterator iter = + std::map<string, const Descriptor*>::iterator iter = seen_types.find(oneof_desc->name()); if (iter != seen_types.end() && iter->second->options().map_entry()) { AddError(message->full_name(), proto, @@ -5835,7 +5903,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( // name in |debug_msg_name|, for use in error messages. const Descriptor* descriptor = options_descriptor; const FieldDescriptor* field = NULL; - vector<const FieldDescriptor*> intermediate_fields; + std::vector<const FieldDescriptor*> intermediate_fields; string debug_msg_name = ""; for (int i = 0; i < uninterpreted_option_->name_size(); ++i) { @@ -5943,7 +6011,7 @@ bool DescriptorBuilder::OptionInterpreter::InterpretSingleOption( // Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all // the intermediate messages. - for (vector<const FieldDescriptor*>::reverse_iterator iter = + for (std::vector<const FieldDescriptor*>::reverse_iterator iter = intermediate_fields.rbegin(); iter != intermediate_fields.rend(); ++iter) { google::protobuf::scoped_ptr<UnknownFieldSet> parent_unknown_fields( @@ -5993,8 +6061,9 @@ void DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting( } bool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet( - vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter, - vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, + std::vector<const FieldDescriptor*>::const_iterator + intermediate_fields_iter, + std::vector<const FieldDescriptor*>::const_iterator intermediate_fields_end, const FieldDescriptor* innermost_field, const string& debug_msg_name, const UnknownFieldSet& unknown_fields) { // We do linear searches of the UnknownFieldSet and its sub-groups. This @@ -6454,7 +6523,7 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, annotation_extensions.insert("google.protobuf.ServiceOptions"); annotation_extensions.insert("google.protobuf.MethodOptions"); annotation_extensions.insert("google.protobuf.StreamOptions"); - for (set<const FileDescriptor*>::const_iterator + for (std::set<const FileDescriptor*>::const_iterator it = unused_dependency_.begin(); it != unused_dependency_.end(); ++it) { // Do not log warnings for proto files which extend annotations. diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 0151e1d9..cc099693 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -62,6 +62,7 @@ #include <string> #include <vector> #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/mutex.h> // TYPE_BOOL is defined in the MacOS's ConditionalMacros.h. #ifdef TYPE_BOOL diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 1e21e230..56e75fa4 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -19,116 +19,78 @@ namespace google { namespace protobuf { +class FileDescriptorSetDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> {}; +FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; +class FileDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> {}; +FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; +class DescriptorProto_ExtensionRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> {}; +DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; +class DescriptorProto_ReservedRangeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> {}; +DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; +class DescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> {}; +DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; +class FieldDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> {}; +FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; +class OneofDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> {}; +OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; +class EnumDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> {}; +EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; +class EnumValueDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> {}; +EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; +class ServiceDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> {}; +ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; +class MethodDescriptorProtoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> {}; +MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; +class FileOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> {}; +FileOptionsDefaultTypeInternal _FileOptions_default_instance_; +class MessageOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> {}; +MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; +class FieldOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> {}; +FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; +class OneofOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> {}; +OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; +class EnumOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> {}; +EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; +class EnumValueOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> {}; +EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; +class ServiceOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> {}; +ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; +class MethodOptionsDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> {}; +MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; +class UninterpretedOption_NamePartDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> {}; +UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +class UninterpretedOptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> {}; +UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; +class SourceCodeInfo_LocationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> {}; +SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; +class SourceCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> {}; +SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> {}; +GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; +class GeneratedCodeInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> {}; +GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; namespace { -const ::google::protobuf::Descriptor* FileDescriptorSet_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorSet_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_ExtensionRange_reflection_ = NULL; -const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DescriptorProto_ReservedRange_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldDescriptorProto_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor_ = NULL; -const ::google::protobuf::Descriptor* OneofDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - OneofDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodDescriptorProto_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodDescriptorProto_reflection_ = NULL; -const ::google::protobuf::Descriptor* FileOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FileOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor_ = NULL; -const ::google::protobuf::Descriptor* MessageOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MessageOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* FieldOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldOptions_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor_ = NULL; -const ::google::protobuf::Descriptor* OneofOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - OneofOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValueOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValueOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* ServiceOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ServiceOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* MethodOptions_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - MethodOptions_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_reflection_ = NULL; -const ::google::protobuf::Descriptor* UninterpretedOption_NamePart_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UninterpretedOption_NamePart_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_reflection_ = NULL; -const ::google::protobuf::Descriptor* SourceCodeInfo_Location_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceCodeInfo_Location_reflection_ = NULL; -const ::google::protobuf::Descriptor* GeneratedCodeInfo_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - GeneratedCodeInfo_reflection_ = NULL; -const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - GeneratedCodeInfo_Annotation_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[25]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[6]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/descriptor.proto"); - GOOGLE_CHECK(file != NULL); - FileDescriptorSet_descriptor_ = file->message_type(0); - static const int FileDescriptorSet_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_), - }; - FileDescriptorSet_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileDescriptorSet_descriptor_, - FileDescriptorSet::internal_default_instance(), - FileDescriptorSet_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_), - -1, - -1, - sizeof(FileDescriptorSet), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_)); - FileDescriptorProto_descriptor_ = file->message_type(1); - static const int FileDescriptorProto_offsets_[12] = { + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_), @@ -141,19 +103,38 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_), - }; - FileDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileDescriptorProto_descriptor_, - FileDescriptorProto::internal_default_instance(), - FileDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_), - -1, - -1, - sizeof(FileDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_)); - DescriptorProto_descriptor_ = file->message_type(2); - static const int DescriptorProto_offsets_[10] = { + 0, + 1, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 3, + 4, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_), @@ -164,49 +145,20 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_), - }; - DescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_descriptor_, - DescriptorProto::internal_default_instance(), - DescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_), - -1, - -1, - sizeof(DescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_)); - DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0); - static const int DescriptorProto_ExtensionRange_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_), - }; - DescriptorProto_ExtensionRange_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_ExtensionRange_descriptor_, - DescriptorProto_ExtensionRange::internal_default_instance(), - DescriptorProto_ExtensionRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_), - -1, - -1, - sizeof(DescriptorProto_ExtensionRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_)); - DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1); - static const int DescriptorProto_ReservedRange_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_), - }; - DescriptorProto_ReservedRange_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DescriptorProto_ReservedRange_descriptor_, - DescriptorProto_ReservedRange::internal_default_instance(), - DescriptorProto_ReservedRange_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_), - -1, - -1, - sizeof(DescriptorProto_ReservedRange), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_)); - FieldDescriptorProto_descriptor_ = file->message_type(3); - static const int FieldDescriptorProto_offsets_[10] = { + 0, + 2, + 3, + 4, + 5, + 6, + 7, + 1, + 8, + 9, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_), @@ -217,103 +169,74 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_), - }; - FieldDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldDescriptorProto_descriptor_, - FieldDescriptorProto::internal_default_instance(), - FieldDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_), - -1, - -1, - sizeof(FieldDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_)); - FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0); - FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1); - OneofDescriptorProto_descriptor_ = file->message_type(4); - static const int OneofDescriptorProto_offsets_[2] = { + 0, + 6, + 8, + 9, + 1, + 2, + 3, + 7, + 4, + 5, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_), - }; - OneofDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - OneofDescriptorProto_descriptor_, - OneofDescriptorProto::internal_default_instance(), - OneofDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_), - -1, - -1, - sizeof(OneofDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_)); - EnumDescriptorProto_descriptor_ = file->message_type(5); - static const int EnumDescriptorProto_offsets_[3] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_), - }; - EnumDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumDescriptorProto_descriptor_, - EnumDescriptorProto::internal_default_instance(), - EnumDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_), - -1, - -1, - sizeof(EnumDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_)); - EnumValueDescriptorProto_descriptor_ = file->message_type(6); - static const int EnumValueDescriptorProto_offsets_[3] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_), - }; - EnumValueDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValueDescriptorProto_descriptor_, - EnumValueDescriptorProto::internal_default_instance(), - EnumValueDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_), - -1, - -1, - sizeof(EnumValueDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_)); - ServiceDescriptorProto_descriptor_ = file->message_type(7); - static const int ServiceDescriptorProto_offsets_[3] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_), - }; - ServiceDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ServiceDescriptorProto_descriptor_, - ServiceDescriptorProto::internal_default_instance(), - ServiceDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_), - -1, - -1, - sizeof(ServiceDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_)); - MethodDescriptorProto_descriptor_ = file->message_type(8); - static const int MethodDescriptorProto_offsets_[6] = { + 0, + 2, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_), - }; - MethodDescriptorProto_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MethodDescriptorProto_descriptor_, - MethodDescriptorProto::internal_default_instance(), - MethodDescriptorProto_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_), - -1, - -1, - sizeof(MethodDescriptorProto), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_)); - FileOptions_descriptor_ = file->message_type(9); - static const int FileOptions_offsets_[15] = { + 0, + 1, + 2, + 3, + 4, + 5, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_), @@ -328,39 +251,42 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, swift_prefix_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_), - }; - FileOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FileOptions_descriptor_, - FileOptions::internal_default_instance(), - FileOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_), - sizeof(FileOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_)); - FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0); - MessageOptions_descriptor_ = file->message_type(10); - static const int MessageOptions_offsets_[5] = { + 0, + 1, + 6, + 7, + 8, + 14, + 2, + 9, + 10, + 11, + 12, + 13, + 3, + 4, + 5, + 15, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_), - }; - MessageOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MessageOptions_descriptor_, - MessageOptions::internal_default_instance(), - MessageOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_), - sizeof(MessageOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_)); - FieldOptions_descriptor_ = file->message_type(11); - static const int FieldOptions_offsets_[7] = { + 0, + 1, + 2, + 3, + 4, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_), @@ -368,96 +294,67 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_), - }; - FieldOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldOptions_descriptor_, - FieldOptions::internal_default_instance(), - FieldOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_), - sizeof(FieldOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_)); - FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0); - FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1); - OneofOptions_descriptor_ = file->message_type(12); - static const int OneofOptions_offsets_[1] = { + 0, + 2, + 1, + 3, + 4, + 5, + 6, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_), - }; - OneofOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - OneofOptions_descriptor_, - OneofOptions::internal_default_instance(), - OneofOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_), - sizeof(OneofOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_)); - EnumOptions_descriptor_ = file->message_type(13); - static const int EnumOptions_offsets_[3] = { + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_), - }; - EnumOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumOptions_descriptor_, - EnumOptions::internal_default_instance(), - EnumOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_), - sizeof(EnumOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_)); - EnumValueOptions_descriptor_ = file->message_type(14); - static const int EnumValueOptions_offsets_[2] = { + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_), - }; - EnumValueOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValueOptions_descriptor_, - EnumValueOptions::internal_default_instance(), - EnumValueOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_), - sizeof(EnumValueOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_)); - ServiceOptions_descriptor_ = file->message_type(15); - static const int ServiceOptions_offsets_[2] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_), - }; - ServiceOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ServiceOptions_descriptor_, - ServiceOptions::internal_default_instance(), - ServiceOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_), - sizeof(ServiceOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_)); - MethodOptions_descriptor_ = file->message_type(16); - static const int MethodOptions_offsets_[2] = { + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, idempotency_level_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_), - }; - MethodOptions_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - MethodOptions_descriptor_, - MethodOptions::internal_default_instance(), - MethodOptions_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_), - -1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_), - sizeof(MethodOptions), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_)); - UninterpretedOption_descriptor_ = file->message_type(17); - static const int UninterpretedOption_offsets_[7] = { + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), + 0, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_), @@ -465,426 +362,384 @@ void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_), - }; - UninterpretedOption_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UninterpretedOption_descriptor_, - UninterpretedOption::internal_default_instance(), - UninterpretedOption_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_), - -1, - -1, - sizeof(UninterpretedOption), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_)); - UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0); - static const int UninterpretedOption_NamePart_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_), - }; - UninterpretedOption_NamePart_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UninterpretedOption_NamePart_descriptor_, - UninterpretedOption_NamePart::internal_default_instance(), - UninterpretedOption_NamePart_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_), - -1, - -1, - sizeof(UninterpretedOption_NamePart), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_)); - SourceCodeInfo_descriptor_ = file->message_type(18); - static const int SourceCodeInfo_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), - }; - SourceCodeInfo_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceCodeInfo_descriptor_, - SourceCodeInfo::internal_default_instance(), - SourceCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), - -1, - -1, - sizeof(SourceCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_)); - SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0); - static const int SourceCodeInfo_Location_offsets_[5] = { + 6, + 0, + 3, + 4, + 5, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_), - }; - SourceCodeInfo_Location_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceCodeInfo_Location_descriptor_, - SourceCodeInfo_Location::internal_default_instance(), - SourceCodeInfo_Location_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_), - -1, - -1, - sizeof(SourceCodeInfo_Location), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_)); - GeneratedCodeInfo_descriptor_ = file->message_type(19); - static const int GeneratedCodeInfo_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), - }; - GeneratedCodeInfo_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - GeneratedCodeInfo_descriptor_, - GeneratedCodeInfo::internal_default_instance(), - GeneratedCodeInfo_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), - -1, - -1, - sizeof(GeneratedCodeInfo), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_)); - GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0); - static const int GeneratedCodeInfo_Annotation_offsets_[4] = { + 2, + 3, + 0, + 1, + 4, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_), + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_), + 3, + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_), + 0, }; - GeneratedCodeInfo_Annotation_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - GeneratedCodeInfo_Annotation_descriptor_, - GeneratedCodeInfo_Annotation::internal_default_instance(), - GeneratedCodeInfo_Annotation_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_), - -1, - -1, - sizeof(GeneratedCodeInfo_Annotation), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_)); -} + return offsets; +} + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 5, sizeof(FileDescriptorSet)}, + { 6, 22, sizeof(FileDescriptorProto)}, + { 34, 40, sizeof(DescriptorProto_ExtensionRange)}, + { 42, 48, sizeof(DescriptorProto_ReservedRange)}, + { 50, 64, sizeof(DescriptorProto)}, + { 74, 88, sizeof(FieldDescriptorProto)}, + { 98, 104, sizeof(OneofDescriptorProto)}, + { 106, 113, sizeof(EnumDescriptorProto)}, + { 116, 123, sizeof(EnumValueDescriptorProto)}, + { 126, 133, sizeof(ServiceDescriptorProto)}, + { 136, 146, sizeof(MethodDescriptorProto)}, + { 152, 172, sizeof(FileOptions)}, + { 188, 197, sizeof(MessageOptions)}, + { 202, 213, sizeof(FieldOptions)}, + { 220, 225, sizeof(OneofOptions)}, + { 226, 233, sizeof(EnumOptions)}, + { 236, 242, sizeof(EnumValueOptions)}, + { 244, 250, sizeof(ServiceOptions)}, + { 252, 259, sizeof(MethodOptions)}, + { 262, 268, sizeof(UninterpretedOption_NamePart)}, + { 270, 281, sizeof(UninterpretedOption)}, + { 288, 297, sizeof(SourceCodeInfo_Location)}, + { 302, 307, sizeof(SourceCodeInfo)}, + { 308, 316, sizeof(GeneratedCodeInfo_Annotation)}, + { 320, 325, sizeof(GeneratedCodeInfo)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorSet_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ExtensionRange_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_ReservedRange_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_DescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_OneofDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MethodDescriptorProto_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FileOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MessageOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_OneofOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValueOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ServiceOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_MethodOptions_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_NamePart_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UninterpretedOption_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_Location_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceCodeInfo_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_Annotation_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_GeneratedCodeInfo_default_instance_), NULL}, +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/descriptor.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorSet_descriptor_, FileDescriptorSet::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileDescriptorProto_descriptor_, FileDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_descriptor_, DescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ExtensionRange_descriptor_, DescriptorProto_ExtensionRange::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DescriptorProto_ReservedRange_descriptor_, DescriptorProto_ReservedRange::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldDescriptorProto_descriptor_, FieldDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofDescriptorProto_descriptor_, OneofDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumDescriptorProto_descriptor_, EnumDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueDescriptorProto_descriptor_, EnumValueDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceDescriptorProto_descriptor_, ServiceDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodDescriptorProto_descriptor_, MethodDescriptorProto::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FileOptions_descriptor_, FileOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MessageOptions_descriptor_, MessageOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldOptions_descriptor_, FieldOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - OneofOptions_descriptor_, OneofOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumOptions_descriptor_, EnumOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValueOptions_descriptor_, EnumValueOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ServiceOptions_descriptor_, ServiceOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - MethodOptions_descriptor_, MethodOptions::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_descriptor_, UninterpretedOption::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UninterpretedOption_NamePart_descriptor_, UninterpretedOption_NamePart::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_descriptor_, SourceCodeInfo::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceCodeInfo_Location_descriptor_, SourceCodeInfo_Location::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_descriptor_, GeneratedCodeInfo::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - GeneratedCodeInfo_Annotation_descriptor_, GeneratedCodeInfo_Annotation::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 25); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() { - FileDescriptorSet_default_instance_.Shutdown(); - delete FileDescriptorSet_reflection_; - FileDescriptorProto_default_instance_.Shutdown(); - delete FileDescriptorProto_reflection_; - DescriptorProto_default_instance_.Shutdown(); - delete DescriptorProto_reflection_; - DescriptorProto_ExtensionRange_default_instance_.Shutdown(); - delete DescriptorProto_ExtensionRange_reflection_; - DescriptorProto_ReservedRange_default_instance_.Shutdown(); - delete DescriptorProto_ReservedRange_reflection_; - FieldDescriptorProto_default_instance_.Shutdown(); - delete FieldDescriptorProto_reflection_; - OneofDescriptorProto_default_instance_.Shutdown(); - delete OneofDescriptorProto_reflection_; - EnumDescriptorProto_default_instance_.Shutdown(); - delete EnumDescriptorProto_reflection_; - EnumValueDescriptorProto_default_instance_.Shutdown(); - delete EnumValueDescriptorProto_reflection_; - ServiceDescriptorProto_default_instance_.Shutdown(); - delete ServiceDescriptorProto_reflection_; - MethodDescriptorProto_default_instance_.Shutdown(); - delete MethodDescriptorProto_reflection_; - FileOptions_default_instance_.Shutdown(); - delete FileOptions_reflection_; - MessageOptions_default_instance_.Shutdown(); - delete MessageOptions_reflection_; - FieldOptions_default_instance_.Shutdown(); - delete FieldOptions_reflection_; - OneofOptions_default_instance_.Shutdown(); - delete OneofOptions_reflection_; - EnumOptions_default_instance_.Shutdown(); - delete EnumOptions_reflection_; - EnumValueOptions_default_instance_.Shutdown(); - delete EnumValueOptions_reflection_; - ServiceOptions_default_instance_.Shutdown(); - delete ServiceOptions_reflection_; - MethodOptions_default_instance_.Shutdown(); - delete MethodOptions_reflection_; - UninterpretedOption_default_instance_.Shutdown(); - delete UninterpretedOption_reflection_; - UninterpretedOption_NamePart_default_instance_.Shutdown(); - delete UninterpretedOption_NamePart_reflection_; - SourceCodeInfo_default_instance_.Shutdown(); - delete SourceCodeInfo_reflection_; - SourceCodeInfo_Location_default_instance_.Shutdown(); - delete SourceCodeInfo_Location_reflection_; - GeneratedCodeInfo_default_instance_.Shutdown(); - delete GeneratedCodeInfo_reflection_; - GeneratedCodeInfo_Annotation_default_instance_.Shutdown(); - delete GeneratedCodeInfo_Annotation_reflection_; + _FileDescriptorSet_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _FileDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _DescriptorProto_ExtensionRange_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _DescriptorProto_ReservedRange_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _DescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; + _FieldDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[5].reflection; + _OneofDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[6].reflection; + _EnumDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[7].reflection; + _EnumValueDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[8].reflection; + _ServiceDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[9].reflection; + _MethodDescriptorProto_default_instance_.Shutdown(); + delete file_level_metadata[10].reflection; + _FileOptions_default_instance_.Shutdown(); + delete file_level_metadata[11].reflection; + _MessageOptions_default_instance_.Shutdown(); + delete file_level_metadata[12].reflection; + _FieldOptions_default_instance_.Shutdown(); + delete file_level_metadata[13].reflection; + _OneofOptions_default_instance_.Shutdown(); + delete file_level_metadata[14].reflection; + _EnumOptions_default_instance_.Shutdown(); + delete file_level_metadata[15].reflection; + _EnumValueOptions_default_instance_.Shutdown(); + delete file_level_metadata[16].reflection; + _ServiceOptions_default_instance_.Shutdown(); + delete file_level_metadata[17].reflection; + _MethodOptions_default_instance_.Shutdown(); + delete file_level_metadata[18].reflection; + _UninterpretedOption_NamePart_default_instance_.Shutdown(); + delete file_level_metadata[19].reflection; + _UninterpretedOption_default_instance_.Shutdown(); + delete file_level_metadata[20].reflection; + _SourceCodeInfo_Location_default_instance_.Shutdown(); + delete file_level_metadata[21].reflection; + _SourceCodeInfo_default_instance_.Shutdown(); + delete file_level_metadata[22].reflection; + _GeneratedCodeInfo_Annotation_default_instance_.Shutdown(); + delete file_level_metadata[23].reflection; + _GeneratedCodeInfo_default_instance_.Shutdown(); + delete file_level_metadata[24].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - FileDescriptorSet_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FileDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - DescriptorProto_default_instance_.DefaultConstruct(); - DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct(); - DescriptorProto_ReservedRange_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FieldDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - OneofDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumValueDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - ServiceDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - MethodDescriptorProto_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - FileOptions_default_instance_.DefaultConstruct(); - MessageOptions_default_instance_.DefaultConstruct(); - FieldOptions_default_instance_.DefaultConstruct(); - OneofOptions_default_instance_.DefaultConstruct(); - EnumOptions_default_instance_.DefaultConstruct(); - EnumValueOptions_default_instance_.DefaultConstruct(); - ServiceOptions_default_instance_.DefaultConstruct(); - MethodOptions_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - UninterpretedOption_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - UninterpretedOption_NamePart_default_instance_.DefaultConstruct(); - SourceCodeInfo_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - SourceCodeInfo_Location_default_instance_.DefaultConstruct(); - GeneratedCodeInfo_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct(); - FileDescriptorSet_default_instance_.get_mutable()->InitAsDefaultInstance(); - FileDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_ExtensionRange_default_instance_.get_mutable()->InitAsDefaultInstance(); - DescriptorProto_ReservedRange_default_instance_.get_mutable()->InitAsDefaultInstance(); - FieldDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - OneofDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValueDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - ServiceDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - MethodDescriptorProto_default_instance_.get_mutable()->InitAsDefaultInstance(); - FileOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - MessageOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - FieldOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - OneofOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValueOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - ServiceOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - MethodOptions_default_instance_.get_mutable()->InitAsDefaultInstance(); - UninterpretedOption_default_instance_.get_mutable()->InitAsDefaultInstance(); - UninterpretedOption_NamePart_default_instance_.get_mutable()->InitAsDefaultInstance(); - SourceCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance(); - SourceCodeInfo_Location_default_instance_.get_mutable()->InitAsDefaultInstance(); - GeneratedCodeInfo_default_instance_.get_mutable()->InitAsDefaultInstance(); - GeneratedCodeInfo_Annotation_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_); + ::google::protobuf::internal::InitProtobufDefaults(); + _FileDescriptorSet_default_instance_.DefaultConstruct(); + _FileDescriptorProto_default_instance_.DefaultConstruct(); + _DescriptorProto_ExtensionRange_default_instance_.DefaultConstruct(); + _DescriptorProto_ReservedRange_default_instance_.DefaultConstruct(); + _DescriptorProto_default_instance_.DefaultConstruct(); + _FieldDescriptorProto_default_instance_.DefaultConstruct(); + _OneofDescriptorProto_default_instance_.DefaultConstruct(); + _EnumDescriptorProto_default_instance_.DefaultConstruct(); + _EnumValueDescriptorProto_default_instance_.DefaultConstruct(); + _ServiceDescriptorProto_default_instance_.DefaultConstruct(); + _MethodDescriptorProto_default_instance_.DefaultConstruct(); + _FileOptions_default_instance_.DefaultConstruct(); + _MessageOptions_default_instance_.DefaultConstruct(); + _FieldOptions_default_instance_.DefaultConstruct(); + _OneofOptions_default_instance_.DefaultConstruct(); + _EnumOptions_default_instance_.DefaultConstruct(); + _EnumValueOptions_default_instance_.DefaultConstruct(); + _ServiceOptions_default_instance_.DefaultConstruct(); + _MethodOptions_default_instance_.DefaultConstruct(); + _UninterpretedOption_NamePart_default_instance_.DefaultConstruct(); + _UninterpretedOption_default_instance_.DefaultConstruct(); + _SourceCodeInfo_Location_default_instance_.DefaultConstruct(); + _SourceCodeInfo_default_instance_.DefaultConstruct(); + _GeneratedCodeInfo_Annotation_default_instance_.DefaultConstruct(); + _GeneratedCodeInfo_default_instance_.DefaultConstruct(); + _FileDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FileOptions*>( + ::google::protobuf::FileOptions::internal_default_instance()); + _FileDescriptorProto_default_instance_.get_mutable()->source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( + ::google::protobuf::SourceCodeInfo::internal_default_instance()); + _DescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MessageOptions*>( + ::google::protobuf::MessageOptions::internal_default_instance()); + _FieldDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::FieldOptions*>( + ::google::protobuf::FieldOptions::internal_default_instance()); + _OneofDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::OneofOptions*>( + ::google::protobuf::OneofOptions::internal_default_instance()); + _EnumDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumOptions*>( + ::google::protobuf::EnumOptions::internal_default_instance()); + _EnumValueDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::EnumValueOptions*>( + ::google::protobuf::EnumValueOptions::internal_default_instance()); + _ServiceDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::ServiceOptions*>( + ::google::protobuf::ServiceOptions::internal_default_instance()); + _MethodDescriptorProto_default_instance_.get_mutable()->options_ = const_cast< ::google::protobuf::MethodOptions*>( + ::google::protobuf::MethodOptions::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + static const char descriptor[] = { + "\n google/protobuf/descriptor.proto\022\017goog" + "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" + "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" + "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" + "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" + "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" + "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" + "le.protobuf.DescriptorProto\0227\n\tenum_type" + "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" + "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." + "ServiceDescriptorProto\0228\n\textension\030\007 \003(" + "\0132%.google.protobuf.FieldDescriptorProto" + "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" + "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" + "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" + "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" + "field\030\002 \003(\0132%.google.protobuf.FieldDescr" + "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p" + "rotobuf.FieldDescriptorProto\0225\n\013nested_t" + "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr" + "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf" + ".EnumDescriptorProto\022H\n\017extension_range\030" + "\005 \003(\0132/.google.protobuf.DescriptorProto." + "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo" + "gle.protobuf.OneofDescriptorProto\0220\n\007opt" + "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti" + "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro" + "tobuf.DescriptorProto.ReservedRange\022\025\n\rr" + "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005" + "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang" + "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD" + "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003" + " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi" + "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*" + ".google.protobuf.FieldDescriptorProto.Ty" + "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022" + "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t " + "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132" + "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022" + "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE" + "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020" + "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n" + "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR" + "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022" + "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_" + "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI" + "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE" + "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE" + "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004" + "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro" + "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro" + "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google" + ".protobuf.EnumValueDescriptorProto\022-\n\007op" + "tions\030\003 \001(\0132\034.google.protobuf.EnumOption" + "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 " + "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g" + "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv" + "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth" + "od\030\002 \003(\0132&.google.protobuf.MethodDescrip" + "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto" + "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP" + "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023" + "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" + "oogle.protobuf.MethodOptions\022\037\n\020client_s" + "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" + "g\030\006 \001(\010:\005false\"\232\005\n\013FileOptions\022\024\n\014java_p" + "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" + "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)" + "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030" + "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false" + "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf" + ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p" + "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(" + "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:" + "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal" + "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" + "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" + "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014s" + "wift_prefix\030\' \001(\t\022C\n\024uninterpreted_optio" + "n\030\347\007 \003(\0132$.google.protobuf.Uninterpreted" + "Option\":\n\014OptimizeMode\022\t\n\005SPEED\020\001\022\r\n\tCOD" + "E_SIZE\020\002\022\020\n\014LITE_RUNTIME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010" + "&\020\'\"\354\001\n\016MessageOptions\022&\n\027message_set_wi" + "re_format\030\001 \001(\010:\005false\022.\n\037no_standard_de" + "scriptor_accessor\030\002 \001(\010:\005false\022\031\n\ndeprec" + "ated\030\003 \001(\010:\005false\022\021\n\tmap_entry\030\007 \001(\010\022C\n\024" + "uninterpreted_option\030\347\007 \003(\0132$.google.pro" + "tobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002J\004\010\010" + "\020\t\"\236\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goo" + "gle.protobuf.FieldOptions.CType:\006STRING\022" + "\016\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google" + ".protobuf.FieldOptions.JSType:\tJS_NORMAL" + "\022\023\n\004lazy\030\005 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(" + "\010:\005false\022\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninter" + "preted_option\030\347\007 \003(\0132$.google.protobuf.U" + "ninterpretedOption\"/\n\005CType\022\n\n\006STRING\020\000\022" + "\010\n\004CORD\020\001\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n" + "\tJS_NORMAL\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER" + "\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024u" + "ninterpreted_option\030\347\007 \003(\0132$.google.prot" + "obuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013" + "EnumOptions\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndepr" + "ecated\030\003 \001(\010:\005false\022C\n\024uninterpreted_opt" + "ion\030\347\007 \003(\0132$.google.protobuf.Uninterpret" + "edOption*\t\010\350\007\020\200\200\200\200\002\"}\n\020EnumValueOptions\022" + "\031\n\ndeprecated\030\001 \001(\010:\005false\022C\n\024uninterpre" + "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" + "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOpt" + "ions\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024unint" + "erpreted_option\030\347\007 \003(\0132$.google.protobuf" + ".UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMeth" + "odOptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021" + "idempotency_level\030\" \001(\0162/.google.protobu" + "f.MethodOptions.IdempotencyLevel:\023IDEMPO" + "TENCY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007" + " \003(\0132$.google.protobuf.UninterpretedOpti" + "on\"P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UN" + "KNOWN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTE" + "NT\020\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022" + ";\n\004name\030\002 \003(\0132-.google.protobuf.Uninterp" + "retedOption.NamePart\022\030\n\020identifier_value" + "\030\003 \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022ne" + "gative_int_value\030\005 \001(\003\022\024\n\014double_value\030\006" + " \001(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_" + "value\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002" + "(\t\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeI" + "nfo\022:\n\010location\030\001 \003(\0132(.google.protobuf." + "SourceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004" + "path\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020lead" + "ing_comments\030\003 \001(\t\022\031\n\021trailing_comments\030" + "\004 \001(\t\022!\n\031leading_detached_comments\030\006 \003(\t" + "\"\247\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003" + "(\0132-.google.protobuf.GeneratedCodeInfo.A" + "nnotation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020" + "\001\022\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n" + "\003end\030\004 \001(\005BX\n\023com.google.protobufB\020Descr" + "iptorProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google" + ".Protobuf.Reflection" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n google/protobuf/descriptor.proto\022\017goog" - "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" - "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" - "roto\"\333\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" - "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" - "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" - "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." - "ServiceDescriptorProto\0228\n\textension\030\007 \003(" - "\0132%.google.protobuf.FieldDescriptorProto" - "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" - "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" - "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" - "(\t\"\360\004\n\017DescriptorProto\022\014\n\004name\030\001 \001(\t\0224\n\005" - "field\030\002 \003(\0132%.google.protobuf.FieldDescr" - "iptorProto\0228\n\textension\030\006 \003(\0132%.google.p" - "rotobuf.FieldDescriptorProto\0225\n\013nested_t" - "ype\030\003 \003(\0132 .google.protobuf.DescriptorPr" - "oto\0227\n\tenum_type\030\004 \003(\0132$.google.protobuf" - ".EnumDescriptorProto\022H\n\017extension_range\030" - "\005 \003(\0132/.google.protobuf.DescriptorProto." - "ExtensionRange\0229\n\noneof_decl\030\010 \003(\0132%.goo" - "gle.protobuf.OneofDescriptorProto\0220\n\007opt" - "ions\030\007 \001(\0132\037.google.protobuf.MessageOpti" - "ons\022F\n\016reserved_range\030\t \003(\0132..google.pro" - "tobuf.DescriptorProto.ReservedRange\022\025\n\rr" - "eserved_name\030\n \003(\t\032,\n\016ExtensionRange\022\r\n\005" - "start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\032+\n\rReservedRang" - "e\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"\274\005\n\024FieldD" - "escriptorProto\022\014\n\004name\030\001 \001(\t\022\016\n\006number\030\003" - " \001(\005\022:\n\005label\030\004 \001(\0162+.google.protobuf.Fi" - "eldDescriptorProto.Label\0228\n\004type\030\005 \001(\0162*" - ".google.protobuf.FieldDescriptorProto.Ty" - "pe\022\021\n\ttype_name\030\006 \001(\t\022\020\n\010extendee\030\002 \001(\t\022" - "\025\n\rdefault_value\030\007 \001(\t\022\023\n\013oneof_index\030\t " - "\001(\005\022\021\n\tjson_name\030\n \001(\t\022.\n\007options\030\010 \001(\0132" - "\035.google.protobuf.FieldOptions\"\266\002\n\004Type\022" - "\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE" - "_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020" - "\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n" - "\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GR" - "OUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022" - "\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_" - "SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SI" - "NT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016LABE" - "L_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016LABE" - "L_REPEATED\020\003\"T\n\024OneofDescriptorProto\022\014\n\004" - "name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google.pro" - "tobuf.OneofOptions\"\214\001\n\023EnumDescriptorPro" - "to\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).google" - ".protobuf.EnumValueDescriptorProto\022-\n\007op" - "tions\030\003 \001(\0132\034.google.protobuf.EnumOption" - "s\"l\n\030EnumValueDescriptorProto\022\014\n\004name\030\001 " - "\001(\t\022\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.g" - "oogle.protobuf.EnumValueOptions\"\220\001\n\026Serv" - "iceDescriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006meth" - "od\030\002 \003(\0132&.google.protobuf.MethodDescrip" - "torProto\0220\n\007options\030\003 \001(\0132\037.google.proto" - "buf.ServiceOptions\"\301\001\n\025MethodDescriptorP" - "roto\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023" - "\n\013output_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.g" - "oogle.protobuf.MethodOptions\022\037\n\020client_s" - "treaming\030\005 \001(\010:\005false\022\037\n\020server_streamin" - "g\030\006 \001(\010:\005false\"\204\005\n\013FileOptions\022\024\n\014java_p" - "ackage\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001" - "(\t\022\"\n\023java_multiple_files\030\n \001(\010:\005false\022)" - "\n\035java_generate_equals_and_hash\030\024 \001(\010B\002\030" - "\001\022%\n\026java_string_check_utf8\030\033 \001(\010:\005false" - "\022F\n\014optimize_for\030\t \001(\0162).google.protobuf" - ".FileOptions.OptimizeMode:\005SPEED\022\022\n\ngo_p" - "ackage\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(" - "\010:\005false\022$\n\025java_generic_services\030\021 \001(\010:" - "\005false\022\"\n\023py_generic_services\030\022 \001(\010:\005fal" - "se\022\031\n\ndeprecated\030\027 \001(\010:\005false\022\037\n\020cc_enab" - "le_arenas\030\037 \001(\010:\005false\022\031\n\021objc_class_pre" - "fix\030$ \001(\t\022\030\n\020csharp_namespace\030% \001(\t\022C\n\024u" - "ninterpreted_option\030\347\007 \003(\0132$.google.prot" - "obuf.UninterpretedOption\":\n\014OptimizeMode" - "\022\t\n\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTI" - "ME\020\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\354\001\n\016MessageOptions" - "\022&\n\027message_set_wire_format\030\001 \001(\010:\005false" - "\022.\n\037no_standard_descriptor_accessor\030\002 \001(" - "\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tm" - "ap_entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347" - "\007 \003(\0132$.google.protobuf.UninterpretedOpt" - "ion*\t\010\350\007\020\200\200\200\200\002J\004\010\010\020\t\"\236\003\n\014FieldOptions\022:\n" - "\005ctype\030\001 \001(\0162#.google.protobuf.FieldOpti" - "ons.CType:\006STRING\022\016\n\006packed\030\002 \001(\010\022\?\n\006jst" - "ype\030\006 \001(\0162$.google.protobuf.FieldOptions" - ".JSType:\tJS_NORMAL\022\023\n\004lazy\030\005 \001(\010:\005false\022" - "\031\n\ndeprecated\030\003 \001(\010:\005false\022\023\n\004weak\030\n \001(\010" - ":\005false\022C\n\024uninterpreted_option\030\347\007 \003(\0132$" - ".google.protobuf.UninterpretedOption\"/\n\005" - "CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001\022\020\n\014STRING_PI" - "ECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMAL\020\000\022\r\n\tJS_STR" - "ING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005\"^\n" - "\014OneofOptions\022C\n\024uninterpreted_option\030\347\007" - " \003(\0132$.google.protobuf.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"\215\001\n\013EnumOptions\022\023\n\013allow_a" - "lias\030\002 \001(\010\022\031\n\ndeprecated\030\003 \001(\010:\005false\022C\n" - "\024uninterpreted_option\030\347\007 \003(\0132$.google.pr" - "otobuf.UninterpretedOption*\t\010\350\007\020\200\200\200\200\002\"}\n" - "\020EnumValueOptions\022\031\n\ndeprecated\030\001 \001(\010:\005f" - "alse\022C\n\024uninterpreted_option\030\347\007 \003(\0132$.go" - "ogle.protobuf.UninterpretedOption*\t\010\350\007\020\200" - "\200\200\200\002\"{\n\016ServiceOptions\022\031\n\ndeprecated\030! \001" - "(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(\013" - "2$.google.protobuf.UninterpretedOption*\t" - "\010\350\007\020\200\200\200\200\002\"z\n\rMethodOptions\022\031\n\ndeprecated" - "\030! \001(\010:\005false\022C\n\024uninterpreted_option\030\347\007" - " \003(\0132$.google.protobuf.UninterpretedOpti" - "on*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n" - "\004name\030\002 \003(\0132-.google.protobuf.Uninterpre" - "tedOption.NamePart\022\030\n\020identifier_value\030\003" - " \001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022nega" - "tive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001" - "(\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_va" - "lue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t" - "\022\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInf" - "o\022:\n\010location\030\001 \003(\0132(.google.protobuf.So" - "urceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pa" - "th\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leadin" - "g_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 " - "\001(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\247" - "\001\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\013" - "2-.google.protobuf.GeneratedCodeInfo.Ann" - "otation\032O\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" - "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" - "nd\030\004 \001(\005BX\n\023com.google.protobufB\020Descrip" - "torProtosH\001Z\ndescriptor\242\002\003GPB\252\002\032Google.P" - "rotobuf.Reflection", 5298); + descriptor, 5500); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/descriptor.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto); @@ -901,16 +756,174 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); } } static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_; +const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[0]; +} +bool FieldDescriptorProto_Type_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + return true; + default: + return false; + } +} -namespace { +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32; +const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64; +const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN; +const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX; +const int FieldDescriptorProto::Type_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[1]; +} +bool FieldDescriptorProto_Label_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } +} -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL; +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED; +const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED; +const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN; +const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX; +const int FieldDescriptorProto::Label_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[2]; +} +bool FileOptions_OptimizeMode_IsValid(int value) { + switch (value) { + case 1: + case 2: + case 3: + return true; + default: + return false; + } } -} // namespace +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FileOptions_OptimizeMode FileOptions::SPEED; +const FileOptions_OptimizeMode FileOptions::CODE_SIZE; +const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME; +const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; +const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; +const int FileOptions::OptimizeMode_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[3]; +} +bool FieldOptions_CType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldOptions_CType FieldOptions::STRING; +const FieldOptions_CType FieldOptions::CORD; +const FieldOptions_CType FieldOptions::STRING_PIECE; +const FieldOptions_CType FieldOptions::CType_MIN; +const FieldOptions_CType FieldOptions::CType_MAX; +const int FieldOptions::CType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[4]; +} +bool FieldOptions_JSType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const FieldOptions_JSType FieldOptions::JS_NORMAL; +const FieldOptions_JSType FieldOptions::JS_STRING; +const FieldOptions_JSType FieldOptions::JS_NUMBER; +const FieldOptions_JSType FieldOptions::JSType_MIN; +const FieldOptions_JSType FieldOptions::JSType_MAX; +const int FieldOptions::JSType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[5]; +} +bool MethodOptions_IdempotencyLevel_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENCY_UNKNOWN; +const MethodOptions_IdempotencyLevel MethodOptions::NO_SIDE_EFFECTS; +const MethodOptions_IdempotencyLevel MethodOptions::IDEMPOTENT; +const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MIN; +const MethodOptions_IdempotencyLevel MethodOptions::IdempotencyLevel_MAX; +const int MethodOptions::IdempotencyLevel_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 // =================================================================== @@ -920,19 +933,19 @@ const int FileDescriptorSet::kFileFieldNumber; FileDescriptorSet::FileDescriptorSet() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet) } - -void FileDescriptorSet::InitAsDefaultInstance() { -} - FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + file_(from.file_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet) } @@ -955,7 +968,7 @@ void FileDescriptorSet::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileDescriptorSet_descriptor_; + return file_level_metadata[0].descriptor; } const FileDescriptorSet& FileDescriptorSet::default_instance() { @@ -963,8 +976,6 @@ const FileDescriptorSet& FileDescriptorSet::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_; - FileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const { FileDescriptorSet* n = new FileDescriptorSet; if (arena != NULL) { @@ -977,9 +988,7 @@ void FileDescriptorSet::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet) file_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool FileDescriptorSet::MergePartialFromCodedStream( @@ -988,23 +997,20 @@ bool FileDescriptorSet::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.FileDescriptorProto file = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_file: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_file())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_file; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1069,6 +1075,11 @@ size_t FileDescriptorSet::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.FileDescriptorProto file = 1; { unsigned int count = this->file_size(); @@ -1080,11 +1091,6 @@ size_t FileDescriptorSet::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -1094,7 +1100,7 @@ size_t FileDescriptorSet::ByteSizeLong() const { void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileDescriptorSet* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>( &from); @@ -1103,26 +1109,15 @@ void FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FileDescriptorSet::UnsafeMergeFrom(const FileDescriptorSet& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); file_.MergeFrom(from.file_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) { @@ -1136,11 +1131,10 @@ void FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileDescriptorSet::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->file())) return false; return true; } @@ -1158,10 +1152,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { ::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorSet_descriptor_; - metadata.reflection = FileDescriptorSet_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1197,9 +1188,6 @@ FileDescriptorSet::file() const { return file_; } -inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() { - return &FileDescriptorSet_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1221,23 +1209,47 @@ const int FileDescriptorProto::kSyntaxFieldNumber; FileDescriptorProto::FileDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto) } - -void FileDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FileOptions*>( - ::google::protobuf::FileOptions::internal_default_instance()); - source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>( - ::google::protobuf::SourceCodeInfo::internal_default_instance()); -} - FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + dependency_(from.dependency_), + public_dependency_(from.public_dependency_), + weak_dependency_(from.weak_dependency_), + message_type_(from.message_type_), + enum_type_(from.enum_type_), + service_(from.service_), + extension_(from.extension_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_package()) { + package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); + } + syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_syntax()) { + syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::FileOptions(*from.options_); + } else { + options_ = NULL; + } + if (from.has_source_code_info()) { + source_code_info_ = new ::google::protobuf::SourceCodeInfo(*from.source_code_info_); + } else { + source_code_info_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto) } @@ -1246,8 +1258,8 @@ void FileDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - source_code_info_ = NULL; + ::memset(&options_, 0, reinterpret_cast<char*>(&source_code_info_) - + reinterpret_cast<char*>(&options_) + sizeof(source_code_info_)); } FileDescriptorProto::~FileDescriptorProto() { @@ -1259,8 +1271,10 @@ void FileDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &FileDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; + } + if (this != internal_default_instance()) { delete source_code_info_; } } @@ -1272,7 +1286,7 @@ void FileDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileDescriptorProto_descriptor_; + return file_level_metadata[1].descriptor; } const FileDescriptorProto& FileDescriptorProto::default_instance() { @@ -1280,8 +1294,6 @@ const FileDescriptorProto& FileDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_; - FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const { FileDescriptorProto* n = new FileDescriptorProto; if (arena != NULL) { @@ -1292,36 +1304,37 @@ FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) void FileDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto) - if (_has_bits_[0 / 32] & 3u) { + dependency_.Clear(); + public_dependency_.Clear(); + weak_dependency_.Clear(); + message_type_.Clear(); + enum_type_.Clear(); + service_.Clear(); + extension_.Clear(); + if (_has_bits_[0 / 32] & 31u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_package()) { - package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*package_.UnsafeRawStringPointer())->clear(); + } + if (has_syntax()) { + GOOGLE_DCHECK(!syntax_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*syntax_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 3584u) { if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::FileOptions::Clear(); } if (has_source_code_info()) { - if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); - } - if (has_syntax()) { - syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(source_code_info_ != NULL); + source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); } } - dependency_.Clear(); - public_dependency_.Clear(); - weak_dependency_.Clear(); - message_type_.Clear(); - enum_type_.Clear(); - service_.Clear(); - extension_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool FileDescriptorProto::MergePartialFromCodedStream( @@ -1330,13 +1343,13 @@ bool FileDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1346,14 +1359,12 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_package; break; } // optional string package = 2; case 2: { - if (tag == 18) { - parse_package: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1363,14 +1374,12 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_dependency; break; } // repeated string dependency = 3; case 3: { - if (tag == 26) { - parse_dependency: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_dependency())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1381,144 +1390,118 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_dependency; - if (input->ExpectTag(34)) goto parse_message_type; break; } // repeated .google.protobuf.DescriptorProto message_type = 4; case 4: { - if (tag == 34) { - parse_message_type: + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_message_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_message_type())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_message_type; - if (input->ExpectTag(42)) goto parse_loop_enum_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enum_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_loop_enum_type; - if (input->ExpectTag(50)) goto parse_loop_service; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.ServiceDescriptorProto service = 6; case 6: { - if (tag == 50) { + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_service: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_service())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_service; - if (input->ExpectTag(58)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.FieldDescriptorProto extension = 7; case 7: { - if (tag == 58) { + if (tag == 58u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(66)) goto parse_options; break; } // optional .google.protobuf.FileOptions options = 8; case 8: { - if (tag == 66) { - parse_options: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_source_code_info; break; } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; case 9: { - if (tag == 74) { - parse_source_code_info: + if (tag == 74u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_code_info())); } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_public_dependency; break; } // repeated int32 public_dependency = 10; case 10: { - if (tag == 80) { - parse_public_dependency: + if (tag == 80u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 80, input, this->mutable_public_dependency()))); - } else if (tag == 82) { + 1, 80u, input, this->mutable_public_dependency()))); + } else if (tag == 82u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_public_dependency()))); } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_public_dependency; - if (input->ExpectTag(88)) goto parse_weak_dependency; break; } // repeated int32 weak_dependency = 11; case 11: { - if (tag == 88) { - parse_weak_dependency: + if (tag == 88u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 88, input, this->mutable_weak_dependency()))); - } else if (tag == 90) { + 1, 88u, input, this->mutable_weak_dependency()))); + } else if (tag == 90u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_weak_dependency()))); } else { goto handle_unusual; } - if (input->ExpectTag(88)) goto parse_weak_dependency; - if (input->ExpectTag(98)) goto parse_syntax; break; } // optional string syntax = 12; case 12: { - if (tag == 98) { - parse_syntax: + if (tag == 98u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_syntax())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -1528,7 +1511,6 @@ bool FileDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1765,44 +1747,10 @@ size_t FileDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 3u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional string package = 2; - if (has_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->package()); - } - - } - if (_has_bits_[9 / 32] & 3584u) { - // optional .google.protobuf.FileOptions options = 8; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); - } - - // optional .google.protobuf.SourceCodeInfo source_code_info = 9; - if (has_source_code_info()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_code_info_); - } - - // optional string syntax = 12; - if (has_syntax()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->syntax()); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated string dependency = 3; total_size += 1 * @@ -1882,10 +1830,42 @@ size_t FileDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 31u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional string package = 2; + if (has_package()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->package()); + } + + // optional string syntax = 12; + if (has_syntax()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->syntax()); + } + + // optional .google.protobuf.FileOptions options = 8; + if (has_options()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->options_); + } + + // optional .google.protobuf.SourceCodeInfo source_code_info = 9; + if (has_source_code_info()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_code_info_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -1896,7 +1876,7 @@ size_t FileDescriptorProto::ByteSizeLong() const { void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>( &from); @@ -1905,29 +1885,22 @@ void FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); - dependency_.UnsafeMergeFrom(from.dependency_); - public_dependency_.UnsafeMergeFrom(from.public_dependency_); - weak_dependency_.UnsafeMergeFrom(from.weak_dependency_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + dependency_.MergeFrom(from.dependency_); + public_dependency_.MergeFrom(from.public_dependency_); + weak_dependency_.MergeFrom(from.weak_dependency_); message_type_.MergeFrom(from.message_type_); enum_type_.MergeFrom(from.enum_type_); service_.MergeFrom(from.service_); extension_.MergeFrom(from.extension_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 31u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -1936,22 +1909,16 @@ void FileDescriptorProto::UnsafeMergeFrom(const FileDescriptorProto& from) { set_has_package(); package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_); } - } - if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) { + if (from.has_syntax()) { + set_has_syntax(); + syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); + } if (from.has_options()) { mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options()); } if (from.has_source_code_info()) { mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info()); } - if (from.has_syntax()) { - set_has_syntax(); - syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); } } @@ -1966,11 +1933,10 @@ void FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->message_type())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->service())) return false; @@ -1986,8 +1952,6 @@ void FileDescriptorProto::Swap(FileDescriptorProto* other) { InternalSwap(other); } void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { - name_.Swap(&other->name_); - package_.Swap(&other->package_); dependency_.UnsafeArenaSwap(&other->dependency_); public_dependency_.UnsafeArenaSwap(&other->public_dependency_); weak_dependency_.UnsafeArenaSwap(&other->weak_dependency_); @@ -1995,9 +1959,11 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { enum_type_.UnsafeArenaSwap(&other->enum_type_); service_.UnsafeArenaSwap(&other->service_); extension_.UnsafeArenaSwap(&other->extension_); + name_.Swap(&other->name_); + package_.Swap(&other->package_); + syntax_.Swap(&other->syntax_); std::swap(options_, other->options_); std::swap(source_code_info_, other->source_code_info_); - syntax_.Swap(&other->syntax_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -2005,10 +1971,7 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { ::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileDescriptorProto_descriptor_; - metadata.reflection = FileDescriptorProto_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -2030,7 +1993,7 @@ void FileDescriptorProto::clear_name() { } const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -2084,7 +2047,7 @@ void FileDescriptorProto::clear_package() { } const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.GetNoArena(); } void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); @@ -2359,13 +2322,13 @@ FileDescriptorProto::extension() const { // optional .google.protobuf.FileOptions options = 8; bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000008u; } void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000008u; } void FileDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); @@ -2404,13 +2367,13 @@ void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* // optional .google.protobuf.SourceCodeInfo source_code_info = 9; bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000010u; } void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000010u; } void FileDescriptorProto::clear_source_code_info() { if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); @@ -2449,13 +2412,13 @@ void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::Sou // optional string syntax = 12; bool FileDescriptorProto::has_syntax() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FileDescriptorProto::set_has_syntax() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000004u; } void FileDescriptorProto::clear_has_syntax() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000004u; } void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -2463,7 +2426,7 @@ void FileDescriptorProto::clear_syntax() { } const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.GetNoArena(); } void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); @@ -2501,9 +2464,6 @@ void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } -inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() { - return &FileDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2515,19 +2475,21 @@ const int DescriptorProto_ExtensionRange::kEndFieldNumber; DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange) } - -void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { -} - DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&start_, &from.start_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange) } @@ -2552,7 +2514,7 @@ void DescriptorProto_ExtensionRange::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ExtensionRange_descriptor_; + return file_level_metadata[2].descriptor; } const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() { @@ -2560,8 +2522,6 @@ const DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_in return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange_default_instance_; - DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange; if (arena != NULL) { @@ -2572,31 +2532,12 @@ DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::pr void DescriptorProto_ExtensionRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(DescriptorProto_ExtensionRange, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<DescriptorProto_ExtensionRange*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(start_, end_); - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( @@ -2605,13 +2546,13 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2619,14 +2560,12 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_end; break; } // optional int32 end = 2; case 2: { - if (tag == 16) { - parse_end: + if (tag == 16u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2634,7 +2573,6 @@ bool DescriptorProto_ExtensionRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2706,6 +2644,11 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; if (has_start()) { @@ -2722,11 +2665,6 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -2736,7 +2674,7 @@ size_t DescriptorProto_ExtensionRange::ByteSizeLong() const { void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto_ExtensionRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>( &from); @@ -2745,22 +2683,15 @@ void DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_start()) { set_start(from.start()); } @@ -2768,10 +2699,6 @@ void DescriptorProto_ExtensionRange::UnsafeMergeFrom(const DescriptorProto_Exten set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) { @@ -2785,11 +2712,10 @@ void DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRan // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto_ExtensionRange::IsInitialized() const { - return true; } @@ -2807,14 +2733,63 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange ::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_ExtensionRange_descriptor_; - metadata.reflection = DescriptorProto_ExtensionRange_reflection_; - return metadata; + return file_level_metadata[2]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DescriptorProto_ExtensionRange + +// optional int32 start = 1; +bool DescriptorProto_ExtensionRange::has_start() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DescriptorProto_ExtensionRange::set_has_start() { + _has_bits_[0] |= 0x00000001u; +} +void DescriptorProto_ExtensionRange::clear_has_start() { + _has_bits_[0] &= ~0x00000001u; +} +void DescriptorProto_ExtensionRange::clear_start() { + start_ = 0; + clear_has_start(); +} +::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) + return start_; +} +void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { + set_has_start(); + start_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) +} + +// optional int32 end = 2; +bool DescriptorProto_ExtensionRange::has_end() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DescriptorProto_ExtensionRange::set_has_end() { + _has_bits_[0] |= 0x00000002u; +} +void DescriptorProto_ExtensionRange::clear_has_end() { + _has_bits_[0] &= ~0x00000002u; +} +void DescriptorProto_ExtensionRange::clear_end() { + end_ = 0; + clear_has_end(); +} +::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) + return end_; +} +void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto_ReservedRange::kStartFieldNumber; @@ -2823,19 +2798,21 @@ const int DescriptorProto_ReservedRange::kEndFieldNumber; DescriptorProto_ReservedRange::DescriptorProto_ReservedRange() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange) } - -void DescriptorProto_ReservedRange::InitAsDefaultInstance() { -} - DescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&start_, &from.start_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange) } @@ -2860,7 +2837,7 @@ void DescriptorProto_ReservedRange::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_ReservedRange_descriptor_; + return file_level_metadata[3].descriptor; } const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() { @@ -2868,8 +2845,6 @@ const DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_inst return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange_default_instance_; - DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const { DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange; if (arena != NULL) { @@ -2880,31 +2855,12 @@ DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::prot void DescriptorProto_ReservedRange::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(DescriptorProto_ReservedRange, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<DescriptorProto_ReservedRange*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(start_, end_); - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&start_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&start_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( @@ -2913,13 +2869,13 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional int32 start = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_start(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2927,14 +2883,12 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_end; break; } // optional int32 end = 2; case 2: { - if (tag == 16) { - parse_end: + if (tag == 16u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -2942,7 +2896,6 @@ bool DescriptorProto_ReservedRange::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -3014,6 +2967,11 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional int32 start = 1; if (has_start()) { @@ -3030,11 +2988,6 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -3044,7 +2997,7 @@ size_t DescriptorProto_ReservedRange::ByteSizeLong() const { void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto_ReservedRange* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>( &from); @@ -3053,22 +3006,15 @@ void DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_ReservedRange& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_start()) { set_start(from.start()); } @@ -3076,10 +3022,6 @@ void DescriptorProto_ReservedRange::UnsafeMergeFrom(const DescriptorProto_Reserv set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto_ReservedRange::CopyFrom(const ::google::protobuf::Message& from) { @@ -3093,11 +3035,10 @@ void DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto_ReservedRange::IsInitialized() const { - return true; } @@ -3115,14 +3056,63 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* ::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_ReservedRange_descriptor_; - metadata.reflection = DescriptorProto_ReservedRange_reflection_; - return metadata; + return file_level_metadata[3]; } +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// DescriptorProto_ReservedRange -// ------------------------------------------------------------------- +// optional int32 start = 1; +bool DescriptorProto_ReservedRange::has_start() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void DescriptorProto_ReservedRange::set_has_start() { + _has_bits_[0] |= 0x00000001u; +} +void DescriptorProto_ReservedRange::clear_has_start() { + _has_bits_[0] &= ~0x00000001u; +} +void DescriptorProto_ReservedRange::clear_start() { + start_ = 0; + clear_has_start(); +} +::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) + return start_; +} +void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { + set_has_start(); + start_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) +} + +// optional int32 end = 2; +bool DescriptorProto_ReservedRange::has_end() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void DescriptorProto_ReservedRange::set_has_end() { + _has_bits_[0] |= 0x00000002u; +} +void DescriptorProto_ReservedRange::clear_has_end() { + _has_bits_[0] &= ~0x00000002u; +} +void DescriptorProto_ReservedRange::clear_end() { + end_ = 0; + clear_has_end(); +} +::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { + // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) + return end_; +} +void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int DescriptorProto::kNameFieldNumber; @@ -3139,21 +3129,35 @@ const int DescriptorProto::kReservedNameFieldNumber; DescriptorProto::DescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto) } - -void DescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MessageOptions*>( - ::google::protobuf::MessageOptions::internal_default_instance()); -} - DescriptorProto::DescriptorProto(const DescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + field_(from.field_), + extension_(from.extension_), + nested_type_(from.nested_type_), + enum_type_(from.enum_type_), + extension_range_(from.extension_range_), + oneof_decl_(from.oneof_decl_), + reserved_range_(from.reserved_range_), + reserved_name_(from.reserved_name_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::MessageOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto) } @@ -3170,7 +3174,7 @@ DescriptorProto::~DescriptorProto() { void DescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &DescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -3182,7 +3186,7 @@ void DescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return DescriptorProto_descriptor_; + return file_level_metadata[4].descriptor; } const DescriptorProto& DescriptorProto::default_instance() { @@ -3190,8 +3194,6 @@ const DescriptorProto& DescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_; - DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { DescriptorProto* n = new DescriptorProto; if (arena != NULL) { @@ -3202,14 +3204,6 @@ DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const { void DescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto) - if (_has_bits_[0 / 32] & 129u) { - if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); - } - } field_.Clear(); extension_.Clear(); nested_type_.Clear(); @@ -3218,10 +3212,18 @@ void DescriptorProto::Clear() { oneof_decl_.Clear(); reserved_range_.Clear(); reserved_name_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + if (has_name()) { + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); + } + if (has_options()) { + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::MessageOptions::Clear(); + } } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool DescriptorProto::MergePartialFromCodedStream( @@ -3230,13 +3232,13 @@ bool DescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3246,141 +3248,114 @@ bool DescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_field; break; } // repeated .google.protobuf.FieldDescriptorProto field = 2; case 2: { - if (tag == 18) { - parse_field: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_field: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_field())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_field; - if (input->ExpectTag(26)) goto parse_loop_nested_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto nested_type = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_nested_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_nested_type())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_nested_type; - if (input->ExpectTag(34)) goto parse_loop_enum_type; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; case 4: { - if (tag == 34) { + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enum_type: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enum_type())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_enum_type; - if (input->ExpectTag(42)) goto parse_loop_extension_range; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension_range: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension_range())); } else { goto handle_unusual; } - if (input->ExpectTag(42)) goto parse_loop_extension_range; - if (input->ExpectTag(50)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.FieldDescriptorProto extension = 6; case 6: { - if (tag == 50) { + if (tag == 50u) { DO_(input->IncrementRecursionDepth()); - parse_loop_extension: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_extension())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_loop_extension; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(58)) goto parse_options; break; } // optional .google.protobuf.MessageOptions options = 7; case 7: { - if (tag == 58) { - parse_options: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_oneof_decl; break; } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; case 8: { - if (tag == 66) { - parse_oneof_decl: + if (tag == 66u) { DO_(input->IncrementRecursionDepth()); - parse_loop_oneof_decl: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_oneof_decl())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_loop_oneof_decl; - if (input->ExpectTag(74)) goto parse_loop_reserved_range; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; case 9: { - if (tag == 74) { + if (tag == 74u) { DO_(input->IncrementRecursionDepth()); - parse_loop_reserved_range: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_reserved_range())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_loop_reserved_range; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(82)) goto parse_reserved_name; break; } // repeated string reserved_name = 10; case 10: { - if (tag == 82) { - parse_reserved_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_reserved_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -3391,8 +3366,6 @@ bool DescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(82)) goto parse_reserved_name; - if (input->ExpectAtEnd()) goto success; break; } @@ -3589,21 +3562,10 @@ size_t DescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 129u) { - // optional string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.MessageOptions options = 7; - if (has_options()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->options_); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated .google.protobuf.FieldDescriptorProto field = 2; { @@ -3690,10 +3652,21 @@ size_t DescriptorProto::ByteSizeLong() const { this->reserved_name(i)); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string name = 1; + if (has_name()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // optional .google.protobuf.MessageOptions options = 7; + if (has_options()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->options_); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -3704,7 +3677,7 @@ size_t DescriptorProto::ByteSizeLong() const { void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>( &from); @@ -3713,21 +3686,14 @@ void DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DescriptorProto::MergeFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); field_.MergeFrom(from.field_); extension_.MergeFrom(from.extension_); nested_type_.MergeFrom(from.nested_type_); @@ -3735,8 +3701,8 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { extension_range_.MergeFrom(from.extension_range_); oneof_decl_.MergeFrom(from.oneof_decl_); reserved_range_.MergeFrom(from.reserved_range_); - reserved_name_.UnsafeMergeFrom(from.reserved_name_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + reserved_name_.MergeFrom(from.reserved_name_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -3745,10 +3711,6 @@ void DescriptorProto::UnsafeMergeFrom(const DescriptorProto& from) { mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -3762,11 +3724,10 @@ void DescriptorProto::CopyFrom(const DescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false; if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false; @@ -3783,16 +3744,16 @@ void DescriptorProto::Swap(DescriptorProto* other) { InternalSwap(other); } void DescriptorProto::InternalSwap(DescriptorProto* other) { - name_.Swap(&other->name_); field_.UnsafeArenaSwap(&other->field_); extension_.UnsafeArenaSwap(&other->extension_); nested_type_.UnsafeArenaSwap(&other->nested_type_); enum_type_.UnsafeArenaSwap(&other->enum_type_); extension_range_.UnsafeArenaSwap(&other->extension_range_); oneof_decl_.UnsafeArenaSwap(&other->oneof_decl_); - std::swap(options_, other->options_); reserved_range_.UnsafeArenaSwap(&other->reserved_range_); reserved_name_.UnsafeArenaSwap(&other->reserved_name_); + name_.Swap(&other->name_); + std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -3800,123 +3761,10 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { ::google::protobuf::Metadata DescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DescriptorProto_descriptor_; - metadata.reflection = DescriptorProto_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// DescriptorProto_ExtensionRange - -// optional int32 start = 1; -bool DescriptorProto_ExtensionRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ExtensionRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start) - return start_; -} -void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start) -} - -// optional int32 end = 2; -bool DescriptorProto_ExtensionRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ExtensionRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ExtensionRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end) - return end_; -} -void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) -} - -inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() { - return &DescriptorProto_ExtensionRange_default_instance_.get(); -} -// ------------------------------------------------------------------- - -// DescriptorProto_ReservedRange - -// optional int32 start = 1; -bool DescriptorProto_ReservedRange::has_start() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void DescriptorProto_ReservedRange::set_has_start() { - _has_bits_[0] |= 0x00000001u; -} -void DescriptorProto_ReservedRange::clear_has_start() { - _has_bits_[0] &= ~0x00000001u; -} -void DescriptorProto_ReservedRange::clear_start() { - start_ = 0; - clear_has_start(); -} -::google::protobuf::int32 DescriptorProto_ReservedRange::start() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start) - return start_; -} -void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) { - set_has_start(); - start_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start) -} - -// optional int32 end = 2; -bool DescriptorProto_ReservedRange::has_end() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void DescriptorProto_ReservedRange::set_has_end() { - _has_bits_[0] |= 0x00000002u; -} -void DescriptorProto_ReservedRange::clear_has_end() { - _has_bits_[0] &= ~0x00000002u; -} -void DescriptorProto_ReservedRange::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 DescriptorProto_ReservedRange::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end) - return end_; -} -void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) -} - -inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() { - return &DescriptorProto_ReservedRange_default_instance_.get(); -} -// ------------------------------------------------------------------- - // DescriptorProto // optional string name = 1; @@ -3935,7 +3783,7 @@ void DescriptorProto::clear_name() { } const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4155,13 +4003,13 @@ DescriptorProto::oneof_decl() const { // optional .google.protobuf.MessageOptions options = 7; bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000002u; } void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000002u; } void DescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); @@ -4283,89 +4131,10 @@ DescriptorProto::mutable_reserved_name() { return &reserved_name_; } -inline const DescriptorProto* DescriptorProto::internal_default_instance() { - return &DescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Type_descriptor_; -} -bool FieldDescriptorProto_Type_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32; -const FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN; -const FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX; -const int FieldDescriptorProto::Type_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_Label_descriptor_; -} -bool FieldDescriptorProto_Label_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED; -const FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN; -const FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX; -const int FieldDescriptorProto::Label_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldDescriptorProto::kNameFieldNumber; const int FieldDescriptorProto::kNumberFieldNumber; @@ -4381,21 +4150,46 @@ const int FieldDescriptorProto::kOptionsFieldNumber; FieldDescriptorProto::FieldDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto) } - -void FieldDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::FieldOptions*>( - ::google::protobuf::FieldOptions::internal_default_instance()); -} - FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_type_name()) { + type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); + } + extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_extendee()) { + extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_); + } + default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_default_value()) { + default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); + } + json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_json_name()) { + json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::FieldOptions(*from.options_); + } else { + options_ = NULL; + } + ::memcpy(&number_, &from.number_, + reinterpret_cast<char*>(&type_) - + reinterpret_cast<char*>(&number_) + sizeof(type_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto) } @@ -4406,9 +4200,8 @@ void FieldDescriptorProto::SharedCtor() { extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - - reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); + ::memset(&options_, 0, reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&options_) + sizeof(oneof_index_)); label_ = 1; type_ = 1; } @@ -4424,7 +4217,7 @@ void FieldDescriptorProto::SharedDtor() { extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &FieldDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -4436,7 +4229,7 @@ void FieldDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldDescriptorProto_descriptor_; + return file_level_metadata[5].descriptor; } const FieldDescriptorProto& FieldDescriptorProto::default_instance() { @@ -4444,8 +4237,6 @@ const FieldDescriptorProto& FieldDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_; - FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const { FieldDescriptorProto* n = new FieldDescriptorProto; if (arena != NULL) { @@ -4456,55 +4247,42 @@ FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena void FieldDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(FieldDescriptorProto, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<FieldDescriptorProto*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - if (_has_bits_[0 / 32] & 255u) { - ZR_(number_, oneof_index_); + if (_has_bits_[0 / 32] & 63u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } - label_ = 1; - type_ = 1; if (has_type_name()) { - type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!type_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*type_name_.UnsafeRawStringPointer())->clear(); } if (has_extendee()) { - extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!extendee_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*extendee_.UnsafeRawStringPointer())->clear(); } if (has_default_value()) { - default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!default_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*default_value_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 768u) { if (has_json_name()) { - json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!json_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*json_name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::FieldOptions::Clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 192u) { + ::memset(&number_, 0, reinterpret_cast<char*>(&oneof_index_) - + reinterpret_cast<char*>(&number_) + sizeof(oneof_index_)); } + if (_has_bits_[8 / 32] & 768u) { + label_ = 1; + type_ = 1; + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FieldDescriptorProto::MergePartialFromCodedStream( @@ -4513,13 +4291,13 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4529,14 +4307,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_extendee; break; } // optional string extendee = 2; case 2: { - if (tag == 18) { - parse_extendee: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_extendee())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4546,14 +4322,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_number; break; } // optional int32 number = 3; case 3: { - if (tag == 24) { - parse_number: + if (tag == 24u) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4561,14 +4335,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_label; break; } // optional .google.protobuf.FieldDescriptorProto.Label label = 4; case 4: { - if (tag == 32) { - parse_label: + if (tag == 32u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4581,14 +4353,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_type; break; } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; case 5: { - if (tag == 40) { - parse_type: + if (tag == 40u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -4601,14 +4371,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_type_name; break; } // optional string type_name = 6; case 6: { - if (tag == 50) { - parse_type_name: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4618,14 +4386,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_default_value; break; } // optional string default_value = 7; case 7: { - if (tag == 58) { - parse_default_value: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4635,27 +4401,23 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_options; break; } // optional .google.protobuf.FieldOptions options = 8; case 8: { - if (tag == 66) { - parse_options: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(72)) goto parse_oneof_index; break; } // optional int32 oneof_index = 9; case 9: { - if (tag == 72) { - parse_oneof_index: + if (tag == 72u) { set_has_oneof_index(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -4663,14 +4425,12 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(82)) goto parse_json_name; break; } // optional string json_name = 10; case 10: { - if (tag == 82) { - parse_json_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -4680,7 +4440,6 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -4894,6 +4653,11 @@ size_t FieldDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 255u) { // optional string name = 1; if (has_name()) { @@ -4902,25 +4666,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const { this->name()); } - // optional int32 number = 3; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - - // optional .google.protobuf.FieldDescriptorProto.Label label = 4; - if (has_label()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->label()); - } - - // optional .google.protobuf.FieldDescriptorProto.Type type = 5; - if (has_type()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); - } - // optional string type_name = 6; if (has_type_name()) { total_size += 1 + @@ -4942,15 +4687,6 @@ size_t FieldDescriptorProto::ByteSizeLong() const { this->default_value()); } - // optional int32 oneof_index = 9; - if (has_oneof_index()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->oneof_index()); - } - - } - if (_has_bits_[8 / 32] & 768u) { // optional string json_name = 10; if (has_json_name()) { total_size += 1 + @@ -4965,11 +4701,34 @@ size_t FieldDescriptorProto::ByteSizeLong() const { *this->options_); } + // optional int32 number = 3; + if (has_number()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); + } + + // optional int32 oneof_index = 9; + if (has_oneof_index()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->oneof_index()); + } + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[8 / 32] & 768u) { + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + if (has_label()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->label()); + } + + // optional .google.protobuf.FieldDescriptorProto.Type type = 5; + if (has_type()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -4980,7 +4739,7 @@ size_t FieldDescriptorProto::ByteSizeLong() const { void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>( &from); @@ -4989,35 +4748,19 @@ void FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 255u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } - if (from.has_number()) { - set_number(from.number()); - } - if (from.has_label()) { - set_label(from.label()); - } - if (from.has_type()) { - set_type(from.type()); - } if (from.has_type_name()) { set_has_type_name(); type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_); @@ -5030,11 +4773,6 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { set_has_default_value(); default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_); } - if (from.has_oneof_index()) { - set_oneof_index(from.oneof_index()); - } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_json_name()) { set_has_json_name(); json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_); @@ -5042,10 +4780,20 @@ void FieldDescriptorProto::UnsafeMergeFrom(const FieldDescriptorProto& from) { if (from.has_options()) { mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options()); } + if (from.has_number()) { + set_number(from.number()); + } + if (from.has_oneof_index()) { + set_oneof_index(from.oneof_index()); + } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from._has_bits_[8 / 32] & 768u) { + if (from.has_label()) { + set_label(from.label()); + } + if (from.has_type()) { + set_type(from.type()); + } } } @@ -5060,11 +4808,10 @@ void FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -5077,15 +4824,15 @@ void FieldDescriptorProto::Swap(FieldDescriptorProto* other) { } void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { name_.Swap(&other->name_); - std::swap(number_, other->number_); - std::swap(label_, other->label_); - std::swap(type_, other->type_); type_name_.Swap(&other->type_name_); extendee_.Swap(&other->extendee_); default_value_.Swap(&other->default_value_); - std::swap(oneof_index_, other->oneof_index_); json_name_.Swap(&other->json_name_); std::swap(options_, other->options_); + std::swap(number_, other->number_); + std::swap(oneof_index_, other->oneof_index_); + std::swap(label_, other->label_); + std::swap(type_, other->type_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -5093,10 +4840,7 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { ::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldDescriptorProto_descriptor_; - metadata.reflection = FieldDescriptorProto_reflection_; - return metadata; + return file_level_metadata[5]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5118,7 +4862,7 @@ void FieldDescriptorProto::clear_name() { } const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5158,13 +4902,13 @@ void FieldDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 3; bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000040u; } void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000040u; } void FieldDescriptorProto::clear_number() { number_ = 0; @@ -5182,13 +4926,13 @@ void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000100u; } void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000100u; } void FieldDescriptorProto::clear_label() { label_ = 1; @@ -5207,13 +4951,13 @@ void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_La // optional .google.protobuf.FieldDescriptorProto.Type type = 5; bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000200u; } void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000200u; } void FieldDescriptorProto::clear_type() { type_ = 1; @@ -5232,13 +4976,13 @@ void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Typ // optional string type_name = 6; bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000002u; } void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000002u; } void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5246,7 +4990,7 @@ void FieldDescriptorProto::clear_type_name() { } const ::std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) - return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_name_.GetNoArena(); } void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); @@ -5286,13 +5030,13 @@ void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) { // optional string extendee = 2; bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000004u; } void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000004u; } void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5300,7 +5044,7 @@ void FieldDescriptorProto::clear_extendee() { } const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.GetNoArena(); } void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); @@ -5340,13 +5084,13 @@ void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) { // optional string default_value = 7; bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000008u; } void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000008u; } void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5354,7 +5098,7 @@ void FieldDescriptorProto::clear_default_value() { } const ::std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) - return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.GetNoArena(); } void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); @@ -5418,13 +5162,13 @@ void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) { // optional string json_name = 10; bool FieldDescriptorProto::has_json_name() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FieldDescriptorProto::set_has_json_name() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000010u; } void FieldDescriptorProto::clear_has_json_name() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000010u; } void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5432,7 +5176,7 @@ void FieldDescriptorProto::clear_json_name() { } const ::std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) - return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.GetNoArena(); } void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); @@ -5472,13 +5216,13 @@ void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) { // optional .google.protobuf.FieldOptions options = 8; bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000020u; } void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000020u; } void FieldDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); @@ -5515,9 +5259,6 @@ void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOption // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } -inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() { - return &FieldDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -5529,21 +5270,27 @@ const int OneofDescriptorProto::kOptionsFieldNumber; OneofDescriptorProto::OneofDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto) } - -void OneofDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::OneofOptions*>( - ::google::protobuf::OneofOptions::internal_default_instance()); -} - OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::OneofOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto) } @@ -5560,7 +5307,7 @@ OneofDescriptorProto::~OneofDescriptorProto() { void OneofDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &OneofDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -5572,7 +5319,7 @@ void OneofDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return OneofDescriptorProto_descriptor_; + return file_level_metadata[6].descriptor; } const OneofDescriptorProto& OneofDescriptorProto::default_instance() { @@ -5580,8 +5327,6 @@ const OneofDescriptorProto& OneofDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_; - OneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const { OneofDescriptorProto* n = new OneofDescriptorProto; if (arena != NULL) { @@ -5594,16 +5339,16 @@ void OneofDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto) if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::OneofOptions::Clear(); } } _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool OneofDescriptorProto::MergePartialFromCodedStream( @@ -5612,13 +5357,13 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -5628,20 +5373,17 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_options; break; } // optional .google.protobuf.OneofOptions options = 2; case 2: { - if (tag == 18) { - parse_options: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -5727,6 +5469,11 @@ size_t OneofDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { @@ -5743,11 +5490,6 @@ size_t OneofDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -5757,7 +5499,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const { void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const OneofDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>( &from); @@ -5766,22 +5508,15 @@ void OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -5790,10 +5525,6 @@ void OneofDescriptorProto::UnsafeMergeFrom(const OneofDescriptorProto& from) { mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void OneofDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -5807,11 +5538,10 @@ void OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool OneofDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -5832,10 +5562,7 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { ::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = OneofDescriptorProto_descriptor_; - metadata.reflection = OneofDescriptorProto_reflection_; - return metadata; + return file_level_metadata[6]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -5857,7 +5584,7 @@ void OneofDescriptorProto::clear_name() { } const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5940,9 +5667,6 @@ void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOption // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } -inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() { - return &OneofDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -5955,21 +5679,28 @@ const int EnumDescriptorProto::kOptionsFieldNumber; EnumDescriptorProto::EnumDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto) } - -void EnumDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumOptions*>( - ::google::protobuf::EnumOptions::internal_default_instance()); -} - EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + value_(from.value_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::EnumOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto) } @@ -5986,7 +5717,7 @@ EnumDescriptorProto::~EnumDescriptorProto() { void EnumDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &EnumDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -5998,7 +5729,7 @@ void EnumDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumDescriptorProto_descriptor_; + return file_level_metadata[7].descriptor; } const EnumDescriptorProto& EnumDescriptorProto::default_instance() { @@ -6006,8 +5737,6 @@ const EnumDescriptorProto& EnumDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_; - EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumDescriptorProto* n = new EnumDescriptorProto; if (arena != NULL) { @@ -6018,19 +5747,19 @@ EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) void EnumDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto) - if (_has_bits_[0 / 32] & 5u) { + value_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::EnumOptions::Clear(); } } - value_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumDescriptorProto::MergePartialFromCodedStream( @@ -6039,13 +5768,13 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6055,37 +5784,30 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_value: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_value())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_value; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.EnumOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6184,7 +5906,23 @@ size_t EnumDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 5u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.EnumValueDescriptorProto value = 2; + { + unsigned int count = this->value_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->value(i)); + } + } + + if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -6200,22 +5938,6 @@ size_t EnumDescriptorProto::ByteSizeLong() const { } } - // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - { - unsigned int count = this->value_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->value(i)); - } - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -6225,7 +5947,7 @@ size_t EnumDescriptorProto::ByteSizeLong() const { void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>( &from); @@ -6234,23 +5956,16 @@ void EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); value_.MergeFrom(from.value_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -6259,10 +5974,6 @@ void EnumDescriptorProto::UnsafeMergeFrom(const EnumDescriptorProto& from) { mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -6276,11 +5987,10 @@ void EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->value())) return false; if (has_options()) { if (!this->options_->IsInitialized()) return false; @@ -6293,8 +6003,8 @@ void EnumDescriptorProto::Swap(EnumDescriptorProto* other) { InternalSwap(other); } void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { - name_.Swap(&other->name_); value_.UnsafeArenaSwap(&other->value_); + name_.Swap(&other->name_); std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -6303,10 +6013,7 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { ::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumDescriptorProto_descriptor_; - metadata.reflection = EnumDescriptorProto_reflection_; - return metadata; + return file_level_metadata[7]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6328,7 +6035,7 @@ void EnumDescriptorProto::clear_name() { } const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -6398,13 +6105,13 @@ EnumDescriptorProto::value() const { // optional .google.protobuf.EnumOptions options = 3; bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void EnumDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); @@ -6441,9 +6148,6 @@ void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } -inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() { - return &EnumDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -6456,29 +6160,36 @@ const int EnumValueDescriptorProto::kOptionsFieldNumber; EnumValueDescriptorProto::EnumValueDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto) } - -void EnumValueDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::EnumValueOptions*>( - ::google::protobuf::EnumValueOptions::internal_default_instance()); -} - EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::EnumValueOptions(*from.options_); + } else { + options_ = NULL; + } + number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto) } void EnumValueDescriptorProto::SharedCtor() { _cached_size_ = 0; name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - number_ = 0; + ::memset(&options_, 0, reinterpret_cast<char*>(&number_) - + reinterpret_cast<char*>(&options_) + sizeof(number_)); } EnumValueDescriptorProto::~EnumValueDescriptorProto() { @@ -6488,7 +6199,7 @@ EnumValueDescriptorProto::~EnumValueDescriptorProto() { void EnumValueDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &EnumValueDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -6500,7 +6211,7 @@ void EnumValueDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValueDescriptorProto_descriptor_; + return file_level_metadata[8].descriptor; } const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { @@ -6508,8 +6219,6 @@ const EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_; - EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const { EnumValueDescriptorProto* n = new EnumValueDescriptorProto; if (arena != NULL) { @@ -6520,19 +6229,19 @@ EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Aren void EnumValueDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto) - if (_has_bits_[0 / 32] & 7u) { + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } - number_ = 0; if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::EnumValueOptions::Clear(); } } + number_ = 0; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumValueDescriptorProto::MergePartialFromCodedStream( @@ -6541,13 +6250,13 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -6557,14 +6266,12 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_number; break; } // optional int32 number = 2; case 2: { - if (tag == 16) { - parse_number: + if (tag == 16u) { set_has_number(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -6572,20 +6279,17 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.EnumValueOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -6681,6 +6385,11 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; if (has_name()) { @@ -6689,13 +6398,6 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { this->name()); } - // optional int32 number = 2; - if (has_number()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); - } - // optional .google.protobuf.EnumValueOptions options = 3; if (has_options()) { total_size += 1 + @@ -6703,11 +6405,13 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { *this->options_); } - } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional int32 number = 2; + if (has_number()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -6718,7 +6422,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValueDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>( &from); @@ -6727,36 +6431,25 @@ void EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumValueDescriptorProto::UnsafeMergeFrom(const EnumValueDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); } - if (from.has_number()) { - set_number(from.number()); - } if (from.has_options()) { mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options()); } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_number()) { + set_number(from.number()); + } } } @@ -6771,11 +6464,10 @@ void EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValueDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -6788,8 +6480,8 @@ void EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) { } void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { name_.Swap(&other->name_); - std::swap(number_, other->number_); std::swap(options_, other->options_); + std::swap(number_, other->number_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -6797,10 +6489,7 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { ::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueDescriptorProto_descriptor_; - metadata.reflection = EnumValueDescriptorProto_reflection_; - return metadata; + return file_level_metadata[8]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -6822,7 +6511,7 @@ void EnumValueDescriptorProto::clear_name() { } const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -6862,13 +6551,13 @@ void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 2; bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } void EnumValueDescriptorProto::clear_number() { number_ = 0; @@ -6886,13 +6575,13 @@ void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.EnumValueOptions options = 3; bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void EnumValueDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); @@ -6929,9 +6618,6 @@ void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumVal // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } -inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() { - return &EnumValueDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -6944,21 +6630,28 @@ const int ServiceDescriptorProto::kOptionsFieldNumber; ServiceDescriptorProto::ServiceDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto) } - -void ServiceDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::ServiceOptions*>( - ::google::protobuf::ServiceOptions::internal_default_instance()); -} - ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + method_(from.method_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::ServiceOptions(*from.options_); + } else { + options_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto) } @@ -6975,7 +6668,7 @@ ServiceDescriptorProto::~ServiceDescriptorProto() { void ServiceDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &ServiceDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -6987,7 +6680,7 @@ void ServiceDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return ServiceDescriptorProto_descriptor_; + return file_level_metadata[9].descriptor; } const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { @@ -6995,8 +6688,6 @@ const ServiceDescriptorProto& ServiceDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_; - ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const { ServiceDescriptorProto* n = new ServiceDescriptorProto; if (arena != NULL) { @@ -7007,19 +6698,19 @@ ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* a void ServiceDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto) - if (_has_bits_[0 / 32] & 5u) { + method_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::ServiceOptions::Clear(); } } - method_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool ServiceDescriptorProto::MergePartialFromCodedStream( @@ -7028,13 +6719,13 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7044,37 +6735,30 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_method; break; } // repeated .google.protobuf.MethodDescriptorProto method = 2; case 2: { - if (tag == 18) { - parse_method: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_method: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_method())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_method; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_options; break; } // optional .google.protobuf.ServiceOptions options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7173,7 +6857,23 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto) size_t total_size = 0; - if (_has_bits_[0 / 32] & 5u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.MethodDescriptorProto method = 2; + { + unsigned int count = this->method_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->method(i)); + } + } + + if (_has_bits_[0 / 32] & 3u) { // optional string name = 1; if (has_name()) { total_size += 1 + @@ -7189,22 +6889,6 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { } } - // repeated .google.protobuf.MethodDescriptorProto method = 2; - { - unsigned int count = this->method_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->method(i)); - } - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -7214,7 +6898,7 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ServiceDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>( &from); @@ -7223,23 +6907,16 @@ void ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); method_.MergeFrom(from.method_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -7248,10 +6925,6 @@ void ServiceDescriptorProto::UnsafeMergeFrom(const ServiceDescriptorProto& from) mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -7265,11 +6938,10 @@ void ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ServiceDescriptorProto::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->method())) return false; if (has_options()) { if (!this->options_->IsInitialized()) return false; @@ -7282,8 +6954,8 @@ void ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) { InternalSwap(other); } void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { - name_.Swap(&other->name_); method_.UnsafeArenaSwap(&other->method_); + name_.Swap(&other->name_); std::swap(options_, other->options_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); @@ -7292,10 +6964,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { ::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceDescriptorProto_descriptor_; - metadata.reflection = ServiceDescriptorProto_reflection_; - return metadata; + return file_level_metadata[9]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7317,7 +6986,7 @@ void ServiceDescriptorProto::clear_name() { } const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -7387,13 +7056,13 @@ ServiceDescriptorProto::method() const { // optional .google.protobuf.ServiceOptions options = 3; bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void ServiceDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); @@ -7430,9 +7099,6 @@ void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOp // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } -inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() { - return &ServiceDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -7448,21 +7114,38 @@ const int MethodDescriptorProto::kServerStreamingFieldNumber; MethodDescriptorProto::MethodDescriptorProto() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto) } - -void MethodDescriptorProto::InitAsDefaultInstance() { - options_ = const_cast< ::google::protobuf::MethodOptions*>( - ::google::protobuf::MethodOptions::internal_default_instance()); -} - MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name()) { + name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); + } + input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_input_type()) { + input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_); + } + output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_output_type()) { + output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_); + } + if (from.has_options()) { + options_ = new ::google::protobuf::MethodOptions(*from.options_); + } else { + options_ = NULL; + } + ::memcpy(&client_streaming_, &from.client_streaming_, + reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto) } @@ -7471,9 +7154,8 @@ void MethodDescriptorProto::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - options_ = NULL; - ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - - reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); + ::memset(&options_, 0, reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&options_) + sizeof(server_streaming_)); } MethodDescriptorProto::~MethodDescriptorProto() { @@ -7485,7 +7167,7 @@ void MethodDescriptorProto::SharedDtor() { name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - if (this != &MethodDescriptorProto_default_instance_.get()) { + if (this != internal_default_instance()) { delete options_; } } @@ -7497,7 +7179,7 @@ void MethodDescriptorProto::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() { protobuf_AssignDescriptorsOnce(); - return MethodDescriptorProto_descriptor_; + return file_level_metadata[10].descriptor; } const MethodDescriptorProto& MethodDescriptorProto::default_instance() { @@ -7505,8 +7187,6 @@ const MethodDescriptorProto& MethodDescriptorProto::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_; - MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const { MethodDescriptorProto* n = new MethodDescriptorProto; if (arena != NULL) { @@ -7517,45 +7197,30 @@ MethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* are void MethodDescriptorProto::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(MethodDescriptorProto, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<MethodDescriptorProto*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - if (_has_bits_[0 / 32] & 63u) { - ZR_(client_streaming_, server_streaming_); + if (_has_bits_[0 / 32] & 15u) { if (has_name()) { - name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_.UnsafeRawStringPointer())->clear(); } if (has_input_type()) { - input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!input_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*input_type_.UnsafeRawStringPointer())->clear(); } if (has_output_type()) { - output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!output_type_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*output_type_.UnsafeRawStringPointer())->clear(); } if (has_options()) { - if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear(); + GOOGLE_DCHECK(options_ != NULL); + options_->::google::protobuf::MethodOptions::Clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 48u) { + ::memset(&client_streaming_, 0, reinterpret_cast<char*>(&server_streaming_) - + reinterpret_cast<char*>(&client_streaming_) + sizeof(server_streaming_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MethodDescriptorProto::MergePartialFromCodedStream( @@ -7564,13 +7229,13 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7580,14 +7245,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_input_type; break; } // optional string input_type = 2; case 2: { - if (tag == 18) { - parse_input_type: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_input_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7597,14 +7260,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_output_type; break; } // optional string output_type = 3; case 3: { - if (tag == 26) { - parse_output_type: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_output_type())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -7614,27 +7275,23 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_options; break; } // optional .google.protobuf.MethodOptions options = 4; case 4: { - if (tag == 34) { - parse_options: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_options())); } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_client_streaming; break; } // optional bool client_streaming = 5 [default = false]; case 5: { - if (tag == 40) { - parse_client_streaming: + if (tag == 40u) { set_has_client_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7642,14 +7299,12 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_server_streaming; break; } // optional bool server_streaming = 6 [default = false]; case 6: { - if (tag == 48) { - parse_server_streaming: + if (tag == 48u) { set_has_server_streaming(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -7657,7 +7312,6 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -7805,6 +7459,11 @@ size_t MethodDescriptorProto::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (_has_bits_[0 / 32] & 63u) { // optional string name = 1; if (has_name()) { @@ -7845,11 +7504,6 @@ size_t MethodDescriptorProto::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -7859,7 +7513,7 @@ size_t MethodDescriptorProto::ByteSizeLong() const { void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MethodDescriptorProto* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>( &from); @@ -7868,22 +7522,15 @@ void MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 63u) { if (from.has_name()) { set_has_name(); name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_); @@ -7906,10 +7553,6 @@ void MethodDescriptorProto::UnsafeMergeFrom(const MethodDescriptorProto& from) { set_server_streaming(from.server_streaming()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) { @@ -7923,11 +7566,10 @@ void MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MethodDescriptorProto::IsInitialized() const { - if (has_options()) { if (!this->options_->IsInitialized()) return false; } @@ -7952,10 +7594,7 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { ::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodDescriptorProto_descriptor_; - metadata.reflection = MethodDescriptorProto_reflection_; - return metadata; + return file_level_metadata[10]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -7977,7 +7616,7 @@ void MethodDescriptorProto::clear_name() { } const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -8031,7 +7670,7 @@ void MethodDescriptorProto::clear_input_type() { } const ::std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) - return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return input_type_.GetNoArena(); } void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); @@ -8085,7 +7724,7 @@ void MethodDescriptorProto::clear_output_type() { } const ::std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) - return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return output_type_.GetNoArena(); } void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); @@ -8216,36 +7855,10 @@ void MethodDescriptorProto::set_server_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) } -inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() { - return &MethodDescriptorProto_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FileOptions_OptimizeMode_descriptor_; -} -bool FileOptions_OptimizeMode_IsValid(int value) { - switch (value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FileOptions_OptimizeMode FileOptions::SPEED; -const FileOptions_OptimizeMode FileOptions::CODE_SIZE; -const FileOptions_OptimizeMode FileOptions::LITE_RUNTIME; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN; -const FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX; -const int FileOptions::OptimizeMode_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FileOptions::kJavaPackageFieldNumber; const int FileOptions::kJavaOuterClassnameFieldNumber; @@ -8261,24 +7874,53 @@ const int FileOptions::kDeprecatedFieldNumber; const int FileOptions::kCcEnableArenasFieldNumber; const int FileOptions::kObjcClassPrefixFieldNumber; const int FileOptions::kCsharpNamespaceFieldNumber; +const int FileOptions::kSwiftPrefixFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 FileOptions::FileOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FileOptions) } - -void FileOptions::InitAsDefaultInstance() { -} - FileOptions::FileOptions(const FileOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_java_package()) { + java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); + } + java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_java_outer_classname()) { + java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); + } + go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_go_package()) { + go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + } + objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_objc_class_prefix()) { + objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + } + csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_csharp_namespace()) { + csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + } + swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_swift_prefix()) { + swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + } + ::memcpy(&java_multiple_files_, &from.java_multiple_files_, + reinterpret_cast<char*>(&optimize_for_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(optimize_for_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions) } @@ -8289,6 +7931,7 @@ void FileOptions::SharedCtor() { go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + swift_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - reinterpret_cast<char*>(&java_multiple_files_) + sizeof(cc_enable_arenas_)); optimize_for_ = 1; @@ -8305,6 +7948,7 @@ void FileOptions::SharedDtor() { go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + swift_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } void FileOptions::SetCachedSize(int size) const { @@ -8314,7 +7958,7 @@ void FileOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FileOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return FileOptions_descriptor_; + return file_level_metadata[11].descriptor; } const FileOptions& FileOptions::default_instance() { @@ -8322,8 +7966,6 @@ const FileOptions& FileOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_; - FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { FileOptions* n = new FileOptions; if (arena != NULL) { @@ -8335,53 +7977,44 @@ FileOptions* FileOptions::New(::google::protobuf::Arena* arena) const { void FileOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(FileOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<FileOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - if (_has_bits_[0 / 32] & 255u) { - ZR_(java_multiple_files_, cc_generic_services_); + uninterpreted_option_.Clear(); + if (_has_bits_[0 / 32] & 63u) { if (has_java_package()) { - java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!java_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*java_package_.UnsafeRawStringPointer())->clear(); } if (has_java_outer_classname()) { - java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!java_outer_classname_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*java_outer_classname_.UnsafeRawStringPointer())->clear(); } - optimize_for_ = 1; if (has_go_package()) { - go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!go_package_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*go_package_.UnsafeRawStringPointer())->clear(); } - } - if (_has_bits_[8 / 32] & 16128u) { - ZR_(java_generic_services_, cc_enable_arenas_); if (has_objc_class_prefix()) { - objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!objc_class_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*objc_class_prefix_.UnsafeRawStringPointer())->clear(); } if (has_csharp_namespace()) { - csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!csharp_namespace_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*csharp_namespace_.UnsafeRawStringPointer())->clear(); + } + if (has_swift_prefix()) { + GOOGLE_DCHECK(!swift_prefix_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*swift_prefix_.UnsafeRawStringPointer())->clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 192u) { + ::memset(&java_multiple_files_, 0, reinterpret_cast<char*>(&java_generate_equals_and_hash_) - + reinterpret_cast<char*>(&java_multiple_files_) + sizeof(java_generate_equals_and_hash_)); } + if (_has_bits_[8 / 32] & 32512u) { + ::memset(&java_string_check_utf8_, 0, reinterpret_cast<char*>(&cc_enable_arenas_) - + reinterpret_cast<char*>(&java_string_check_utf8_) + sizeof(cc_enable_arenas_)); + optimize_for_ = 1; + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FileOptions::MergePartialFromCodedStream( @@ -8390,13 +8023,13 @@ bool FileOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FileOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional string java_package = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8406,14 +8039,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_java_outer_classname; break; } // optional string java_outer_classname = 8; case 8: { - if (tag == 66) { - parse_java_outer_classname: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_java_outer_classname())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8423,14 +8054,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(72)) goto parse_optimize_for; break; } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; case 9: { - if (tag == 72) { - parse_optimize_for: + if (tag == 72u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -8443,14 +8072,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_java_multiple_files; break; } // optional bool java_multiple_files = 10 [default = false]; case 10: { - if (tag == 80) { - parse_java_multiple_files: + if (tag == 80u) { set_has_java_multiple_files(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8458,14 +8085,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(90)) goto parse_go_package; break; } // optional string go_package = 11; case 11: { - if (tag == 90) { - parse_go_package: + if (tag == 90u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_go_package())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8475,14 +8100,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(128)) goto parse_cc_generic_services; break; } // optional bool cc_generic_services = 16 [default = false]; case 16: { - if (tag == 128) { - parse_cc_generic_services: + if (tag == 128u) { set_has_cc_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8490,14 +8113,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(136)) goto parse_java_generic_services; break; } // optional bool java_generic_services = 17 [default = false]; case 17: { - if (tag == 136) { - parse_java_generic_services: + if (tag == 136u) { set_has_java_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8505,14 +8126,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(144)) goto parse_py_generic_services; break; } // optional bool py_generic_services = 18 [default = false]; case 18: { - if (tag == 144) { - parse_py_generic_services: + if (tag == 144u) { set_has_py_generic_services(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8520,14 +8139,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash; break; } // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; case 20: { - if (tag == 160) { - parse_java_generate_equals_and_hash: + if (tag == 160u) { set_has_java_generate_equals_and_hash(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8535,14 +8152,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(184)) goto parse_deprecated; break; } // optional bool deprecated = 23 [default = false]; case 23: { - if (tag == 184) { - parse_deprecated: + if (tag == 184u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8550,14 +8165,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(216)) goto parse_java_string_check_utf8; break; } // optional bool java_string_check_utf8 = 27 [default = false]; case 27: { - if (tag == 216) { - parse_java_string_check_utf8: + if (tag == 216u) { set_has_java_string_check_utf8(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8565,14 +8178,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(248)) goto parse_cc_enable_arenas; break; } // optional bool cc_enable_arenas = 31 [default = false]; case 31: { - if (tag == 248) { - parse_cc_enable_arenas: + if (tag == 248u) { set_has_cc_enable_arenas(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -8580,14 +8191,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(290)) goto parse_objc_class_prefix; break; } // optional string objc_class_prefix = 36; case 36: { - if (tag == 290) { - parse_objc_class_prefix: + if (tag == 290u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_objc_class_prefix())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8597,14 +8206,12 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(298)) goto parse_csharp_namespace; break; } // optional string csharp_namespace = 37; case 37: { - if (tag == 298) { - parse_csharp_namespace: + if (tag == 298u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_csharp_namespace())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -8614,24 +8221,34 @@ bool FileOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; + break; + } + + // optional string swift_prefix = 39; + case 39: { + if (tag == 314u) { + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_swift_prefix())); + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::PARSE, + "google.protobuf.FileOptions.swift_prefix"); + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -8761,6 +8378,16 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), output); } + // optional string swift_prefix = 39; + if (has_swift_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.swift_prefix"); + ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( + 39, this->swift_prefix(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -8883,6 +8510,17 @@ void FileOptions::SerializeWithCachedSizes( 37, this->csharp_namespace(), target); } + // optional string swift_prefix = 39; + if (has_swift_prefix()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( + this->swift_prefix().data(), this->swift_prefix().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE, + "google.protobuf.FileOptions.swift_prefix"); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 39, this->swift_prefix(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -8906,6 +8544,24 @@ size_t FileOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } + } + if (_has_bits_[0 / 32] & 255u) { // optional string java_package = 1; if (has_java_package()) { @@ -8921,6 +8577,34 @@ size_t FileOptions::ByteSizeLong() const { this->java_outer_classname()); } + // optional string go_package = 11; + if (has_go_package()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->go_package()); + } + + // optional string objc_class_prefix = 36; + if (has_objc_class_prefix()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->objc_class_prefix()); + } + + // optional string csharp_namespace = 37; + if (has_csharp_namespace()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->csharp_namespace()); + } + + // optional string swift_prefix = 39; + if (has_swift_prefix()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->swift_prefix()); + } + // optional bool java_multiple_files = 10 [default = false]; if (has_java_multiple_files()) { total_size += 1 + 1; @@ -8931,31 +8615,18 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } + } + if (_has_bits_[8 / 32] & 32512u) { // optional bool java_string_check_utf8 = 27 [default = false]; if (has_java_string_check_utf8()) { total_size += 2 + 1; } - // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; - if (has_optimize_for()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); - } - - // optional string go_package = 11; - if (has_go_package()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->go_package()); - } - // optional bool cc_generic_services = 16 [default = false]; if (has_cc_generic_services()) { total_size += 2 + 1; } - } - if (_has_bits_[8 / 32] & 16128u) { // optional bool java_generic_services = 17 [default = false]; if (has_java_generic_services()) { total_size += 2 + 1; @@ -8976,38 +8647,12 @@ size_t FileOptions::ByteSizeLong() const { total_size += 2 + 1; } - // optional string objc_class_prefix = 36; - if (has_objc_class_prefix()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->objc_class_prefix()); - } - - // optional string csharp_namespace = 37; - if (has_csharp_namespace()) { - total_size += 2 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->csharp_namespace()); - } - - } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = this->uninterpreted_option_size(); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; + if (has_optimize_for()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for()); } - } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -9018,7 +8663,7 @@ size_t FileOptions::ByteSizeLong() const { void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FileOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>( &from); @@ -9027,23 +8672,17 @@ void FileOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FileOptions::MergeFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FileOptions::UnsafeMergeFrom(const FileOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 255u) { if (from.has_java_package()) { set_has_java_package(); java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_); @@ -9052,27 +8691,36 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) { set_has_java_outer_classname(); java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_); } + if (from.has_go_package()) { + set_has_go_package(); + go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); + } + if (from.has_objc_class_prefix()) { + set_has_objc_class_prefix(); + objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); + } + if (from.has_csharp_namespace()) { + set_has_csharp_namespace(); + csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + } + if (from.has_swift_prefix()) { + set_has_swift_prefix(); + swift_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.swift_prefix_); + } if (from.has_java_multiple_files()) { set_java_multiple_files(from.java_multiple_files()); } if (from.has_java_generate_equals_and_hash()) { set_java_generate_equals_and_hash(from.java_generate_equals_and_hash()); } + } + if (from._has_bits_[8 / 32] & 32512u) { if (from.has_java_string_check_utf8()) { set_java_string_check_utf8(from.java_string_check_utf8()); } - if (from.has_optimize_for()) { - set_optimize_for(from.optimize_for()); - } - if (from.has_go_package()) { - set_has_go_package(); - go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_); - } if (from.has_cc_generic_services()) { set_cc_generic_services(from.cc_generic_services()); } - } - if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from.has_java_generic_services()) { set_java_generic_services(from.java_generic_services()); } @@ -9085,20 +8733,10 @@ void FileOptions::UnsafeMergeFrom(const FileOptions& from) { if (from.has_cc_enable_arenas()) { set_cc_enable_arenas(from.cc_enable_arenas()); } - if (from.has_objc_class_prefix()) { - set_has_objc_class_prefix(); - objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_); - } - if (from.has_csharp_namespace()) { - set_has_csharp_namespace(); - csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_); + if (from.has_optimize_for()) { + set_optimize_for(from.optimize_for()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FileOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -9112,16 +8750,15 @@ void FileOptions::CopyFrom(const FileOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FileOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -9130,21 +8767,22 @@ void FileOptions::Swap(FileOptions* other) { InternalSwap(other); } void FileOptions::InternalSwap(FileOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); java_package_.Swap(&other->java_package_); java_outer_classname_.Swap(&other->java_outer_classname_); + go_package_.Swap(&other->go_package_); + objc_class_prefix_.Swap(&other->objc_class_prefix_); + csharp_namespace_.Swap(&other->csharp_namespace_); + swift_prefix_.Swap(&other->swift_prefix_); std::swap(java_multiple_files_, other->java_multiple_files_); std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_); std::swap(java_string_check_utf8_, other->java_string_check_utf8_); - std::swap(optimize_for_, other->optimize_for_); - go_package_.Swap(&other->go_package_); std::swap(cc_generic_services_, other->cc_generic_services_); std::swap(java_generic_services_, other->java_generic_services_); std::swap(py_generic_services_, other->py_generic_services_); std::swap(deprecated_, other->deprecated_); std::swap(cc_enable_arenas_, other->cc_enable_arenas_); - objc_class_prefix_.Swap(&other->objc_class_prefix_); - csharp_namespace_.Swap(&other->csharp_namespace_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(optimize_for_, other->optimize_for_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -9153,10 +8791,7 @@ void FileOptions::InternalSwap(FileOptions* other) { ::google::protobuf::Metadata FileOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FileOptions_descriptor_; - metadata.reflection = FileOptions_reflection_; - return metadata; + return file_level_metadata[11]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -9178,7 +8813,7 @@ void FileOptions::clear_java_package() { } const ::std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) - return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return java_package_.GetNoArena(); } void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); @@ -9232,7 +8867,7 @@ void FileOptions::clear_java_outer_classname() { } const ::std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) - return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return java_outer_classname_.GetNoArena(); } void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); @@ -9272,13 +8907,13 @@ void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_c // optional bool java_multiple_files = 10 [default = false]; bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000040u; } void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000040u; } void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -9296,13 +8931,13 @@ void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000080u; } void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000080u; } void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -9320,13 +8955,13 @@ void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000100u; } void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000100u; } void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -9344,13 +8979,13 @@ void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00004000u; } void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00004000u; } void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -9369,13 +9004,13 @@ void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode // optional string go_package = 11; bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9383,7 +9018,7 @@ void FileOptions::clear_go_package() { } const ::std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) - return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return go_package_.GetNoArena(); } void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); @@ -9423,13 +9058,13 @@ void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000200u; } void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000200u; } void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -9447,13 +9082,13 @@ void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000400u; } void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000400u; } void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -9471,13 +9106,13 @@ void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000800u; } void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000800u; } void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -9495,13 +9130,13 @@ void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00001000u; } void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00001000u; } void FileOptions::clear_deprecated() { deprecated_ = false; @@ -9519,13 +9154,13 @@ void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00002000u) != 0; } void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00002000u; } void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00002000u; } void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -9543,13 +9178,13 @@ void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000008u; } void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000008u; } void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9557,7 +9192,7 @@ void FileOptions::clear_objc_class_prefix() { } const ::std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) - return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return objc_class_prefix_.GetNoArena(); } void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); @@ -9597,13 +9232,13 @@ void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_pref // optional string csharp_namespace = 37; bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00000010u; } void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00000010u; } void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -9611,7 +9246,7 @@ void FileOptions::clear_csharp_namespace() { } const ::std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) - return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return csharp_namespace_.GetNoArena(); } void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); @@ -9649,6 +9284,60 @@ void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional string swift_prefix = 39; +bool FileOptions::has_swift_prefix() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void FileOptions::set_has_swift_prefix() { + _has_bits_[0] |= 0x00000020u; +} +void FileOptions::clear_has_swift_prefix() { + _has_bits_[0] &= ~0x00000020u; +} +void FileOptions::clear_swift_prefix() { + swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_swift_prefix(); +} +const ::std::string& FileOptions::swift_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.GetNoArena(); +} +void FileOptions::set_swift_prefix(const ::std::string& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) +} +void FileOptions::set_swift_prefix(const char* value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) +} +void FileOptions::set_swift_prefix(const char* value, size_t size) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) +} +::std::string* FileOptions::mutable_swift_prefix() { + set_has_swift_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* FileOptions::release_swift_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) + clear_has_swift_prefix(); + return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { + if (swift_prefix != NULL) { + set_has_swift_prefix(); + } else { + clear_has_swift_prefix(); + } + swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -9679,9 +9368,6 @@ FileOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FileOptions* FileOptions::internal_default_instance() { - return &FileOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -9696,19 +9382,23 @@ const int MessageOptions::kUninterpretedOptionFieldNumber; MessageOptions::MessageOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions) } - -void MessageOptions::InitAsDefaultInstance() { -} - MessageOptions::MessageOptions(const MessageOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&message_set_wire_format_, &from.message_set_wire_format_, + reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions) } @@ -9733,7 +9423,7 @@ void MessageOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MessageOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return MessageOptions_descriptor_; + return file_level_metadata[12].descriptor; } const MessageOptions& MessageOptions::default_instance() { @@ -9741,8 +9431,6 @@ const MessageOptions& MessageOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_; - MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { MessageOptions* n = new MessageOptions; if (arena != NULL) { @@ -9754,32 +9442,13 @@ MessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const { void MessageOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(MessageOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<MessageOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(message_set_wire_format_, map_entry_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 15u) { + ::memset(&message_set_wire_format_, 0, reinterpret_cast<char*>(&map_entry_) - + reinterpret_cast<char*>(&message_set_wire_format_) + sizeof(map_entry_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MessageOptions::MergePartialFromCodedStream( @@ -9788,13 +9457,13 @@ bool MessageOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool message_set_wire_format = 1 [default = false]; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_message_set_wire_format(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9802,14 +9471,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_no_standard_descriptor_accessor; break; } // optional bool no_standard_descriptor_accessor = 2 [default = false]; case 2: { - if (tag == 16) { - parse_no_standard_descriptor_accessor: + if (tag == 16u) { set_has_no_standard_descriptor_accessor(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9817,14 +9484,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9832,14 +9497,12 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(56)) goto parse_map_entry; break; } // optional bool map_entry = 7; case 7: { - if (tag == 56) { - parse_map_entry: + if (tag == 56u) { set_has_map_entry(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -9847,24 +9510,19 @@ bool MessageOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -9982,6 +9640,24 @@ size_t MessageOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } + } + if (_has_bits_[0 / 32] & 15u) { // optional bool message_set_wire_format = 1 [default = false]; if (has_message_set_wire_format()) { @@ -10004,24 +9680,6 @@ size_t MessageOptions::ByteSizeLong() const { } } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = this->uninterpreted_option_size(); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - } - - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -10031,7 +9689,7 @@ size_t MessageOptions::ByteSizeLong() const { void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MessageOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>( &from); @@ -10040,23 +9698,17 @@ void MessageOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MessageOptions::MergeFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 15u) { if (from.has_message_set_wire_format()) { set_message_set_wire_format(from.message_set_wire_format()); } @@ -10070,11 +9722,6 @@ void MessageOptions::UnsafeMergeFrom(const MessageOptions& from) { set_map_entry(from.map_entry()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void MessageOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -10088,16 +9735,15 @@ void MessageOptions::CopyFrom(const MessageOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MessageOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -10106,11 +9752,11 @@ void MessageOptions::Swap(MessageOptions* other) { InternalSwap(other); } void MessageOptions::InternalSwap(MessageOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(message_set_wire_format_, other->message_set_wire_format_); std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); std::swap(deprecated_, other->deprecated_); std::swap(map_entry_, other->map_entry_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -10119,10 +9765,7 @@ void MessageOptions::InternalSwap(MessageOptions* other) { ::google::protobuf::Metadata MessageOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MessageOptions_descriptor_; - metadata.reflection = MessageOptions_reflection_; - return metadata; + return file_level_metadata[12]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10254,59 +9897,10 @@ MessageOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MessageOptions* MessageOptions::internal_default_instance() { - return &MessageOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_CType_descriptor_; -} -bool FieldOptions_CType_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldOptions_CType FieldOptions::STRING; -const FieldOptions_CType FieldOptions::CORD; -const FieldOptions_CType FieldOptions::STRING_PIECE; -const FieldOptions_CType FieldOptions::CType_MIN; -const FieldOptions_CType FieldOptions::CType_MAX; -const int FieldOptions::CType_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() { - protobuf_AssignDescriptorsOnce(); - return FieldOptions_JSType_descriptor_; -} -bool FieldOptions_JSType_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const FieldOptions_JSType FieldOptions::JS_NORMAL; -const FieldOptions_JSType FieldOptions::JS_STRING; -const FieldOptions_JSType FieldOptions::JS_NUMBER; -const FieldOptions_JSType FieldOptions::JSType_MIN; -const FieldOptions_JSType FieldOptions::JSType_MAX; -const int FieldOptions::JSType_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int FieldOptions::kCtypeFieldNumber; const int FieldOptions::kPackedFieldNumber; @@ -10319,19 +9913,23 @@ const int FieldOptions::kUninterpretedOptionFieldNumber; FieldOptions::FieldOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions) } - -void FieldOptions::InitAsDefaultInstance() { -} - FieldOptions::FieldOptions(const FieldOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&ctype_, &from.ctype_, + reinterpret_cast<char*>(&weak_) - + reinterpret_cast<char*>(&ctype_) + sizeof(weak_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions) } @@ -10356,7 +9954,7 @@ void FieldOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldOptions_descriptor_; + return file_level_metadata[13].descriptor; } const FieldOptions& FieldOptions::default_instance() { @@ -10364,8 +9962,6 @@ const FieldOptions& FieldOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_; - FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { FieldOptions* n = new FieldOptions; if (arena != NULL) { @@ -10377,32 +9973,13 @@ FieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const { void FieldOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(FieldOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<FieldOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(ctype_, weak_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 63u) { + ::memset(&ctype_, 0, reinterpret_cast<char*>(&weak_) - + reinterpret_cast<char*>(&ctype_) + sizeof(weak_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool FieldOptions::MergePartialFromCodedStream( @@ -10411,13 +9988,13 @@ bool FieldOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10430,14 +10007,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_packed; break; } // optional bool packed = 2; case 2: { - if (tag == 16) { - parse_packed: + if (tag == 16u) { set_has_packed(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10445,14 +10020,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10460,14 +10033,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_lazy; break; } // optional bool lazy = 5 [default = false]; case 5: { - if (tag == 40) { - parse_lazy: + if (tag == 40u) { set_has_lazy(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10475,14 +10046,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_jstype; break; } // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; case 6: { - if (tag == 48) { - parse_jstype: + if (tag == 48u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -10495,14 +10064,12 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(80)) goto parse_weak; break; } // optional bool weak = 10 [default = false]; case 10: { - if (tag == 80) { - parse_weak: + if (tag == 80u) { set_has_weak(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -10510,24 +10077,19 @@ bool FieldOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -10669,6 +10231,24 @@ size_t FieldOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + { + unsigned int count = this->uninterpreted_option_size(); + total_size += 2UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->uninterpreted_option(i)); + } + } + if (_has_bits_[0 / 32] & 63u) { // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; if (has_ctype()) { @@ -10676,17 +10256,17 @@ size_t FieldOptions::ByteSizeLong() const { ::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype()); } - // optional bool packed = 2; - if (has_packed()) { - total_size += 1 + 1; - } - // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; if (has_jstype()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->jstype()); } + // optional bool packed = 2; + if (has_packed()) { + total_size += 1 + 1; + } + // optional bool lazy = 5 [default = false]; if (has_lazy()) { total_size += 1 + 1; @@ -10703,24 +10283,6 @@ size_t FieldOptions::ByteSizeLong() const { } } - // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = this->uninterpreted_option_size(); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->uninterpreted_option(i)); - } - } - - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -10730,7 +10292,7 @@ size_t FieldOptions::ByteSizeLong() const { void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>( &from); @@ -10739,32 +10301,26 @@ void FieldOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldOptions::MergeFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 63u) { if (from.has_ctype()) { set_ctype(from.ctype()); } - if (from.has_packed()) { - set_packed(from.packed()); - } if (from.has_jstype()) { set_jstype(from.jstype()); } + if (from.has_packed()) { + set_packed(from.packed()); + } if (from.has_lazy()) { set_lazy(from.lazy()); } @@ -10775,11 +10331,6 @@ void FieldOptions::UnsafeMergeFrom(const FieldOptions& from) { set_weak(from.weak()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void FieldOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -10793,16 +10344,15 @@ void FieldOptions::CopyFrom(const FieldOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -10811,13 +10361,13 @@ void FieldOptions::Swap(FieldOptions* other) { InternalSwap(other); } void FieldOptions::InternalSwap(FieldOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(ctype_, other->ctype_); - std::swap(packed_, other->packed_); std::swap(jstype_, other->jstype_); + std::swap(packed_, other->packed_); std::swap(lazy_, other->lazy_); std::swap(deprecated_, other->deprecated_); std::swap(weak_, other->weak_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -10826,10 +10376,7 @@ void FieldOptions::InternalSwap(FieldOptions* other) { ::google::protobuf::Metadata FieldOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldOptions_descriptor_; - metadata.reflection = FieldOptions_reflection_; - return metadata; + return file_level_metadata[13]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -10862,13 +10409,13 @@ void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) { // optional bool packed = 2; bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } void FieldOptions::clear_packed() { packed_ = false; @@ -10886,13 +10433,13 @@ void FieldOptions::set_packed(bool value) { // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; bool FieldOptions::has_jstype() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void FieldOptions::set_has_jstype() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } void FieldOptions::clear_has_jstype() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } void FieldOptions::clear_jstype() { jstype_ = 0; @@ -11011,9 +10558,6 @@ FieldOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FieldOptions* FieldOptions::internal_default_instance() { - return &FieldOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11024,19 +10568,20 @@ const int OneofOptions::kUninterpretedOptionFieldNumber; OneofOptions::OneofOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions) } - -void OneofOptions::InitAsDefaultInstance() { -} - OneofOptions::OneofOptions(const OneofOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions) } @@ -11059,7 +10604,7 @@ void OneofOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* OneofOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return OneofOptions_descriptor_; + return file_level_metadata[14].descriptor; } const OneofOptions& OneofOptions::default_instance() { @@ -11067,8 +10612,6 @@ const OneofOptions& OneofOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_; - OneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const { OneofOptions* n = new OneofOptions; if (arena != NULL) { @@ -11082,9 +10625,7 @@ void OneofOptions::Clear() { _extensions_.Clear(); uninterpreted_option_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool OneofOptions::MergePartialFromCodedStream( @@ -11093,23 +10634,20 @@ bool OneofOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11187,6 +10725,13 @@ size_t OneofOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions) size_t total_size = 0; + total_size += _extensions_.ByteSize(); + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -11198,13 +10743,6 @@ size_t OneofOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -11214,7 +10752,7 @@ size_t OneofOptions::ByteSizeLong() const { void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const OneofOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>( &from); @@ -11223,27 +10761,16 @@ void OneofOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void OneofOptions::MergeFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void OneofOptions::UnsafeMergeFrom(const OneofOptions& from) { - GOOGLE_DCHECK(&from != this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); } void OneofOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -11257,16 +10784,15 @@ void OneofOptions::CopyFrom(const OneofOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool OneofOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -11284,10 +10810,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) { ::google::protobuf::Metadata OneofOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = OneofOptions_descriptor_; - metadata.reflection = OneofOptions_reflection_; - return metadata; + return file_level_metadata[14]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11323,9 +10846,6 @@ OneofOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const OneofOptions* OneofOptions::internal_default_instance() { - return &OneofOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11338,19 +10858,23 @@ const int EnumOptions::kUninterpretedOptionFieldNumber; EnumOptions::EnumOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions) } - -void EnumOptions::InitAsDefaultInstance() { -} - EnumOptions::EnumOptions(const EnumOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&allow_alias_, &from.allow_alias_, + reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions) } @@ -11375,7 +10899,7 @@ void EnumOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumOptions_descriptor_; + return file_level_metadata[15].descriptor; } const EnumOptions& EnumOptions::default_instance() { @@ -11383,8 +10907,6 @@ const EnumOptions& EnumOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_; - EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { EnumOptions* n = new EnumOptions; if (arena != NULL) { @@ -11396,32 +10918,13 @@ EnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const { void EnumOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions) _extensions_.Clear(); -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(EnumOptions, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<EnumOptions*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(allow_alias_, deprecated_); - -#undef ZR_HELPER_ -#undef ZR_ - uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&allow_alias_, 0, reinterpret_cast<char*>(&deprecated_) - + reinterpret_cast<char*>(&allow_alias_) + sizeof(deprecated_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool EnumOptions::MergePartialFromCodedStream( @@ -11430,13 +10933,13 @@ bool EnumOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool allow_alias = 2; case 2: { - if (tag == 16) { + if (tag == 16u) { set_has_allow_alias(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11444,14 +10947,12 @@ bool EnumOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_deprecated; break; } // optional bool deprecated = 3 [default = false]; case 3: { - if (tag == 24) { - parse_deprecated: + if (tag == 24u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11459,24 +10960,19 @@ bool EnumOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11574,17 +11070,12 @@ size_t EnumOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions) size_t total_size = 0; - if (_has_bits_[0 / 32] & 3u) { - // optional bool allow_alias = 2; - if (has_allow_alias()) { - total_size += 1 + 1; - } - - // optional bool deprecated = 3 [default = false]; - if (has_deprecated()) { - total_size += 1 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { @@ -11597,12 +11088,17 @@ size_t EnumOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); + if (_has_bits_[0 / 32] & 3u) { + // optional bool allow_alias = 2; + if (has_allow_alias()) { + total_size += 1 + 1; + } + + // optional bool deprecated = 3 [default = false]; + if (has_deprecated()) { + total_size += 1 + 1; + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -11613,7 +11109,7 @@ size_t EnumOptions::ByteSizeLong() const { void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>( &from); @@ -11622,23 +11118,17 @@ void EnumOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumOptions::MergeFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_allow_alias()) { set_allow_alias(from.allow_alias()); } @@ -11646,11 +11136,6 @@ void EnumOptions::UnsafeMergeFrom(const EnumOptions& from) { set_deprecated(from.deprecated()); } } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void EnumOptions::CopyFrom(const ::google::protobuf::Message& from) { @@ -11664,16 +11149,15 @@ void EnumOptions::CopyFrom(const EnumOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -11682,9 +11166,9 @@ void EnumOptions::Swap(EnumOptions* other) { InternalSwap(other); } void EnumOptions::InternalSwap(EnumOptions* other) { + uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(allow_alias_, other->allow_alias_); std::swap(deprecated_, other->deprecated_); - uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -11693,10 +11177,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) { ::google::protobuf::Metadata EnumOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumOptions_descriptor_; - metadata.reflection = EnumOptions_reflection_; - return metadata; + return file_level_metadata[15]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -11780,9 +11261,6 @@ EnumOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumOptions* EnumOptions::internal_default_instance() { - return &EnumOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -11794,19 +11272,21 @@ const int EnumValueOptions::kUninterpretedOptionFieldNumber; EnumValueOptions::EnumValueOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions) } - -void EnumValueOptions::InitAsDefaultInstance() { -} - EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions) } @@ -11830,7 +11310,7 @@ void EnumValueOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValueOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValueOptions_descriptor_; + return file_level_metadata[16].descriptor; } const EnumValueOptions& EnumValueOptions::default_instance() { @@ -11838,8 +11318,6 @@ const EnumValueOptions& EnumValueOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_; - EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const { EnumValueOptions* n = new EnumValueOptions; if (arena != NULL) { @@ -11851,12 +11329,10 @@ EnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const void EnumValueOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); + deprecated_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool EnumValueOptions::MergePartialFromCodedStream( @@ -11865,13 +11341,13 @@ bool EnumValueOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 1 [default = false]; case 1: { - if (tag == 8) { + if (tag == 8u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -11879,24 +11355,19 @@ bool EnumValueOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -11984,11 +11455,13 @@ size_t EnumValueOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions) size_t total_size = 0; - // optional bool deprecated = 1 [default = false]; - if (has_deprecated()) { - total_size += 1 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12000,13 +11473,11 @@ size_t EnumValueOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional bool deprecated = 1 [default = false]; + if (has_deprecated()) { + total_size += 1 + 1; } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -12016,7 +11487,7 @@ size_t EnumValueOptions::ByteSizeLong() const { void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValueOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>( &from); @@ -12025,31 +11496,18 @@ void EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValueOptions::MergeFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumValueOptions::UnsafeMergeFrom(const EnumValueOptions& from) { - GOOGLE_DCHECK(&from != this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_deprecated()) { - set_deprecated(from.deprecated()); - } - } + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + if (from.has_deprecated()) { + set_deprecated(from.deprecated()); } } @@ -12064,16 +11522,15 @@ void EnumValueOptions::CopyFrom(const EnumValueOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValueOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12082,8 +11539,8 @@ void EnumValueOptions::Swap(EnumValueOptions* other) { InternalSwap(other); } void EnumValueOptions::InternalSwap(EnumValueOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12092,10 +11549,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { ::google::protobuf::Metadata EnumValueOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValueOptions_descriptor_; - metadata.reflection = EnumValueOptions_reflection_; - return metadata; + return file_level_metadata[16]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12155,9 +11609,6 @@ EnumValueOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumValueOptions* EnumValueOptions::internal_default_instance() { - return &EnumValueOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -12169,19 +11620,21 @@ const int ServiceOptions::kUninterpretedOptionFieldNumber; ServiceOptions::ServiceOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions) } - -void ServiceOptions::InitAsDefaultInstance() { -} - ServiceOptions::ServiceOptions(const ServiceOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + deprecated_ = from.deprecated_; // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions) } @@ -12205,7 +11658,7 @@ void ServiceOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ServiceOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return ServiceOptions_descriptor_; + return file_level_metadata[17].descriptor; } const ServiceOptions& ServiceOptions::default_instance() { @@ -12213,8 +11666,6 @@ const ServiceOptions& ServiceOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_; - ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { ServiceOptions* n = new ServiceOptions; if (arena != NULL) { @@ -12226,12 +11677,10 @@ ServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const { void ServiceOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); + deprecated_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool ServiceOptions::MergePartialFromCodedStream( @@ -12240,13 +11689,13 @@ bool ServiceOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264) { + if (tag == 264u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12254,24 +11703,19 @@ bool ServiceOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -12359,11 +11803,13 @@ size_t ServiceOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions) size_t total_size = 0; - // optional bool deprecated = 33 [default = false]; - if (has_deprecated()) { - total_size += 2 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12375,13 +11821,11 @@ size_t ServiceOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + // optional bool deprecated = 33 [default = false]; + if (has_deprecated()) { + total_size += 2 + 1; } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -12391,7 +11835,7 @@ size_t ServiceOptions::ByteSizeLong() const { void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ServiceOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>( &from); @@ -12400,31 +11844,18 @@ void ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ServiceOptions::MergeFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void ServiceOptions::UnsafeMergeFrom(const ServiceOptions& from) { - GOOGLE_DCHECK(&from != this); - uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_deprecated()) { - set_deprecated(from.deprecated()); - } - } + GOOGLE_DCHECK_NE(&from, this); _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + _internal_metadata_.MergeFrom(from._internal_metadata_); + uninterpreted_option_.MergeFrom(from.uninterpreted_option_); + if (from.has_deprecated()) { + set_deprecated(from.deprecated()); } } @@ -12439,16 +11870,15 @@ void ServiceOptions::CopyFrom(const ServiceOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ServiceOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12457,8 +11887,8 @@ void ServiceOptions::Swap(ServiceOptions* other) { InternalSwap(other); } void ServiceOptions::InternalSwap(ServiceOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12467,10 +11897,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { ::google::protobuf::Metadata ServiceOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ServiceOptions_descriptor_; - metadata.reflection = ServiceOptions_reflection_; - return metadata; + return file_level_metadata[17]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12530,39 +11957,42 @@ ServiceOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const ServiceOptions* ServiceOptions::internal_default_instance() { - return &ServiceOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int MethodOptions::kDeprecatedFieldNumber; +const int MethodOptions::kIdempotencyLevelFieldNumber; const int MethodOptions::kUninterpretedOptionFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 MethodOptions::MethodOptions() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions) } - -void MethodOptions::InitAsDefaultInstance() { -} - MethodOptions::MethodOptions(const MethodOptions& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + uninterpreted_option_(from.uninterpreted_option_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + _extensions_.MergeFrom(from._extensions_); + ::memcpy(&deprecated_, &from.deprecated_, + reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions) } void MethodOptions::SharedCtor() { _cached_size_ = 0; - deprecated_ = false; + ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); } MethodOptions::~MethodOptions() { @@ -12580,7 +12010,7 @@ void MethodOptions::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* MethodOptions::descriptor() { protobuf_AssignDescriptorsOnce(); - return MethodOptions_descriptor_; + return file_level_metadata[18].descriptor; } const MethodOptions& MethodOptions::default_instance() { @@ -12588,8 +12018,6 @@ const MethodOptions& MethodOptions::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_; - MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { MethodOptions* n = new MethodOptions; if (arena != NULL) { @@ -12601,12 +12029,13 @@ MethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const { void MethodOptions::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions) _extensions_.Clear(); - deprecated_ = false; uninterpreted_option_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 3u) { + ::memset(&deprecated_, 0, reinterpret_cast<char*>(&idempotency_level_) - + reinterpret_cast<char*>(&deprecated_) + sizeof(idempotency_level_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool MethodOptions::MergePartialFromCodedStream( @@ -12615,13 +12044,13 @@ bool MethodOptions::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(16383u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional bool deprecated = 33 [default = false]; case 33: { - if (tag == 264) { + if (tag == 264u) { set_has_deprecated(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -12629,24 +12058,37 @@ bool MethodOptions::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_uninterpreted_option; + break; + } + + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + case 34: { + if (tag == 272u) { + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)) { + set_idempotency_level(static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(value)); + } else { + mutable_unknown_fields()->AddVarint(34, value); + } + } else { + goto handle_unusual; + } break; } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; case 999: { - if (tag == 7994) { - parse_uninterpreted_option: + if (tag == 7994u) { DO_(input->IncrementRecursionDepth()); - parse_loop_uninterpreted_option: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_uninterpreted_option())); } else { goto handle_unusual; } - if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -12685,6 +12127,12 @@ void MethodOptions::SerializeWithCachedSizes( ::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output); } + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 34, this->idempotency_level(), output); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( @@ -12711,6 +12159,12 @@ void MethodOptions::SerializeWithCachedSizes( target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target); } + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 34, this->idempotency_level(), target); + } + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: @@ -12734,11 +12188,13 @@ size_t MethodOptions::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions) size_t total_size = 0; - // optional bool deprecated = 33 [default = false]; - if (has_deprecated()) { - total_size += 2 + 1; - } + total_size += _extensions_.ByteSize(); + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; { unsigned int count = this->uninterpreted_option_size(); @@ -12750,12 +12206,18 @@ size_t MethodOptions::ByteSizeLong() const { } } - total_size += _extensions_.ByteSize(); + if (_has_bits_[0 / 32] & 3u) { + // optional bool deprecated = 33 [default = false]; + if (has_deprecated()) { + total_size += 2 + 1; + } + + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + if (has_idempotency_level()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->idempotency_level()); + } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -12766,7 +12228,7 @@ size_t MethodOptions::ByteSizeLong() const { void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const MethodOptions* source = ::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>( &from); @@ -12775,31 +12237,23 @@ void MethodOptions::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void MethodOptions::MergeFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void MethodOptions::UnsafeMergeFrom(const MethodOptions& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _extensions_.MergeFrom(from._extensions_); + _internal_metadata_.MergeFrom(from._internal_metadata_); uninterpreted_option_.MergeFrom(from.uninterpreted_option_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from._has_bits_[0 / 32] & 3u) { if (from.has_deprecated()) { set_deprecated(from.deprecated()); } - } - _extensions_.MergeFrom(from._extensions_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); + if (from.has_idempotency_level()) { + set_idempotency_level(from.idempotency_level()); + } } } @@ -12814,16 +12268,15 @@ void MethodOptions::CopyFrom(const MethodOptions& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool MethodOptions::IsInitialized() const { - - if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; - if (!_extensions_.IsInitialized()) { return false; } + + if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false; return true; } @@ -12832,8 +12285,9 @@ void MethodOptions::Swap(MethodOptions* other) { InternalSwap(other); } void MethodOptions::InternalSwap(MethodOptions* other) { - std::swap(deprecated_, other->deprecated_); uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_); + std::swap(deprecated_, other->deprecated_); + std::swap(idempotency_level_, other->idempotency_level_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -12842,10 +12296,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) { ::google::protobuf::Metadata MethodOptions::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = MethodOptions_descriptor_; - metadata.reflection = MethodOptions_reflection_; - return metadata; + return file_level_metadata[18]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -12875,6 +12326,31 @@ void MethodOptions::set_deprecated(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) } +// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; +bool MethodOptions::has_idempotency_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void MethodOptions::set_has_idempotency_level() { + _has_bits_[0] |= 0x00000002u; +} +void MethodOptions::clear_has_idempotency_level() { + _has_bits_[0] &= ~0x00000002u; +} +void MethodOptions::clear_idempotency_level() { + idempotency_level_ = 0; + clear_has_idempotency_level(); +} +::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { + // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) + return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_); +} +void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) { + assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)); + set_has_idempotency_level(); + idempotency_level_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int MethodOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -12905,9 +12381,6 @@ MethodOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MethodOptions* MethodOptions::internal_default_instance() { - return &MethodOptions_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -12919,19 +12392,23 @@ const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; UninterpretedOption_NamePart::UninterpretedOption_NamePart() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart) } - -void UninterpretedOption_NamePart::InitAsDefaultInstance() { -} - UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_name_part()) { + name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); + } + is_extension_ = from.is_extension_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart) } @@ -12957,7 +12434,7 @@ void UninterpretedOption_NamePart::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() { protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_NamePart_descriptor_; + return file_level_metadata[19].descriptor; } const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() { @@ -12965,8 +12442,6 @@ const UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instan return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart_default_instance_; - UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const { UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart; if (arena != NULL) { @@ -12977,16 +12452,13 @@ UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protob void UninterpretedOption_NamePart::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart) - if (_has_bits_[0 / 32] & 3u) { - if (has_name_part()) { - name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - is_extension_ = false; + if (has_name_part()) { + GOOGLE_DCHECK(!name_part_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*name_part_.UnsafeRawStringPointer())->clear(); } + is_extension_ = false; _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool UninterpretedOption_NamePart::MergePartialFromCodedStream( @@ -12995,13 +12467,13 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // required string name_part = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name_part())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13011,14 +12483,12 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_is_extension; break; } // required bool is_extension = 2; case 2: { - if (tag == 16) { - parse_is_extension: + if (tag == 16u) { set_has_is_extension(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -13026,7 +12496,6 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13127,6 +12596,11 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) { // All required fields are present. // required string name_part = 1; total_size += 1 + @@ -13139,11 +12613,6 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { } else { total_size += RequiredFieldsByteSizeFallback(); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -13153,7 +12622,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UninterpretedOption_NamePart* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>( &from); @@ -13162,22 +12631,15 @@ void UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_NamePart& from) { - GOOGLE_DCHECK(&from != this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_name_part()) { set_has_name_part(); name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_); @@ -13186,10 +12648,6 @@ void UninterpretedOption_NamePart::UnsafeMergeFrom(const UninterpretedOption_Nam set_is_extension(from.is_extension()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) { @@ -13203,12 +12661,11 @@ void UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UninterpretedOption_NamePart::IsInitialized() const { if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - return true; } @@ -13226,14 +12683,93 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot ::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_NamePart_descriptor_; - metadata.reflection = UninterpretedOption_NamePart_reflection_; - return metadata; + return file_level_metadata[19]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// UninterpretedOption_NamePart + +// required string name_part = 1; +bool UninterpretedOption_NamePart::has_name_part() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void UninterpretedOption_NamePart::set_has_name_part() { + _has_bits_[0] |= 0x00000001u; +} +void UninterpretedOption_NamePart::clear_has_name_part() { + _has_bits_[0] &= ~0x00000001u; +} +void UninterpretedOption_NamePart::clear_name_part() { + name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_name_part(); +} +const ::std::string& UninterpretedOption_NamePart::name_part() const { + // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) + return name_part_.GetNoArena(); +} +void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { + set_has_name_part(); + name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) +} +void UninterpretedOption_NamePart::set_name_part(const char* value) { + set_has_name_part(); + name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) +} +void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { + set_has_name_part(); + name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) +} +::std::string* UninterpretedOption_NamePart::mutable_name_part() { + set_has_name_part(); + // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) + return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* UninterpretedOption_NamePart::release_name_part() { + // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) + clear_has_name_part(); + return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { + if (name_part != NULL) { + set_has_name_part(); + } else { + clear_has_name_part(); + } + name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) +} + +// required bool is_extension = 2; +bool UninterpretedOption_NamePart::has_is_extension() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void UninterpretedOption_NamePart::set_has_is_extension() { + _has_bits_[0] |= 0x00000002u; +} +void UninterpretedOption_NamePart::clear_has_is_extension() { + _has_bits_[0] &= ~0x00000002u; +} +void UninterpretedOption_NamePart::clear_is_extension() { + is_extension_ = false; + clear_has_is_extension(); +} +bool UninterpretedOption_NamePart::is_extension() const { + // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) + return is_extension_; +} +void UninterpretedOption_NamePart::set_is_extension(bool value) { + set_has_is_extension(); + is_extension_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int UninterpretedOption::kNameFieldNumber; @@ -13247,19 +12783,34 @@ const int UninterpretedOption::kAggregateValueFieldNumber; UninterpretedOption::UninterpretedOption() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption) } - -void UninterpretedOption::InitAsDefaultInstance() { -} - UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + name_(from.name_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_identifier_value()) { + identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); + } + string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_string_value()) { + string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + } + aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_aggregate_value()) { + aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + } + ::memcpy(&positive_int_value_, &from.positive_int_value_, + reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption) } @@ -13290,7 +12841,7 @@ void UninterpretedOption::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UninterpretedOption::descriptor() { protobuf_AssignDescriptorsOnce(); - return UninterpretedOption_descriptor_; + return file_level_metadata[20].descriptor; } const UninterpretedOption& UninterpretedOption::default_instance() { @@ -13298,8 +12849,6 @@ const UninterpretedOption& UninterpretedOption::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_; - UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const { UninterpretedOption* n = new UninterpretedOption; if (arena != NULL) { @@ -13310,43 +12859,27 @@ UninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) void UninterpretedOption::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(UninterpretedOption, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<UninterpretedOption*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - if (_has_bits_[0 / 32] & 126u) { - ZR_(positive_int_value_, double_value_); + name_.Clear(); + if (_has_bits_[0 / 32] & 7u) { if (has_identifier_value()) { - identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!identifier_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*identifier_value_.UnsafeRawStringPointer())->clear(); } if (has_string_value()) { - string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!string_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*string_value_.UnsafeRawStringPointer())->clear(); } if (has_aggregate_value()) { - aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!aggregate_value_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*aggregate_value_.UnsafeRawStringPointer())->clear(); } } - -#undef ZR_HELPER_ -#undef ZR_ - - name_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (_has_bits_[0 / 32] & 56u) { + ::memset(&positive_int_value_, 0, reinterpret_cast<char*>(&double_value_) - + reinterpret_cast<char*>(&positive_int_value_) + sizeof(double_value_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool UninterpretedOption::MergePartialFromCodedStream( @@ -13355,30 +12888,26 @@ bool UninterpretedOption::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; case 2: { - if (tag == 18) { + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_name: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_name())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_name; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_identifier_value; break; } // optional string identifier_value = 3; case 3: { - if (tag == 26) { - parse_identifier_value: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_identifier_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13388,14 +12917,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_positive_int_value; break; } // optional uint64 positive_int_value = 4; case 4: { - if (tag == 32) { - parse_positive_int_value: + if (tag == 32u) { set_has_positive_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -13403,14 +12930,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_negative_int_value; break; } // optional int64 negative_int_value = 5; case 5: { - if (tag == 40) { - parse_negative_int_value: + if (tag == 40u) { set_has_negative_int_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -13418,14 +12943,12 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(49)) goto parse_double_value; break; } // optional double double_value = 6; case 6: { - if (tag == 49) { - parse_double_value: + if (tag == 49u) { set_has_double_value(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -13433,27 +12956,23 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(58)) goto parse_string_value; break; } // optional bytes string_value = 7; case 7: { - if (tag == 58) { - parse_string_value: + if (tag == 58u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_string_value())); } else { goto handle_unusual; } - if (input->ExpectTag(66)) goto parse_aggregate_value; break; } // optional string aggregate_value = 8; case 8: { - if (tag == 66) { - parse_aggregate_value: + if (tag == 66u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_aggregate_value())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -13463,7 +12982,6 @@ bool UninterpretedOption::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -13613,7 +13131,23 @@ size_t UninterpretedOption::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption) size_t total_size = 0; - if (_has_bits_[1 / 32] & 126u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + { + unsigned int count = this->name_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->name(i)); + } + } + + if (_has_bits_[0 / 32] & 63u) { // optional string identifier_value = 3; if (has_identifier_value()) { total_size += 1 + @@ -13621,6 +13155,20 @@ size_t UninterpretedOption::ByteSizeLong() const { this->identifier_value()); } + // optional bytes string_value = 7; + if (has_string_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::BytesSize( + this->string_value()); + } + + // optional string aggregate_value = 8; + if (has_aggregate_value()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->aggregate_value()); + } + // optional uint64 positive_int_value = 4; if (has_positive_int_value()) { total_size += 1 + @@ -13640,36 +13188,6 @@ size_t UninterpretedOption::ByteSizeLong() const { total_size += 1 + 8; } - // optional bytes string_value = 7; - if (has_string_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->string_value()); - } - - // optional string aggregate_value = 8; - if (has_aggregate_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->aggregate_value()); - } - - } - // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - { - unsigned int count = this->name_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->name(i)); - } - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -13680,7 +13198,7 @@ size_t UninterpretedOption::ByteSizeLong() const { void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UninterpretedOption* source = ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>( &from); @@ -13689,27 +13207,28 @@ void UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); name_.MergeFrom(from.name_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { + if (from._has_bits_[0 / 32] & 63u) { if (from.has_identifier_value()) { set_has_identifier_value(); identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_); } + if (from.has_string_value()) { + set_has_string_value(); + string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); + } + if (from.has_aggregate_value()) { + set_has_aggregate_value(); + aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); + } if (from.has_positive_int_value()) { set_positive_int_value(from.positive_int_value()); } @@ -13719,18 +13238,6 @@ void UninterpretedOption::UnsafeMergeFrom(const UninterpretedOption& from) { if (from.has_double_value()) { set_double_value(from.double_value()); } - if (from.has_string_value()) { - set_has_string_value(); - string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_); - } - if (from.has_aggregate_value()) { - set_has_aggregate_value(); - aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_); - } - } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); } } @@ -13745,11 +13252,10 @@ void UninterpretedOption::CopyFrom(const UninterpretedOption& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UninterpretedOption::IsInitialized() const { - if (!::google::protobuf::internal::AllAreInitialized(this->name())) return false; return true; } @@ -13761,11 +13267,11 @@ void UninterpretedOption::Swap(UninterpretedOption* other) { void UninterpretedOption::InternalSwap(UninterpretedOption* other) { name_.UnsafeArenaSwap(&other->name_); identifier_value_.Swap(&other->identifier_value_); + string_value_.Swap(&other->string_value_); + aggregate_value_.Swap(&other->aggregate_value_); std::swap(positive_int_value_, other->positive_int_value_); std::swap(negative_int_value_, other->negative_int_value_); std::swap(double_value_, other->double_value_); - string_value_.Swap(&other->string_value_); - aggregate_value_.Swap(&other->aggregate_value_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -13773,98 +13279,10 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { ::google::protobuf::Metadata UninterpretedOption::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UninterpretedOption_descriptor_; - metadata.reflection = UninterpretedOption_reflection_; - return metadata; + return file_level_metadata[20]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// UninterpretedOption_NamePart - -// required string name_part = 1; -bool UninterpretedOption_NamePart::has_name_part() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -void UninterpretedOption_NamePart::set_has_name_part() { - _has_bits_[0] |= 0x00000001u; -} -void UninterpretedOption_NamePart::clear_has_name_part() { - _has_bits_[0] &= ~0x00000001u; -} -void UninterpretedOption_NamePart::clear_name_part() { - name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_name_part(); -} -const ::std::string& UninterpretedOption_NamePart::name_part() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) -} -void UninterpretedOption_NamePart::set_name_part(const char* value) { - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part) -} -void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) { - set_has_name_part(); - name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) -} -::std::string* UninterpretedOption_NamePart::mutable_name_part() { - set_has_name_part(); - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* UninterpretedOption_NamePart::release_name_part() { - // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part) - clear_has_name_part(); - return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) { - if (name_part != NULL) { - set_has_name_part(); - } else { - clear_has_name_part(); - } - name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part) -} - -// required bool is_extension = 2; -bool UninterpretedOption_NamePart::has_is_extension() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void UninterpretedOption_NamePart::set_has_is_extension() { - _has_bits_[0] |= 0x00000002u; -} -void UninterpretedOption_NamePart::clear_has_is_extension() { - _has_bits_[0] &= ~0x00000002u; -} -void UninterpretedOption_NamePart::clear_is_extension() { - is_extension_ = false; - clear_has_is_extension(); -} -bool UninterpretedOption_NamePart::is_extension() const { - // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension) - return is_extension_; -} -void UninterpretedOption_NamePart::set_is_extension(bool value) { - set_has_is_extension(); - is_extension_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) -} - -inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() { - return &UninterpretedOption_NamePart_default_instance_.get(); -} -// ------------------------------------------------------------------- - // UninterpretedOption // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; @@ -13899,13 +13317,13 @@ UninterpretedOption::name() const { // optional string identifier_value = 3; bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -13913,7 +13331,7 @@ void UninterpretedOption::clear_identifier_value() { } const ::std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) - return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return identifier_value_.GetNoArena(); } void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); @@ -13953,13 +13371,13 @@ void UninterpretedOption::set_allocated_identifier_value(::std::string* identifi // optional uint64 positive_int_value = 4; bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); @@ -13977,13 +13395,13 @@ void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 valu // optional int64 negative_int_value = 5; bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); @@ -14001,13 +13419,13 @@ void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value // optional double double_value = 6; bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } void UninterpretedOption::clear_double_value() { double_value_ = 0; @@ -14025,13 +13443,13 @@ void UninterpretedOption::set_double_value(double value) { // optional bytes string_value = 7; bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000002u; } void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000002u; } void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14039,7 +13457,7 @@ void UninterpretedOption::clear_string_value() { } const ::std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) - return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return string_value_.GetNoArena(); } void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); @@ -14079,13 +13497,13 @@ void UninterpretedOption::set_allocated_string_value(::std::string* string_value // optional string aggregate_value = 8; bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14093,7 +13511,7 @@ void UninterpretedOption::clear_aggregate_value() { } const ::std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) - return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return aggregate_value_.GetNoArena(); } void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); @@ -14131,9 +13549,6 @@ void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } -inline const UninterpretedOption* UninterpretedOption::internal_default_instance() { - return &UninterpretedOption_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -14148,19 +13563,29 @@ const int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber; SourceCodeInfo_Location::SourceCodeInfo_Location() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location) } - -void SourceCodeInfo_Location::InitAsDefaultInstance() { -} - SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + path_(from.path_), + span_(from.span_), + leading_detached_comments_(from.leading_detached_comments_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_leading_comments()) { + leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); + } + trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_trailing_comments()) { + trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) } @@ -14187,7 +13612,7 @@ void SourceCodeInfo_Location::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() { protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_Location_descriptor_; + return file_level_metadata[21].descriptor; } const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { @@ -14195,8 +13620,6 @@ const SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location_default_instance_; - SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const { SourceCodeInfo_Location* n = new SourceCodeInfo_Location; if (arena != NULL) { @@ -14207,21 +13630,21 @@ SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* void SourceCodeInfo_Location::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location) - if (_has_bits_[0 / 32] & 12u) { + path_.Clear(); + span_.Clear(); + leading_detached_comments_.Clear(); + if (_has_bits_[0 / 32] & 3u) { if (has_leading_comments()) { - leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!leading_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*leading_comments_.UnsafeRawStringPointer())->clear(); } if (has_trailing_comments()) { - trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + GOOGLE_DCHECK(!trailing_comments_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*trailing_comments_.UnsafeRawStringPointer())->clear(); } } - path_.Clear(); - span_.Clear(); - leading_detached_comments_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool SourceCodeInfo_Location::MergePartialFromCodedStream( @@ -14230,49 +13653,45 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8) { + } else if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 10, input, this->mutable_path()))); + 1, 10u, input, this->mutable_path()))); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_span; break; } // repeated int32 span = 2 [packed = true]; case 2: { - if (tag == 18) { - parse_span: + if (tag == 18u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_span()))); - } else if (tag == 16) { + } else if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 18, input, this->mutable_span()))); + 1, 18u, input, this->mutable_span()))); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_leading_comments; break; } // optional string leading_comments = 3; case 3: { - if (tag == 26) { - parse_leading_comments: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_leading_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14282,14 +13701,12 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_trailing_comments; break; } // optional string trailing_comments = 4; case 4: { - if (tag == 34) { - parse_trailing_comments: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_trailing_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14299,14 +13716,12 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_leading_detached_comments; break; } // repeated string leading_detached_comments = 6; case 6: { - if (tag == 50) { - parse_leading_detached_comments: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_leading_detached_comments())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -14317,8 +13732,6 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_leading_detached_comments; - if (input->ExpectAtEnd()) goto success; break; } @@ -14480,21 +13893,10 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location) size_t total_size = 0; - if (_has_bits_[2 / 32] & 12u) { - // optional string leading_comments = 3; - if (has_leading_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->leading_comments()); - } - - // optional string trailing_comments = 4; - if (has_trailing_comments()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->trailing_comments()); - } - + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); } // repeated int32 path = 1 [packed = true]; { @@ -14542,10 +13944,21 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { this->leading_detached_comments(i)); } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + if (_has_bits_[0 / 32] & 3u) { + // optional string leading_comments = 3; + if (has_leading_comments()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->leading_comments()); + } + + // optional string trailing_comments = 4; + if (has_trailing_comments()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->trailing_comments()); + } + } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); @@ -14556,7 +13969,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const SourceCodeInfo_Location* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>( &from); @@ -14565,25 +13978,18 @@ void SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& from) { - GOOGLE_DCHECK(&from != this); - path_.UnsafeMergeFrom(from.path_); - span_.UnsafeMergeFrom(from.span_); - leading_detached_comments_.UnsafeMergeFrom(from.leading_detached_comments_); - if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + path_.MergeFrom(from.path_); + span_.MergeFrom(from.span_); + leading_detached_comments_.MergeFrom(from.leading_detached_comments_); + if (from._has_bits_[0 / 32] & 3u) { if (from.has_leading_comments()) { set_has_leading_comments(); leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_); @@ -14593,10 +13999,6 @@ void SourceCodeInfo_Location::UnsafeMergeFrom(const SourceCodeInfo_Location& fro trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) { @@ -14610,11 +14012,10 @@ void SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool SourceCodeInfo_Location::IsInitialized() const { - return true; } @@ -14625,9 +14026,9 @@ void SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) { void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { path_.UnsafeArenaSwap(&other->path_); span_.UnsafeArenaSwap(&other->span_); + leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_); leading_comments_.Swap(&other->leading_comments_); trailing_comments_.Swap(&other->trailing_comments_); - leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_); std::swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); @@ -14635,262 +14036,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { ::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_Location_descriptor_; - metadata.reflection = SourceCodeInfo_Location_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const int SourceCodeInfo::kLocationFieldNumber; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 - -SourceCodeInfo::SourceCodeInfo() - : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); - SharedCtor(); - // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) -} - -void SourceCodeInfo::InitAsDefaultInstance() { -} - -SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) - : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); - // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) -} - -void SourceCodeInfo::SharedCtor() { - _cached_size_ = 0; -} - -SourceCodeInfo::~SourceCodeInfo() { - // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) - SharedDtor(); -} - -void SourceCodeInfo::SharedDtor() { -} - -void SourceCodeInfo::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { - protobuf_AssignDescriptorsOnce(); - return SourceCodeInfo_descriptor_; -} - -const SourceCodeInfo& SourceCodeInfo::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); - return *internal_default_instance(); -} - -::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_; - -SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { - SourceCodeInfo* n = new SourceCodeInfo; - if (arena != NULL) { - arena->Own(n); - } - return n; -} - -void SourceCodeInfo::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) - location_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } -} - -bool SourceCodeInfo::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure - ::google::protobuf::uint32 tag; - // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo) - for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); - tag = p.first; - if (!p.second) goto handle_unusual; - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - case 1: { - if (tag == 10) { - DO_(input->IncrementRecursionDepth()); - parse_loop_location: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( - input, add_location())); - } else { - goto handle_unusual; - } - if (input->ExpectTag(10)) goto parse_loop_location; - input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; - break; - } - - default: { - handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - goto success; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } -success: - // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo) - return true; -failure: - // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo) - return false; -#undef DO_ -} - -void SourceCodeInfo::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo) - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->location(i), output); - } - - if (_internal_metadata_.have_unknown_fields()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } - // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo) -} - -::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo) - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (unsigned int i = 0, n = this->location_size(); i < n; i++) { - target = ::google::protobuf::internal::WireFormatLite:: - InternalWriteMessageNoVirtualToArray( - 1, this->location(i), false, target); - } - - if (_internal_metadata_.have_unknown_fields()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) - return target; -} - -size_t SourceCodeInfo::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) - size_t total_size = 0; - - // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - { - unsigned int count = this->location_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->location(i)); - } - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); - const SourceCodeInfo* source = - ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>( - &from); - if (source == NULL) { - // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo) - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) - UnsafeMergeFrom(*source); - } -} - -void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void SourceCodeInfo::UnsafeMergeFrom(const SourceCodeInfo& from) { - GOOGLE_DCHECK(&from != this); - location_.MergeFrom(from.location_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } -} - -void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { -// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) - if (&from == this) return; - Clear(); - UnsafeMergeFrom(from); -} - -bool SourceCodeInfo::IsInitialized() const { - - return true; -} - -void SourceCodeInfo::Swap(SourceCodeInfo* other) { - if (other == this) return; - InternalSwap(other); -} -void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { - location_.UnsafeArenaSwap(&other->location_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); -} - -::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceCodeInfo_descriptor_; - metadata.reflection = SourceCodeInfo_reflection_; - return metadata; + return file_level_metadata[21]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -14958,13 +14104,13 @@ SourceCodeInfo_Location::mutable_span() { // optional string leading_comments = 3; bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000001u; } void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000001u; } void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -14972,7 +14118,7 @@ void SourceCodeInfo_Location::clear_leading_comments() { } const ::std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) - return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return leading_comments_.GetNoArena(); } void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); @@ -15012,13 +14158,13 @@ void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* lead // optional string trailing_comments = 4; bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000002u; } void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000002u; } void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -15026,7 +14172,7 @@ void SourceCodeInfo_Location::clear_trailing_comments() { } const ::std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) - return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return trailing_comments_.GetNoArena(); } void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); @@ -15119,11 +14265,238 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() { return &leading_detached_comments_; } -inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() { - return &SourceCodeInfo_Location_default_instance_.get(); +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int SourceCodeInfo::kLocationFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +SourceCodeInfo::SourceCodeInfo() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo) +} +SourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + location_(from.location_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo) +} + +void SourceCodeInfo::SharedCtor() { + _cached_size_ = 0; +} + +SourceCodeInfo::~SourceCodeInfo() { + // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo) + SharedDtor(); +} + +void SourceCodeInfo::SharedDtor() { +} + +void SourceCodeInfo::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[22].descriptor; +} + +const SourceCodeInfo& SourceCodeInfo::default_instance() { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + return *internal_default_instance(); +} + +SourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const { + SourceCodeInfo* n = new SourceCodeInfo; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void SourceCodeInfo::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo) + location_.Clear(); + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool SourceCodeInfo::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + case 1: { + if (tag == 10u) { + DO_(input->IncrementRecursionDepth()); + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_location())); + } else { + goto handle_unusual; + } + input->UnsafeDecrementRecursionDepth(); + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo) + return true; +failure: + // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo) + return false; +#undef DO_ +} + +void SourceCodeInfo::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo) + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 1, this->location(i), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo) +} + +::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo) + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + for (unsigned int i = 0, n = this->location_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 1, this->location(i), false, target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo) + return target; +} + +size_t SourceCodeInfo::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + { + unsigned int count = this->location_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->location(i)); + } + } + + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo) + GOOGLE_DCHECK_NE(&from, this); + const SourceCodeInfo* source = + ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo) + MergeFrom(*source); + } } -// ------------------------------------------------------------------- +void SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + location_.MergeFrom(from.location_); +} + +void SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeInfo::IsInitialized() const { + return true; +} + +void SourceCodeInfo::Swap(SourceCodeInfo* other) { + if (other == this) return; + InternalSwap(other); +} +void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { + location_.UnsafeArenaSwap(&other->location_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + return file_level_metadata[22]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceCodeInfo // repeated .google.protobuf.SourceCodeInfo.Location location = 1; @@ -15156,9 +14529,6 @@ SourceCodeInfo::location() const { return location_; } -inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() { - return &SourceCodeInfo_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -15172,19 +14542,26 @@ const int GeneratedCodeInfo_Annotation::kEndFieldNumber; GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation) } - -void GeneratedCodeInfo_Annotation::InitAsDefaultInstance() { -} - GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + path_(from.path_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.has_source_file()) { + source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); + } + ::memcpy(&begin_, &from.begin_, + reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_) + sizeof(end_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation) } @@ -15211,7 +14588,7 @@ void GeneratedCodeInfo_Annotation::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() { protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_Annotation_descriptor_; + return file_level_metadata[23].descriptor; } const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() { @@ -15219,8 +14596,6 @@ const GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instan return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation_default_instance_; - GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation; if (arena != NULL) { @@ -15231,37 +14606,17 @@ GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protob void GeneratedCodeInfo_Annotation::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(GeneratedCodeInfo_Annotation, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<GeneratedCodeInfo_Annotation*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - if (_has_bits_[0 / 32] & 14u) { - ZR_(begin_, end_); - if (has_source_file()) { - source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - } - } - -#undef ZR_HELPER_ -#undef ZR_ - path_.Clear(); - _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); + if (has_source_file()) { + GOOGLE_DCHECK(!source_file_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); + (*source_file_.UnsafeRawStringPointer())->clear(); + } + if (_has_bits_[0 / 32] & 6u) { + ::memset(&begin_, 0, reinterpret_cast<char*>(&end_) - + reinterpret_cast<char*>(&begin_) + sizeof(end_)); } + _has_bits_.Clear(); + _internal_metadata_.Clear(); } bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( @@ -15270,31 +14625,29 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated int32 path = 1 [packed = true]; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, this->mutable_path()))); - } else if (tag == 8) { + } else if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 10, input, this->mutable_path()))); + 1, 10u, input, this->mutable_path()))); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_source_file; break; } // optional string source_file = 2; case 2: { - if (tag == 18) { - parse_source_file: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_source_file())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( @@ -15304,14 +14657,12 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_begin; break; } // optional int32 begin = 3; case 3: { - if (tag == 24) { - parse_begin: + if (tag == 24u) { set_has_begin(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15319,14 +14670,12 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(32)) goto parse_end; break; } // optional int32 end = 4; case 4: { - if (tag == 32) { - parse_end: + if (tag == 32u) { set_has_end(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -15334,7 +14683,6 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -15451,7 +14799,31 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation) size_t total_size = 0; - if (_has_bits_[1 / 32] & 14u) { + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + // repeated int32 path = 1 [packed = true]; + { + size_t data_size = 0; + unsigned int count = this->path_size(); + for (unsigned int i = 0; i < count; i++) { + data_size += ::google::protobuf::internal::WireFormatLite:: + Int32Size(this->path(i)); + } + if (data_size > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _path_cached_byte_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + total_size += data_size; + } + + if (_has_bits_[0 / 32] & 7u) { // optional string source_file = 2; if (has_source_file()) { total_size += 1 + @@ -15474,30 +14846,6 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { } } - // repeated int32 path = 1 [packed = true]; - { - size_t data_size = 0; - unsigned int count = this->path_size(); - for (unsigned int i = 0; i < count; i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->path(i)); - } - if (data_size > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); - } - int cached_size = ::google::protobuf::internal::ToCachedSize(data_size); - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _path_cached_byte_size_ = cached_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - total_size += data_size; - } - - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -15507,7 +14855,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const GeneratedCodeInfo_Annotation* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>( &from); @@ -15516,23 +14864,16 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from) { - GOOGLE_DCHECK(&from != this); - path_.UnsafeMergeFrom(from.path_); - if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) { + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + path_.MergeFrom(from.path_); + if (from._has_bits_[0 / 32] & 7u) { if (from.has_source_file()) { set_has_source_file(); source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_); @@ -15544,10 +14885,6 @@ void GeneratedCodeInfo_Annotation::UnsafeMergeFrom(const GeneratedCodeInfo_Annot set_end(from.end()); } } - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void GeneratedCodeInfo_Annotation::CopyFrom(const ::google::protobuf::Message& from) { @@ -15561,11 +14898,10 @@ void GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool GeneratedCodeInfo_Annotation::IsInitialized() const { - return true; } @@ -15585,14 +14921,147 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot ::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = GeneratedCodeInfo_Annotation_descriptor_; - metadata.reflection = GeneratedCodeInfo_Annotation_reflection_; - return metadata; + return file_level_metadata[23]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// GeneratedCodeInfo_Annotation + +// repeated int32 path = 1 [packed = true]; +int GeneratedCodeInfo_Annotation::path_size() const { + return path_.size(); +} +void GeneratedCodeInfo_Annotation::clear_path() { + path_.Clear(); +} +::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) + return path_.Get(index); +} +void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { + path_.Set(index, value); + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) +} +void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { + path_.Add(value); + // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path) +} +const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& +GeneratedCodeInfo_Annotation::path() const { + // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) + return path_; +} +::google::protobuf::RepeatedField< ::google::protobuf::int32 >* +GeneratedCodeInfo_Annotation::mutable_path() { + // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) + return &path_; +} + +// optional string source_file = 2; +bool GeneratedCodeInfo_Annotation::has_source_file() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_source_file() { + _has_bits_[0] |= 0x00000001u; +} +void GeneratedCodeInfo_Annotation::clear_has_source_file() { + _has_bits_[0] &= ~0x00000001u; +} +void GeneratedCodeInfo_Annotation::clear_source_file() { + source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_source_file(); +} +const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + return source_file_.GetNoArena(); +} +void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { + set_has_source_file(); + source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { + set_has_source_file(); + source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { + set_has_source_file(); + source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { + set_has_source_file(); + // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +::std::string* GeneratedCodeInfo_Annotation::release_source_file() { + // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + clear_has_source_file(); + return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { + if (source_file != NULL) { + set_has_source_file(); + } else { + clear_has_source_file(); + } + source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} + +// optional int32 begin = 3; +bool GeneratedCodeInfo_Annotation::has_begin() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_begin() { + _has_bits_[0] |= 0x00000002u; +} +void GeneratedCodeInfo_Annotation::clear_has_begin() { + _has_bits_[0] &= ~0x00000002u; +} +void GeneratedCodeInfo_Annotation::clear_begin() { + begin_ = 0; + clear_has_begin(); +} +::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) + return begin_; +} +void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { + set_has_begin(); + begin_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) +} + +// optional int32 end = 4; +bool GeneratedCodeInfo_Annotation::has_end() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void GeneratedCodeInfo_Annotation::set_has_end() { + _has_bits_[0] |= 0x00000004u; +} +void GeneratedCodeInfo_Annotation::clear_has_end() { + _has_bits_[0] &= ~0x00000004u; +} +void GeneratedCodeInfo_Annotation::clear_end() { + end_ = 0; + clear_has_end(); +} +::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { + // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) + return end_; +} +void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { + set_has_end(); + end_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) } +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS -// ------------------------------------------------------------------- +// =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int GeneratedCodeInfo::kAnnotationFieldNumber; @@ -15600,19 +15069,19 @@ const int GeneratedCodeInfo::kAnnotationFieldNumber; GeneratedCodeInfo::GeneratedCodeInfo() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo) } - -void GeneratedCodeInfo::InitAsDefaultInstance() { -} - GeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + annotation_(from.annotation_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo) } @@ -15635,7 +15104,7 @@ void GeneratedCodeInfo::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() { protobuf_AssignDescriptorsOnce(); - return GeneratedCodeInfo_descriptor_; + return file_level_metadata[24].descriptor; } const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { @@ -15643,8 +15112,6 @@ const GeneratedCodeInfo& GeneratedCodeInfo::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_; - GeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const { GeneratedCodeInfo* n = new GeneratedCodeInfo; if (arena != NULL) { @@ -15657,9 +15124,7 @@ void GeneratedCodeInfo::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo) annotation_.Clear(); _has_bits_.Clear(); - if (_internal_metadata_.have_unknown_fields()) { - mutable_unknown_fields()->Clear(); - } + _internal_metadata_.Clear(); } bool GeneratedCodeInfo::MergePartialFromCodedStream( @@ -15668,23 +15133,20 @@ bool GeneratedCodeInfo::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_annotation: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_annotation())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_annotation; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -15749,6 +15211,11 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo) size_t total_size = 0; + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; { unsigned int count = this->annotation_size(); @@ -15760,11 +15227,6 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { } } - if (_internal_metadata_.have_unknown_fields()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -15774,7 +15236,7 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const GeneratedCodeInfo* source = ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>( &from); @@ -15783,26 +15245,15 @@ void GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void GeneratedCodeInfo::UnsafeMergeFrom(const GeneratedCodeInfo& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); annotation_.MergeFrom(from.annotation_); - if (from._internal_metadata_.have_unknown_fields()) { - ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata( - from.unknown_fields(), &_internal_metadata_); - } } void GeneratedCodeInfo::CopyFrom(const ::google::protobuf::Message& from) { @@ -15816,11 +15267,10 @@ void GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool GeneratedCodeInfo::IsInitialized() const { - return true; } @@ -15837,152 +15287,10 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { ::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = GeneratedCodeInfo_descriptor_; - metadata.reflection = GeneratedCodeInfo_reflection_; - return metadata; + return file_level_metadata[24]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS -// GeneratedCodeInfo_Annotation - -// repeated int32 path = 1 [packed = true]; -int GeneratedCodeInfo_Annotation::path_size() const { - return path_.size(); -} -void GeneratedCodeInfo_Annotation::clear_path() { - path_.Clear(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path) - return path_.Get(index); -} -void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) { - path_.Set(index, value); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path) -} -void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) { - path_.Add(value); - // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path) -} -const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -GeneratedCodeInfo_Annotation::path() const { - // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return path_; -} -::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -GeneratedCodeInfo_Annotation::mutable_path() { - // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path) - return &path_; -} - -// optional string source_file = 2; -bool GeneratedCodeInfo_Annotation::has_source_file() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_source_file() { - _has_bits_[0] |= 0x00000002u; -} -void GeneratedCodeInfo_Annotation::clear_has_source_file() { - _has_bits_[0] &= ~0x00000002u; -} -void GeneratedCodeInfo_Annotation::clear_source_file() { - source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - clear_has_source_file(); -} -const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -void GeneratedCodeInfo_Annotation::set_source_file(const char* value) { - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); - // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) { - set_has_source_file(); - source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), - ::std::string(reinterpret_cast<const char*>(value), size)); - // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} -::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { - set_has_source_file(); - // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -::std::string* GeneratedCodeInfo_Annotation::release_source_file() { - // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - clear_has_source_file(); - return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); -} -void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) { - if (source_file != NULL) { - set_has_source_file(); - } else { - clear_has_source_file(); - } - source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file) -} - -// optional int32 begin = 3; -bool GeneratedCodeInfo_Annotation::has_begin() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_begin() { - _has_bits_[0] |= 0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_has_begin() { - _has_bits_[0] &= ~0x00000004u; -} -void GeneratedCodeInfo_Annotation::clear_begin() { - begin_ = 0; - clear_has_begin(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin) - return begin_; -} -void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) { - set_has_begin(); - begin_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin) -} - -// optional int32 end = 4; -bool GeneratedCodeInfo_Annotation::has_end() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -void GeneratedCodeInfo_Annotation::set_has_end() { - _has_bits_[0] |= 0x00000008u; -} -void GeneratedCodeInfo_Annotation::clear_has_end() { - _has_bits_[0] &= ~0x00000008u; -} -void GeneratedCodeInfo_Annotation::clear_end() { - end_ = 0; - clear_has_end(); -} -::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const { - // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end) - return end_; -} -void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) { - set_has_end(); - end_ = value; - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) -} - -inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() { - return &GeneratedCodeInfo_Annotation_default_instance_.get(); -} -// ------------------------------------------------------------------- - // GeneratedCodeInfo // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; @@ -16015,9 +15323,6 @@ GeneratedCodeInfo::annotation() const { return annotation_; } -inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { - return &GeneratedCodeInfo_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 257dd0f7..00956cbf 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -24,46 +24,97 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { - -// Internal implementation detail -- do not call these. -void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); -void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - class DescriptorProto; +class DescriptorProtoDefaultTypeInternal; +extern DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; class DescriptorProto_ExtensionRange; +class DescriptorProto_ExtensionRangeDefaultTypeInternal; +extern DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; class DescriptorProto_ReservedRange; +class DescriptorProto_ReservedRangeDefaultTypeInternal; +extern DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; class EnumDescriptorProto; +class EnumDescriptorProtoDefaultTypeInternal; +extern EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; class EnumOptions; +class EnumOptionsDefaultTypeInternal; +extern EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; class EnumValueDescriptorProto; +class EnumValueDescriptorProtoDefaultTypeInternal; +extern EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; class EnumValueOptions; +class EnumValueOptionsDefaultTypeInternal; +extern EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; class FieldDescriptorProto; +class FieldDescriptorProtoDefaultTypeInternal; +extern FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; class FieldOptions; +class FieldOptionsDefaultTypeInternal; +extern FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; class FileDescriptorProto; +class FileDescriptorProtoDefaultTypeInternal; +extern FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; class FileDescriptorSet; +class FileDescriptorSetDefaultTypeInternal; +extern FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; class FileOptions; +class FileOptionsDefaultTypeInternal; +extern FileOptionsDefaultTypeInternal _FileOptions_default_instance_; class GeneratedCodeInfo; +class GeneratedCodeInfoDefaultTypeInternal; +extern GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; class GeneratedCodeInfo_Annotation; +class GeneratedCodeInfo_AnnotationDefaultTypeInternal; +extern GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; class MessageOptions; +class MessageOptionsDefaultTypeInternal; +extern MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; class MethodDescriptorProto; +class MethodDescriptorProtoDefaultTypeInternal; +extern MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; class MethodOptions; +class MethodOptionsDefaultTypeInternal; +extern MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; class OneofDescriptorProto; +class OneofDescriptorProtoDefaultTypeInternal; +extern OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; class OneofOptions; +class OneofOptionsDefaultTypeInternal; +extern OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; class ServiceDescriptorProto; +class ServiceDescriptorProtoDefaultTypeInternal; +extern ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; class ServiceOptions; +class ServiceOptionsDefaultTypeInternal; +extern ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; class SourceCodeInfo; +class SourceCodeInfoDefaultTypeInternal; +extern SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; class SourceCodeInfo_Location; +class SourceCodeInfo_LocationDefaultTypeInternal; +extern SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; class UninterpretedOption; +class UninterpretedOptionDefaultTypeInternal; +extern UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; class UninterpretedOption_NamePart; +class UninterpretedOption_NamePartDefaultTypeInternal; +extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +// Internal implementation detail -- do not call these. +void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); enum FieldDescriptorProto_Type { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, @@ -180,6 +231,26 @@ inline bool FieldOptions_JSType_Parse( return ::google::protobuf::internal::ParseNamedEnum<FieldOptions_JSType>( FieldOptions_JSType_descriptor(), name, value); } +enum MethodOptions_IdempotencyLevel { + MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN = 0, + MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS = 1, + MethodOptions_IdempotencyLevel_IDEMPOTENT = 2 +}; +LIBPROTOBUF_EXPORT bool MethodOptions_IdempotencyLevel_IsValid(int value); +const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN = MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN; +const MethodOptions_IdempotencyLevel MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX = MethodOptions_IdempotencyLevel_IDEMPOTENT; +const int MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE = MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX + 1; + +LIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* MethodOptions_IdempotencyLevel_descriptor(); +inline const ::std::string& MethodOptions_IdempotencyLevel_Name(MethodOptions_IdempotencyLevel value) { + return ::google::protobuf::internal::NameOfEnum( + MethodOptions_IdempotencyLevel_descriptor(), value); +} +inline bool MethodOptions_IdempotencyLevel_Parse( + const ::std::string& name, MethodOptions_IdempotencyLevel* value) { + return ::google::protobuf::internal::ParseNamedEnum<MethodOptions_IdempotencyLevel>( + MethodOptions_IdempotencyLevel_descriptor(), name, value); +} // =================================================================== class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { @@ -205,49 +276,52 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorSet& default_instance(); - static const FileDescriptorSet* internal_default_instance(); + static inline const FileDescriptorSet* internal_default_instance() { + return reinterpret_cast<const FileDescriptorSet*>( + &_FileDescriptorSet_default_instance_); + } void Swap(FileDescriptorSet* other); // implements Message ---------------------------------------------- - inline FileDescriptorSet* New() const { return New(NULL); } + inline FileDescriptorSet* New() const PROTOBUF_FINAL { return New(NULL); } - FileDescriptorSet* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileDescriptorSet* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorSet& from); void MergeFrom(const FileDescriptorSet& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorSet* other); - void UnsafeMergeFrom(const FileDescriptorSet& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -274,13 +348,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorSet> FileDescriptorSet_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { @@ -306,49 +377,52 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const FileDescriptorProto& default_instance(); - static const FileDescriptorProto* internal_default_instance(); + static inline const FileDescriptorProto* internal_default_instance() { + return reinterpret_cast<const FileDescriptorProto*>( + &_FileDescriptorProto_default_instance_); + } void Swap(FileDescriptorProto* other); // implements Message ---------------------------------------------- - inline FileDescriptorProto* New() const { return New(NULL); } + inline FileDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - FileDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileDescriptorProto& from); void MergeFrom(const FileDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileDescriptorProto* other); - void UnsafeMergeFrom(const FileDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -498,16 +572,16 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_package(); - inline void clear_has_package(); - inline void set_has_options(); - inline void clear_has_options(); - inline void set_has_source_code_info(); - inline void clear_has_source_code_info(); - inline void set_has_syntax(); - inline void clear_has_syntax(); + void set_has_name(); + void clear_has_name(); + void set_has_package(); + void clear_has_package(); + void set_has_options(); + void clear_has_options(); + void set_has_source_code_info(); + void clear_has_source_code_info(); + void set_has_syntax(); + void clear_has_syntax(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -526,13 +600,10 @@ class LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::SourceCodeInfo* source_code_info_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileDescriptorProto> FileDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { @@ -558,49 +629,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ExtensionRange& default_instance(); - static const DescriptorProto_ExtensionRange* internal_default_instance(); + static inline const DescriptorProto_ExtensionRange* internal_default_instance() { + return reinterpret_cast<const DescriptorProto_ExtensionRange*>( + &_DescriptorProto_ExtensionRange_default_instance_); + } void Swap(DescriptorProto_ExtensionRange* other); // implements Message ---------------------------------------------- - inline DescriptorProto_ExtensionRange* New() const { return New(NULL); } + inline DescriptorProto_ExtensionRange* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ExtensionRange& from); void MergeFrom(const DescriptorProto_ExtensionRange& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ExtensionRange* other); - void UnsafeMergeFrom(const DescriptorProto_ExtensionRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -622,10 +696,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange) private: - inline void set_has_start(); - inline void clear_has_start(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_start(); + void clear_has_start(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -634,13 +708,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::proto ::google::protobuf::int32 end_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ExtensionRange> DescriptorProto_ExtensionRange_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { @@ -666,49 +737,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto_ReservedRange& default_instance(); - static const DescriptorProto_ReservedRange* internal_default_instance(); + static inline const DescriptorProto_ReservedRange* internal_default_instance() { + return reinterpret_cast<const DescriptorProto_ReservedRange*>( + &_DescriptorProto_ReservedRange_default_instance_); + } void Swap(DescriptorProto_ReservedRange* other); // implements Message ---------------------------------------------- - inline DescriptorProto_ReservedRange* New() const { return New(NULL); } + inline DescriptorProto_ReservedRange* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto_ReservedRange& from); void MergeFrom(const DescriptorProto_ReservedRange& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto_ReservedRange* other); - void UnsafeMergeFrom(const DescriptorProto_ReservedRange& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -730,10 +804,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange) private: - inline void set_has_start(); - inline void clear_has_start(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_start(); + void clear_has_start(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -742,13 +816,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protob ::google::protobuf::int32 end_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto_ReservedRange> DescriptorProto_ReservedRange_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { @@ -774,49 +845,52 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const DescriptorProto& default_instance(); - static const DescriptorProto* internal_default_instance(); + static inline const DescriptorProto* internal_default_instance() { + return reinterpret_cast<const DescriptorProto*>( + &_DescriptorProto_default_instance_); + } void Swap(DescriptorProto* other); // implements Message ---------------------------------------------- - inline DescriptorProto* New() const { return New(NULL); } + inline DescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - DescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DescriptorProto& from); void MergeFrom(const DescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DescriptorProto* other); - void UnsafeMergeFrom(const DescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -948,10 +1022,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -968,13 +1042,10 @@ class LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* ::google::protobuf::MessageOptions* options_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DescriptorProto> DescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { @@ -1000,49 +1071,52 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const FieldDescriptorProto& default_instance(); - static const FieldDescriptorProto* internal_default_instance(); + static inline const FieldDescriptorProto* internal_default_instance() { + return reinterpret_cast<const FieldDescriptorProto*>( + &_FieldDescriptorProto_default_instance_); + } void Swap(FieldDescriptorProto* other); // implements Message ---------------------------------------------- - inline FieldDescriptorProto* New() const { return New(NULL); } + inline FieldDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - FieldDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldDescriptorProto& from); void MergeFrom(const FieldDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldDescriptorProto* other); - void UnsafeMergeFrom(const FieldDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1233,26 +1307,26 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa // @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_label(); - inline void clear_has_label(); - inline void set_has_type(); - inline void clear_has_type(); - inline void set_has_type_name(); - inline void clear_has_type_name(); - inline void set_has_extendee(); - inline void clear_has_extendee(); - inline void set_has_default_value(); - inline void clear_has_default_value(); - inline void set_has_oneof_index(); - inline void clear_has_oneof_index(); - inline void set_has_json_name(); - inline void clear_has_json_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_number(); + void clear_has_number(); + void set_has_label(); + void clear_has_label(); + void set_has_type(); + void clear_has_type(); + void set_has_type_name(); + void clear_has_type_name(); + void set_has_extendee(); + void clear_has_extendee(); + void set_has_default_value(); + void clear_has_default_value(); + void set_has_oneof_index(); + void clear_has_oneof_index(); + void set_has_json_name(); + void clear_has_json_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1269,13 +1343,10 @@ class LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Messa int type_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldDescriptorProto> FieldDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { @@ -1301,49 +1372,52 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa static const ::google::protobuf::Descriptor* descriptor(); static const OneofDescriptorProto& default_instance(); - static const OneofDescriptorProto* internal_default_instance(); + static inline const OneofDescriptorProto* internal_default_instance() { + return reinterpret_cast<const OneofDescriptorProto*>( + &_OneofDescriptorProto_default_instance_); + } void Swap(OneofDescriptorProto* other); // implements Message ---------------------------------------------- - inline OneofDescriptorProto* New() const { return New(NULL); } + inline OneofDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - OneofDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + OneofDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofDescriptorProto& from); void MergeFrom(const OneofDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofDescriptorProto* other); - void UnsafeMergeFrom(const OneofDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1372,10 +1446,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa // @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1384,13 +1458,10 @@ class LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Messa ::google::protobuf::OneofOptions* options_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<OneofDescriptorProto> OneofDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { @@ -1416,49 +1487,52 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const EnumDescriptorProto& default_instance(); - static const EnumDescriptorProto* internal_default_instance(); + static inline const EnumDescriptorProto* internal_default_instance() { + return reinterpret_cast<const EnumDescriptorProto*>( + &_EnumDescriptorProto_default_instance_); + } void Swap(EnumDescriptorProto* other); // implements Message ---------------------------------------------- - inline EnumDescriptorProto* New() const { return New(NULL); } + inline EnumDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - EnumDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumDescriptorProto& from); void MergeFrom(const EnumDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumDescriptorProto* other); - void UnsafeMergeFrom(const EnumDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1499,10 +1573,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1512,13 +1586,10 @@ class LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Messag ::google::protobuf::EnumOptions* options_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumDescriptorProto> EnumDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { @@ -1544,49 +1615,52 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueDescriptorProto& default_instance(); - static const EnumValueDescriptorProto* internal_default_instance(); + static inline const EnumValueDescriptorProto* internal_default_instance() { + return reinterpret_cast<const EnumValueDescriptorProto*>( + &_EnumValueDescriptorProto_default_instance_); + } void Swap(EnumValueDescriptorProto* other); // implements Message ---------------------------------------------- - inline EnumValueDescriptorProto* New() const { return New(NULL); } + inline EnumValueDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueDescriptorProto& from); void MergeFrom(const EnumValueDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueDescriptorProto* other); - void UnsafeMergeFrom(const EnumValueDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1622,12 +1696,12 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_number(); - inline void clear_has_number(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_number(); + void clear_has_number(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1637,13 +1711,10 @@ class LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::M ::google::protobuf::int32 number_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueDescriptorProto> EnumValueDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { @@ -1669,49 +1740,52 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes static const ::google::protobuf::Descriptor* descriptor(); static const ServiceDescriptorProto& default_instance(); - static const ServiceDescriptorProto* internal_default_instance(); + static inline const ServiceDescriptorProto* internal_default_instance() { + return reinterpret_cast<const ServiceDescriptorProto*>( + &_ServiceDescriptorProto_default_instance_); + } void Swap(ServiceDescriptorProto* other); // implements Message ---------------------------------------------- - inline ServiceDescriptorProto* New() const { return New(NULL); } + inline ServiceDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceDescriptorProto& from); void MergeFrom(const ServiceDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceDescriptorProto* other); - void UnsafeMergeFrom(const ServiceDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1752,10 +1826,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_options(); - inline void clear_has_options(); + void set_has_name(); + void clear_has_name(); + void set_has_options(); + void clear_has_options(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1765,13 +1839,10 @@ class LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Mes ::google::protobuf::ServiceOptions* options_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceDescriptorProto> ServiceDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { @@ -1797,49 +1868,52 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess static const ::google::protobuf::Descriptor* descriptor(); static const MethodDescriptorProto& default_instance(); - static const MethodDescriptorProto* internal_default_instance(); + static inline const MethodDescriptorProto* internal_default_instance() { + return reinterpret_cast<const MethodDescriptorProto*>( + &_MethodDescriptorProto_default_instance_); + } void Swap(MethodDescriptorProto* other); // implements Message ---------------------------------------------- - inline MethodDescriptorProto* New() const { return New(NULL); } + inline MethodDescriptorProto* New() const PROTOBUF_FINAL { return New(NULL); } - MethodDescriptorProto* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MethodDescriptorProto* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodDescriptorProto& from); void MergeFrom(const MethodDescriptorProto& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodDescriptorProto* other); - void UnsafeMergeFrom(const MethodDescriptorProto& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -1906,18 +1980,18 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess // @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto) private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_input_type(); - inline void clear_has_input_type(); - inline void set_has_output_type(); - inline void clear_has_output_type(); - inline void set_has_options(); - inline void clear_has_options(); - inline void set_has_client_streaming(); - inline void clear_has_client_streaming(); - inline void set_has_server_streaming(); - inline void clear_has_server_streaming(); + void set_has_name(); + void clear_has_name(); + void set_has_input_type(); + void clear_has_input_type(); + void set_has_output_type(); + void clear_has_output_type(); + void set_has_options(); + void clear_has_options(); + void set_has_client_streaming(); + void clear_has_client_streaming(); + void set_has_server_streaming(); + void clear_has_server_streaming(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -1930,13 +2004,10 @@ class LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Mess bool server_streaming_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MethodDescriptorProto> MethodDescriptorProto_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { @@ -1962,49 +2033,52 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const FileOptions& default_instance(); - static const FileOptions* internal_default_instance(); + static inline const FileOptions* internal_default_instance() { + return reinterpret_cast<const FileOptions*>( + &_FileOptions_default_instance_); + } void Swap(FileOptions* other); // implements Message ---------------------------------------------- - inline FileOptions* New() const { return New(NULL); } + inline FileOptions* New() const PROTOBUF_FINAL { return New(NULL); } - FileOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FileOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FileOptions& from); void MergeFrom(const FileOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FileOptions* other); - void UnsafeMergeFrom(const FileOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2161,6 +2235,18 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::std::string* release_csharp_namespace(); void set_allocated_csharp_namespace(::std::string* csharp_namespace); + // optional string swift_prefix = 39; + bool has_swift_prefix() const; + void clear_swift_prefix(); + static const int kSwiftPrefixFieldNumber = 39; + const ::std::string& swift_prefix() const; + void set_swift_prefix(const ::std::string& value); + void set_swift_prefix(const char* value); + void set_swift_prefix(const char* value, size_t size); + ::std::string* mutable_swift_prefix(); + ::std::string* release_swift_prefix(); + void set_allocated_swift_prefix(::std::string* swift_prefix); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -2176,34 +2262,36 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions) private: - inline void set_has_java_package(); - inline void clear_has_java_package(); - inline void set_has_java_outer_classname(); - inline void clear_has_java_outer_classname(); - inline void set_has_java_multiple_files(); - inline void clear_has_java_multiple_files(); - inline void set_has_java_generate_equals_and_hash(); - inline void clear_has_java_generate_equals_and_hash(); - inline void set_has_java_string_check_utf8(); - inline void clear_has_java_string_check_utf8(); - inline void set_has_optimize_for(); - inline void clear_has_optimize_for(); - inline void set_has_go_package(); - inline void clear_has_go_package(); - inline void set_has_cc_generic_services(); - inline void clear_has_cc_generic_services(); - inline void set_has_java_generic_services(); - inline void clear_has_java_generic_services(); - inline void set_has_py_generic_services(); - inline void clear_has_py_generic_services(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_cc_enable_arenas(); - inline void clear_has_cc_enable_arenas(); - inline void set_has_objc_class_prefix(); - inline void clear_has_objc_class_prefix(); - inline void set_has_csharp_namespace(); - inline void clear_has_csharp_namespace(); + void set_has_java_package(); + void clear_has_java_package(); + void set_has_java_outer_classname(); + void clear_has_java_outer_classname(); + void set_has_java_multiple_files(); + void clear_has_java_multiple_files(); + void set_has_java_generate_equals_and_hash(); + void clear_has_java_generate_equals_and_hash(); + void set_has_java_string_check_utf8(); + void clear_has_java_string_check_utf8(); + void set_has_optimize_for(); + void clear_has_optimize_for(); + void set_has_go_package(); + void clear_has_go_package(); + void set_has_cc_generic_services(); + void clear_has_cc_generic_services(); + void set_has_java_generic_services(); + void clear_has_java_generic_services(); + void set_has_py_generic_services(); + void clear_has_py_generic_services(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_cc_enable_arenas(); + void clear_has_cc_enable_arenas(); + void set_has_objc_class_prefix(); + void clear_has_objc_class_prefix(); + void set_has_csharp_namespace(); + void clear_has_csharp_namespace(); + void set_has_swift_prefix(); + void clear_has_swift_prefix(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2216,6 +2304,7 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p ::google::protobuf::internal::ArenaStringPtr go_package_; ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_; ::google::protobuf::internal::ArenaStringPtr csharp_namespace_; + ::google::protobuf::internal::ArenaStringPtr swift_prefix_; bool java_multiple_files_; bool java_generate_equals_and_hash_; bool java_string_check_utf8_; @@ -2227,13 +2316,10 @@ class LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@p int optimize_for_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FileOptions> FileOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { @@ -2259,49 +2345,52 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const MessageOptions& default_instance(); - static const MessageOptions* internal_default_instance(); + static inline const MessageOptions* internal_default_instance() { + return reinterpret_cast<const MessageOptions*>( + &_MessageOptions_default_instance_); + } void Swap(MessageOptions* other); // implements Message ---------------------------------------------- - inline MessageOptions* New() const { return New(NULL); } + inline MessageOptions* New() const PROTOBUF_FINAL { return New(NULL); } - MessageOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MessageOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MessageOptions& from); void MergeFrom(const MessageOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MessageOptions* other); - void UnsafeMergeFrom(const MessageOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2350,14 +2439,14 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions) private: - inline void set_has_message_set_wire_format(); - inline void clear_has_message_set_wire_format(); - inline void set_has_no_standard_descriptor_accessor(); - inline void clear_has_no_standard_descriptor_accessor(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_map_entry(); - inline void clear_has_map_entry(); + void set_has_message_set_wire_format(); + void clear_has_message_set_wire_format(); + void set_has_no_standard_descriptor_accessor(); + void clear_has_no_standard_descriptor_accessor(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_map_entry(); + void clear_has_map_entry(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2371,13 +2460,10 @@ class LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* bool map_entry_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MessageOptions> MessageOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { @@ -2403,49 +2489,52 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const FieldOptions& default_instance(); - static const FieldOptions* internal_default_instance(); + static inline const FieldOptions* internal_default_instance() { + return reinterpret_cast<const FieldOptions*>( + &_FieldOptions_default_instance_); + } void Swap(FieldOptions* other); // implements Message ---------------------------------------------- - inline FieldOptions* New() const { return New(NULL); } + inline FieldOptions* New() const PROTOBUF_FINAL { return New(NULL); } - FieldOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldOptions& from); void MergeFrom(const FieldOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldOptions* other); - void UnsafeMergeFrom(const FieldOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2564,18 +2653,18 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions) // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions) private: - inline void set_has_ctype(); - inline void clear_has_ctype(); - inline void set_has_packed(); - inline void clear_has_packed(); - inline void set_has_jstype(); - inline void clear_has_jstype(); - inline void set_has_lazy(); - inline void clear_has_lazy(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); - inline void set_has_weak(); - inline void clear_has_weak(); + void set_has_ctype(); + void clear_has_ctype(); + void set_has_packed(); + void clear_has_packed(); + void set_has_jstype(); + void clear_has_jstype(); + void set_has_lazy(); + void clear_has_lazy(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_weak(); + void clear_has_weak(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2591,13 +2680,10 @@ class LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@ bool weak_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldOptions> FieldOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { @@ -2623,49 +2709,52 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ static const ::google::protobuf::Descriptor* descriptor(); static const OneofOptions& default_instance(); - static const OneofOptions* internal_default_instance(); + static inline const OneofOptions* internal_default_instance() { + return reinterpret_cast<const OneofOptions*>( + &_OneofOptions_default_instance_); + } void Swap(OneofOptions* other); // implements Message ---------------------------------------------- - inline OneofOptions* New() const { return New(NULL); } + inline OneofOptions* New() const PROTOBUF_FINAL { return New(NULL); } - OneofOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + OneofOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofOptions& from); void MergeFrom(const OneofOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofOptions* other); - void UnsafeMergeFrom(const OneofOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2695,13 +2784,10 @@ class LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@ ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<OneofOptions> OneofOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { @@ -2727,49 +2813,52 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p static const ::google::protobuf::Descriptor* descriptor(); static const EnumOptions& default_instance(); - static const EnumOptions* internal_default_instance(); + static inline const EnumOptions* internal_default_instance() { + return reinterpret_cast<const EnumOptions*>( + &_EnumOptions_default_instance_); + } void Swap(EnumOptions* other); // implements Message ---------------------------------------------- - inline EnumOptions* New() const { return New(NULL); } + inline EnumOptions* New() const PROTOBUF_FINAL { return New(NULL); } - EnumOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumOptions& from); void MergeFrom(const EnumOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumOptions* other); - void UnsafeMergeFrom(const EnumOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2804,10 +2893,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions) private: - inline void set_has_allow_alias(); - inline void clear_has_allow_alias(); - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_allow_alias(); + void clear_has_allow_alias(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2819,13 +2908,10 @@ class LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@p bool deprecated_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumOptions> EnumOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { @@ -2851,49 +2937,52 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / static const ::google::protobuf::Descriptor* descriptor(); static const EnumValueOptions& default_instance(); - static const EnumValueOptions* internal_default_instance(); + static inline const EnumValueOptions* internal_default_instance() { + return reinterpret_cast<const EnumValueOptions*>( + &_EnumValueOptions_default_instance_); + } void Swap(EnumValueOptions* other); // implements Message ---------------------------------------------- - inline EnumValueOptions* New() const { return New(NULL); } + inline EnumValueOptions* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValueOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValueOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValueOptions& from); void MergeFrom(const EnumValueOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValueOptions* other); - void UnsafeMergeFrom(const EnumValueOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -2921,8 +3010,8 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions) // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -2933,13 +3022,10 @@ class LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message / bool deprecated_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValueOptions> EnumValueOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { @@ -2965,49 +3051,52 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const ServiceOptions& default_instance(); - static const ServiceOptions* internal_default_instance(); + static inline const ServiceOptions* internal_default_instance() { + return reinterpret_cast<const ServiceOptions*>( + &_ServiceOptions_default_instance_); + } void Swap(ServiceOptions* other); // implements Message ---------------------------------------------- - inline ServiceOptions* New() const { return New(NULL); } + inline ServiceOptions* New() const PROTOBUF_FINAL { return New(NULL); } - ServiceOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ServiceOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ServiceOptions& from); void MergeFrom(const ServiceOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ServiceOptions* other); - void UnsafeMergeFrom(const ServiceOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3035,8 +3124,8 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions) // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -3047,13 +3136,10 @@ class LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* bool deprecated_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ServiceOptions> ServiceOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { @@ -3079,52 +3165,83 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const MethodOptions& default_instance(); - static const MethodOptions* internal_default_instance(); + static inline const MethodOptions* internal_default_instance() { + return reinterpret_cast<const MethodOptions*>( + &_MethodOptions_default_instance_); + } void Swap(MethodOptions* other); // implements Message ---------------------------------------------- - inline MethodOptions* New() const { return New(NULL); } + inline MethodOptions* New() const PROTOBUF_FINAL { return New(NULL); } - MethodOptions* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + MethodOptions* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MethodOptions& from); void MergeFrom(const MethodOptions& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MethodOptions* other); - void UnsafeMergeFrom(const MethodOptions& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- + typedef MethodOptions_IdempotencyLevel IdempotencyLevel; + static const IdempotencyLevel IDEMPOTENCY_UNKNOWN = + MethodOptions_IdempotencyLevel_IDEMPOTENCY_UNKNOWN; + static const IdempotencyLevel NO_SIDE_EFFECTS = + MethodOptions_IdempotencyLevel_NO_SIDE_EFFECTS; + static const IdempotencyLevel IDEMPOTENT = + MethodOptions_IdempotencyLevel_IDEMPOTENT; + static inline bool IdempotencyLevel_IsValid(int value) { + return MethodOptions_IdempotencyLevel_IsValid(value); + } + static const IdempotencyLevel IdempotencyLevel_MIN = + MethodOptions_IdempotencyLevel_IdempotencyLevel_MIN; + static const IdempotencyLevel IdempotencyLevel_MAX = + MethodOptions_IdempotencyLevel_IdempotencyLevel_MAX; + static const int IdempotencyLevel_ARRAYSIZE = + MethodOptions_IdempotencyLevel_IdempotencyLevel_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + IdempotencyLevel_descriptor() { + return MethodOptions_IdempotencyLevel_descriptor(); + } + static inline const ::std::string& IdempotencyLevel_Name(IdempotencyLevel value) { + return MethodOptions_IdempotencyLevel_Name(value); + } + static inline bool IdempotencyLevel_Parse(const ::std::string& name, + IdempotencyLevel* value) { + return MethodOptions_IdempotencyLevel_Parse(name, value); + } + // accessors ------------------------------------------------------- // optional bool deprecated = 33 [default = false]; @@ -3134,6 +3251,13 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ bool deprecated() const; void set_deprecated(bool value); + // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; + bool has_idempotency_level() const; + void clear_idempotency_level(); + static const int kIdempotencyLevelFieldNumber = 34; + ::google::protobuf::MethodOptions_IdempotencyLevel idempotency_level() const; + void set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value); + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; int uninterpreted_option_size() const; void clear_uninterpreted_option(); @@ -3149,8 +3273,10 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions) // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions) private: - inline void set_has_deprecated(); - inline void clear_has_deprecated(); + void set_has_deprecated(); + void clear_has_deprecated(); + void set_has_idempotency_level(); + void clear_has_idempotency_level(); ::google::protobuf::internal::ExtensionSet _extensions_; @@ -3159,15 +3285,13 @@ class LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @ mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_; bool deprecated_; + int idempotency_level_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<MethodOptions> MethodOptions_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { @@ -3193,49 +3317,52 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption_NamePart& default_instance(); - static const UninterpretedOption_NamePart* internal_default_instance(); + static inline const UninterpretedOption_NamePart* internal_default_instance() { + return reinterpret_cast<const UninterpretedOption_NamePart*>( + &_UninterpretedOption_NamePart_default_instance_); + } void Swap(UninterpretedOption_NamePart* other); // implements Message ---------------------------------------------- - inline UninterpretedOption_NamePart* New() const { return New(NULL); } + inline UninterpretedOption_NamePart* New() const PROTOBUF_FINAL { return New(NULL); } - UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption_NamePart& from); void MergeFrom(const UninterpretedOption_NamePart& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption_NamePart* other); - void UnsafeMergeFrom(const UninterpretedOption_NamePart& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3262,10 +3389,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart) private: - inline void set_has_name_part(); - inline void clear_has_name_part(); - inline void set_has_is_extension(); - inline void clear_has_is_extension(); + void set_has_name_part(); + void clear_has_name_part(); + void set_has_is_extension(); + void clear_has_is_extension(); // helper for ByteSizeLong() size_t RequiredFieldsByteSizeFallback() const; @@ -3277,13 +3404,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobu bool is_extension_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption_NamePart> UninterpretedOption_NamePart_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { @@ -3309,49 +3433,52 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag static const ::google::protobuf::Descriptor* descriptor(); static const UninterpretedOption& default_instance(); - static const UninterpretedOption* internal_default_instance(); + static inline const UninterpretedOption* internal_default_instance() { + return reinterpret_cast<const UninterpretedOption*>( + &_UninterpretedOption_default_instance_); + } void Swap(UninterpretedOption* other); // implements Message ---------------------------------------------- - inline UninterpretedOption* New() const { return New(NULL); } + inline UninterpretedOption* New() const PROTOBUF_FINAL { return New(NULL); } - UninterpretedOption* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UninterpretedOption* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UninterpretedOption& from); void MergeFrom(const UninterpretedOption& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UninterpretedOption* other); - void UnsafeMergeFrom(const UninterpretedOption& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3430,18 +3557,18 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption) private: - inline void set_has_identifier_value(); - inline void clear_has_identifier_value(); - inline void set_has_positive_int_value(); - inline void clear_has_positive_int_value(); - inline void set_has_negative_int_value(); - inline void clear_has_negative_int_value(); - inline void set_has_double_value(); - inline void clear_has_double_value(); - inline void set_has_string_value(); - inline void clear_has_string_value(); - inline void set_has_aggregate_value(); - inline void clear_has_aggregate_value(); + void set_has_identifier_value(); + void clear_has_identifier_value(); + void set_has_positive_int_value(); + void clear_has_positive_int_value(); + void set_has_negative_int_value(); + void clear_has_negative_int_value(); + void set_has_double_value(); + void clear_has_double_value(); + void set_has_string_value(); + void clear_has_string_value(); + void set_has_aggregate_value(); + void clear_has_aggregate_value(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3455,13 +3582,10 @@ class LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Messag double double_value_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UninterpretedOption> UninterpretedOption_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { @@ -3487,49 +3611,52 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo_Location& default_instance(); - static const SourceCodeInfo_Location* internal_default_instance(); + static inline const SourceCodeInfo_Location* internal_default_instance() { + return reinterpret_cast<const SourceCodeInfo_Location*>( + &_SourceCodeInfo_Location_default_instance_); + } void Swap(SourceCodeInfo_Location* other); // implements Message ---------------------------------------------- - inline SourceCodeInfo_Location* New() const { return New(NULL); } + inline SourceCodeInfo_Location* New() const PROTOBUF_FINAL { return New(NULL); } - SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo_Location& from); void MergeFrom(const SourceCodeInfo_Location& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo_Location* other); - void UnsafeMergeFrom(const SourceCodeInfo_Location& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3601,10 +3728,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) private: - inline void set_has_leading_comments(); - inline void clear_has_leading_comments(); - inline void set_has_trailing_comments(); - inline void clear_has_trailing_comments(); + void set_has_leading_comments(); + void clear_has_leading_comments(); + void set_has_trailing_comments(); + void clear_has_trailing_comments(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3618,13 +3745,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Me ::google::protobuf::internal::ArenaStringPtr trailing_comments_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo_Location> SourceCodeInfo_Location_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { @@ -3650,49 +3774,52 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* static const ::google::protobuf::Descriptor* descriptor(); static const SourceCodeInfo& default_instance(); - static const SourceCodeInfo* internal_default_instance(); + static inline const SourceCodeInfo* internal_default_instance() { + return reinterpret_cast<const SourceCodeInfo*>( + &_SourceCodeInfo_default_instance_); + } void Swap(SourceCodeInfo* other); // implements Message ---------------------------------------------- - inline SourceCodeInfo* New() const { return New(NULL); } + inline SourceCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } - SourceCodeInfo* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceCodeInfo& from); void MergeFrom(const SourceCodeInfo& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceCodeInfo* other); - void UnsafeMergeFrom(const SourceCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3721,13 +3848,10 @@ class LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceCodeInfo> SourceCodeInfo_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { @@ -3753,49 +3877,52 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo_Annotation& default_instance(); - static const GeneratedCodeInfo_Annotation* internal_default_instance(); + static inline const GeneratedCodeInfo_Annotation* internal_default_instance() { + return reinterpret_cast<const GeneratedCodeInfo_Annotation*>( + &_GeneratedCodeInfo_Annotation_default_instance_); + } void Swap(GeneratedCodeInfo_Annotation* other); // implements Message ---------------------------------------------- - inline GeneratedCodeInfo_Annotation* New() const { return New(NULL); } + inline GeneratedCodeInfo_Annotation* New() const PROTOBUF_FINAL { return New(NULL); } - GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo_Annotation& from); void MergeFrom(const GeneratedCodeInfo_Annotation& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo_Annotation* other); - void UnsafeMergeFrom(const GeneratedCodeInfo_Annotation& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3841,12 +3968,12 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation) private: - inline void set_has_source_file(); - inline void clear_has_source_file(); - inline void set_has_begin(); - inline void clear_has_begin(); - inline void set_has_end(); - inline void clear_has_end(); + void set_has_source_file(); + void clear_has_source_file(); + void set_has_begin(); + void clear_has_begin(); + void set_has_end(); + void clear_has_end(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::internal::HasBits<1> _has_bits_; @@ -3858,13 +3985,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobu ::google::protobuf::int32 end_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo_Annotation> GeneratedCodeInfo_Annotation_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { @@ -3890,49 +4014,52 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message static const ::google::protobuf::Descriptor* descriptor(); static const GeneratedCodeInfo& default_instance(); - static const GeneratedCodeInfo* internal_default_instance(); + static inline const GeneratedCodeInfo* internal_default_instance() { + return reinterpret_cast<const GeneratedCodeInfo*>( + &_GeneratedCodeInfo_default_instance_); + } void Swap(GeneratedCodeInfo* other); // implements Message ---------------------------------------------- - inline GeneratedCodeInfo* New() const { return New(NULL); } + inline GeneratedCodeInfo* New() const PROTOBUF_FINAL { return New(NULL); } - GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const GeneratedCodeInfo& from); void MergeFrom(const GeneratedCodeInfo& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(GeneratedCodeInfo* other); - void UnsafeMergeFrom(const GeneratedCodeInfo& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -3961,13 +4088,10 @@ class LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fdescriptor_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<GeneratedCodeInfo> GeneratedCodeInfo_default_instance_; - // =================================================================== @@ -4006,9 +4130,6 @@ FileDescriptorSet::file() const { return file_; } -inline const FileDescriptorSet* FileDescriptorSet::internal_default_instance() { - return &FileDescriptorSet_default_instance_.get(); -} // ------------------------------------------------------------------- // FileDescriptorProto @@ -4029,7 +4150,7 @@ inline void FileDescriptorProto::clear_name() { } inline const ::std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void FileDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4083,7 +4204,7 @@ inline void FileDescriptorProto::clear_package() { } inline const ::std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return package_.GetNoArena(); } inline void FileDescriptorProto::set_package(const ::std::string& value) { set_has_package(); @@ -4358,13 +4479,13 @@ FileDescriptorProto::extension() const { // optional .google.protobuf.FileOptions options = 8; inline bool FileDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FileDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000008u; } inline void FileDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000008u; } inline void FileDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); @@ -4403,13 +4524,13 @@ inline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileO // optional .google.protobuf.SourceCodeInfo source_code_info = 9; inline bool FileDescriptorProto::has_source_code_info() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FileDescriptorProto::set_has_source_code_info() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00000010u; } inline void FileDescriptorProto::clear_has_source_code_info() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00000010u; } inline void FileDescriptorProto::clear_source_code_info() { if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear(); @@ -4448,13 +4569,13 @@ inline void FileDescriptorProto::set_allocated_source_code_info(::google::protob // optional string syntax = 12; inline bool FileDescriptorProto::has_syntax() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FileDescriptorProto::set_has_syntax() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00000004u; } inline void FileDescriptorProto::clear_has_syntax() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00000004u; } inline void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -4462,7 +4583,7 @@ inline void FileDescriptorProto::clear_syntax() { } inline const ::std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return syntax_.GetNoArena(); } inline void FileDescriptorProto::set_syntax(const ::std::string& value) { set_has_syntax(); @@ -4500,9 +4621,6 @@ inline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax) } -inline const FileDescriptorProto* FileDescriptorProto::internal_default_instance() { - return &FileDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto_ExtensionRange @@ -4555,9 +4673,6 @@ inline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 va // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end) } -inline const DescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::internal_default_instance() { - return &DescriptorProto_ExtensionRange_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto_ReservedRange @@ -4610,9 +4725,6 @@ inline void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 val // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end) } -inline const DescriptorProto_ReservedRange* DescriptorProto_ReservedRange::internal_default_instance() { - return &DescriptorProto_ReservedRange_default_instance_.get(); -} // ------------------------------------------------------------------- // DescriptorProto @@ -4633,7 +4745,7 @@ inline void DescriptorProto::clear_name() { } inline const ::std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void DescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -4853,13 +4965,13 @@ DescriptorProto::oneof_decl() const { // optional .google.protobuf.MessageOptions options = 7; inline bool DescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void DescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000002u; } inline void DescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000002u; } inline void DescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear(); @@ -4981,9 +5093,6 @@ DescriptorProto::mutable_reserved_name() { return &reserved_name_; } -inline const DescriptorProto* DescriptorProto::internal_default_instance() { - return &DescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldDescriptorProto @@ -5004,7 +5113,7 @@ inline void FieldDescriptorProto::clear_name() { } inline const ::std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void FieldDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5044,13 +5153,13 @@ inline void FieldDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 3; inline bool FieldDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FieldDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000040u; } inline void FieldDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000040u; } inline void FieldDescriptorProto::clear_number() { number_ = 0; @@ -5068,13 +5177,13 @@ inline void FieldDescriptorProto::set_number(::google::protobuf::int32 value) { // optional .google.protobuf.FieldDescriptorProto.Label label = 4; inline bool FieldDescriptorProto::has_label() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FieldDescriptorProto::set_has_label() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000100u; } inline void FieldDescriptorProto::clear_has_label() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000100u; } inline void FieldDescriptorProto::clear_label() { label_ = 1; @@ -5093,13 +5202,13 @@ inline void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorP // optional .google.protobuf.FieldDescriptorProto.Type type = 5; inline bool FieldDescriptorProto::has_type() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FieldDescriptorProto::set_has_type() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000200u; } inline void FieldDescriptorProto::clear_has_type() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000200u; } inline void FieldDescriptorProto::clear_type() { type_ = 1; @@ -5118,13 +5227,13 @@ inline void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorPr // optional string type_name = 6; inline bool FieldDescriptorProto::has_type_name() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void FieldDescriptorProto::set_has_type_name() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000002u; } inline void FieldDescriptorProto::clear_has_type_name() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000002u; } inline void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5132,7 +5241,7 @@ inline void FieldDescriptorProto::clear_type_name() { } inline const ::std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) - return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_name_.GetNoArena(); } inline void FieldDescriptorProto::set_type_name(const ::std::string& value) { set_has_type_name(); @@ -5172,13 +5281,13 @@ inline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_na // optional string extendee = 2; inline bool FieldDescriptorProto::has_extendee() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FieldDescriptorProto::set_has_extendee() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000004u; } inline void FieldDescriptorProto::clear_has_extendee() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000004u; } inline void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5186,7 +5295,7 @@ inline void FieldDescriptorProto::clear_extendee() { } inline const ::std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return extendee_.GetNoArena(); } inline void FieldDescriptorProto::set_extendee(const ::std::string& value) { set_has_extendee(); @@ -5226,13 +5335,13 @@ inline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee // optional string default_value = 7; inline bool FieldDescriptorProto::has_default_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FieldDescriptorProto::set_has_default_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000008u; } inline void FieldDescriptorProto::clear_has_default_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000008u; } inline void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5240,7 +5349,7 @@ inline void FieldDescriptorProto::clear_default_value() { } inline const ::std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) - return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.GetNoArena(); } inline void FieldDescriptorProto::set_default_value(const ::std::string& value) { set_has_default_value(); @@ -5304,13 +5413,13 @@ inline void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 valu // optional string json_name = 10; inline bool FieldDescriptorProto::has_json_name() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FieldDescriptorProto::set_has_json_name() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000010u; } inline void FieldDescriptorProto::clear_has_json_name() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000010u; } inline void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -5318,7 +5427,7 @@ inline void FieldDescriptorProto::clear_json_name() { } inline const ::std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) - return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.GetNoArena(); } inline void FieldDescriptorProto::set_json_name(const ::std::string& value) { set_has_json_name(); @@ -5358,13 +5467,13 @@ inline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_na // optional .google.protobuf.FieldOptions options = 8; inline bool FieldDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void FieldDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000020u; } inline void FieldDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000020u; } inline void FieldDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear(); @@ -5401,9 +5510,6 @@ inline void FieldDescriptorProto::set_allocated_options(::google::protobuf::Fiel // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options) } -inline const FieldDescriptorProto* FieldDescriptorProto::internal_default_instance() { - return &FieldDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // OneofDescriptorProto @@ -5424,7 +5530,7 @@ inline void OneofDescriptorProto::clear_name() { } inline const ::std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void OneofDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5507,9 +5613,6 @@ inline void OneofDescriptorProto::set_allocated_options(::google::protobuf::Oneo // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options) } -inline const OneofDescriptorProto* OneofDescriptorProto::internal_default_instance() { - return &OneofDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumDescriptorProto @@ -5530,7 +5633,7 @@ inline void EnumDescriptorProto::clear_name() { } inline const ::std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void EnumDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5600,13 +5703,13 @@ EnumDescriptorProto::value() const { // optional .google.protobuf.EnumOptions options = 3; inline bool EnumDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void EnumDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void EnumDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void EnumDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear(); @@ -5643,9 +5746,6 @@ inline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumO // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options) } -inline const EnumDescriptorProto* EnumDescriptorProto::internal_default_instance() { - return &EnumDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValueDescriptorProto @@ -5666,7 +5766,7 @@ inline void EnumValueDescriptorProto::clear_name() { } inline const ::std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void EnumValueDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5706,13 +5806,13 @@ inline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) { // optional int32 number = 2; inline bool EnumValueDescriptorProto::has_number() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void EnumValueDescriptorProto::set_has_number() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } inline void EnumValueDescriptorProto::clear_has_number() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } inline void EnumValueDescriptorProto::clear_number() { number_ = 0; @@ -5730,13 +5830,13 @@ inline void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value // optional .google.protobuf.EnumValueOptions options = 3; inline bool EnumValueDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void EnumValueDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void EnumValueDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void EnumValueDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear(); @@ -5773,9 +5873,6 @@ inline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf:: // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options) } -inline const EnumValueDescriptorProto* EnumValueDescriptorProto::internal_default_instance() { - return &EnumValueDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // ServiceDescriptorProto @@ -5796,7 +5893,7 @@ inline void ServiceDescriptorProto::clear_name() { } inline const ::std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void ServiceDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5866,13 +5963,13 @@ ServiceDescriptorProto::method() const { // optional .google.protobuf.ServiceOptions options = 3; inline bool ServiceDescriptorProto::has_options() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void ServiceDescriptorProto::set_has_options() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void ServiceDescriptorProto::clear_has_options() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void ServiceDescriptorProto::clear_options() { if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear(); @@ -5909,9 +6006,6 @@ inline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::Se // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options) } -inline const ServiceDescriptorProto* ServiceDescriptorProto::internal_default_instance() { - return &ServiceDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // MethodDescriptorProto @@ -5932,7 +6026,7 @@ inline void MethodDescriptorProto::clear_name() { } inline const ::std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.GetNoArena(); } inline void MethodDescriptorProto::set_name(const ::std::string& value) { set_has_name(); @@ -5986,7 +6080,7 @@ inline void MethodDescriptorProto::clear_input_type() { } inline const ::std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) - return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return input_type_.GetNoArena(); } inline void MethodDescriptorProto::set_input_type(const ::std::string& value) { set_has_input_type(); @@ -6040,7 +6134,7 @@ inline void MethodDescriptorProto::clear_output_type() { } inline const ::std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) - return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return output_type_.GetNoArena(); } inline void MethodDescriptorProto::set_output_type(const ::std::string& value) { set_has_output_type(); @@ -6171,9 +6265,6 @@ inline void MethodDescriptorProto::set_server_streaming(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming) } -inline const MethodDescriptorProto* MethodDescriptorProto::internal_default_instance() { - return &MethodDescriptorProto_default_instance_.get(); -} // ------------------------------------------------------------------- // FileOptions @@ -6194,7 +6285,7 @@ inline void FileOptions::clear_java_package() { } inline const ::std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) - return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return java_package_.GetNoArena(); } inline void FileOptions::set_java_package(const ::std::string& value) { set_has_java_package(); @@ -6248,7 +6339,7 @@ inline void FileOptions::clear_java_outer_classname() { } inline const ::std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) - return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return java_outer_classname_.GetNoArena(); } inline void FileOptions::set_java_outer_classname(const ::std::string& value) { set_has_java_outer_classname(); @@ -6288,13 +6379,13 @@ inline void FileOptions::set_allocated_java_outer_classname(::std::string* java_ // optional bool java_multiple_files = 10 [default = false]; inline bool FileOptions::has_java_multiple_files() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void FileOptions::set_has_java_multiple_files() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000040u; } inline void FileOptions::clear_has_java_multiple_files() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000040u; } inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; @@ -6312,13 +6403,13 @@ inline void FileOptions::set_java_multiple_files(bool value) { // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; inline bool FileOptions::has_java_generate_equals_and_hash() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } inline void FileOptions::set_has_java_generate_equals_and_hash() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000080u; } inline void FileOptions::clear_has_java_generate_equals_and_hash() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000080u; } inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; @@ -6336,13 +6427,13 @@ inline void FileOptions::set_java_generate_equals_and_hash(bool value) { // optional bool java_string_check_utf8 = 27 [default = false]; inline bool FileOptions::has_java_string_check_utf8() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000100u) != 0; } inline void FileOptions::set_has_java_string_check_utf8() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000100u; } inline void FileOptions::clear_has_java_string_check_utf8() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000100u; } inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; @@ -6360,13 +6451,13 @@ inline void FileOptions::set_java_string_check_utf8(bool value) { // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; inline bool FileOptions::has_optimize_for() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00004000u) != 0; } inline void FileOptions::set_has_optimize_for() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00004000u; } inline void FileOptions::clear_has_optimize_for() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00004000u; } inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; @@ -6385,13 +6476,13 @@ inline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_Optimi // optional string go_package = 11; inline bool FileOptions::has_go_package() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FileOptions::set_has_go_package() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } inline void FileOptions::clear_has_go_package() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } inline void FileOptions::clear_go_package() { go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6399,7 +6490,7 @@ inline void FileOptions::clear_go_package() { } inline const ::std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) - return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return go_package_.GetNoArena(); } inline void FileOptions::set_go_package(const ::std::string& value) { set_has_go_package(); @@ -6439,13 +6530,13 @@ inline void FileOptions::set_allocated_go_package(::std::string* go_package) { // optional bool cc_generic_services = 16 [default = false]; inline bool FileOptions::has_cc_generic_services() const { - return (_has_bits_[0] & 0x00000080u) != 0; + return (_has_bits_[0] & 0x00000200u) != 0; } inline void FileOptions::set_has_cc_generic_services() { - _has_bits_[0] |= 0x00000080u; + _has_bits_[0] |= 0x00000200u; } inline void FileOptions::clear_has_cc_generic_services() { - _has_bits_[0] &= ~0x00000080u; + _has_bits_[0] &= ~0x00000200u; } inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; @@ -6463,13 +6554,13 @@ inline void FileOptions::set_cc_generic_services(bool value) { // optional bool java_generic_services = 17 [default = false]; inline bool FileOptions::has_java_generic_services() const { - return (_has_bits_[0] & 0x00000100u) != 0; + return (_has_bits_[0] & 0x00000400u) != 0; } inline void FileOptions::set_has_java_generic_services() { - _has_bits_[0] |= 0x00000100u; + _has_bits_[0] |= 0x00000400u; } inline void FileOptions::clear_has_java_generic_services() { - _has_bits_[0] &= ~0x00000100u; + _has_bits_[0] &= ~0x00000400u; } inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; @@ -6487,13 +6578,13 @@ inline void FileOptions::set_java_generic_services(bool value) { // optional bool py_generic_services = 18 [default = false]; inline bool FileOptions::has_py_generic_services() const { - return (_has_bits_[0] & 0x00000200u) != 0; + return (_has_bits_[0] & 0x00000800u) != 0; } inline void FileOptions::set_has_py_generic_services() { - _has_bits_[0] |= 0x00000200u; + _has_bits_[0] |= 0x00000800u; } inline void FileOptions::clear_has_py_generic_services() { - _has_bits_[0] &= ~0x00000200u; + _has_bits_[0] &= ~0x00000800u; } inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; @@ -6511,13 +6602,13 @@ inline void FileOptions::set_py_generic_services(bool value) { // optional bool deprecated = 23 [default = false]; inline bool FileOptions::has_deprecated() const { - return (_has_bits_[0] & 0x00000400u) != 0; + return (_has_bits_[0] & 0x00001000u) != 0; } inline void FileOptions::set_has_deprecated() { - _has_bits_[0] |= 0x00000400u; + _has_bits_[0] |= 0x00001000u; } inline void FileOptions::clear_has_deprecated() { - _has_bits_[0] &= ~0x00000400u; + _has_bits_[0] &= ~0x00001000u; } inline void FileOptions::clear_deprecated() { deprecated_ = false; @@ -6535,13 +6626,13 @@ inline void FileOptions::set_deprecated(bool value) { // optional bool cc_enable_arenas = 31 [default = false]; inline bool FileOptions::has_cc_enable_arenas() const { - return (_has_bits_[0] & 0x00000800u) != 0; + return (_has_bits_[0] & 0x00002000u) != 0; } inline void FileOptions::set_has_cc_enable_arenas() { - _has_bits_[0] |= 0x00000800u; + _has_bits_[0] |= 0x00002000u; } inline void FileOptions::clear_has_cc_enable_arenas() { - _has_bits_[0] &= ~0x00000800u; + _has_bits_[0] &= ~0x00002000u; } inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; @@ -6559,13 +6650,13 @@ inline void FileOptions::set_cc_enable_arenas(bool value) { // optional string objc_class_prefix = 36; inline bool FileOptions::has_objc_class_prefix() const { - return (_has_bits_[0] & 0x00001000u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void FileOptions::set_has_objc_class_prefix() { - _has_bits_[0] |= 0x00001000u; + _has_bits_[0] |= 0x00000008u; } inline void FileOptions::clear_has_objc_class_prefix() { - _has_bits_[0] &= ~0x00001000u; + _has_bits_[0] &= ~0x00000008u; } inline void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6573,7 +6664,7 @@ inline void FileOptions::clear_objc_class_prefix() { } inline const ::std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) - return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return objc_class_prefix_.GetNoArena(); } inline void FileOptions::set_objc_class_prefix(const ::std::string& value) { set_has_objc_class_prefix(); @@ -6613,13 +6704,13 @@ inline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_cla // optional string csharp_namespace = 37; inline bool FileOptions::has_csharp_namespace() const { - return (_has_bits_[0] & 0x00002000u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void FileOptions::set_has_csharp_namespace() { - _has_bits_[0] |= 0x00002000u; + _has_bits_[0] |= 0x00000010u; } inline void FileOptions::clear_has_csharp_namespace() { - _has_bits_[0] &= ~0x00002000u; + _has_bits_[0] &= ~0x00000010u; } inline void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -6627,7 +6718,7 @@ inline void FileOptions::clear_csharp_namespace() { } inline const ::std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) - return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return csharp_namespace_.GetNoArena(); } inline void FileOptions::set_csharp_namespace(const ::std::string& value) { set_has_csharp_namespace(); @@ -6665,6 +6756,60 @@ inline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_na // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace) } +// optional string swift_prefix = 39; +inline bool FileOptions::has_swift_prefix() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void FileOptions::set_has_swift_prefix() { + _has_bits_[0] |= 0x00000020u; +} +inline void FileOptions::clear_has_swift_prefix() { + _has_bits_[0] &= ~0x00000020u; +} +inline void FileOptions::clear_swift_prefix() { + swift_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + clear_has_swift_prefix(); +} +inline const ::std::string& FileOptions::swift_prefix() const { + // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.GetNoArena(); +} +inline void FileOptions::set_swift_prefix(const ::std::string& value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) +} +inline void FileOptions::set_swift_prefix(const char* value) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); + // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.swift_prefix) +} +inline void FileOptions::set_swift_prefix(const char* value, size_t size) { + set_has_swift_prefix(); + swift_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), + ::std::string(reinterpret_cast<const char*>(value), size)); + // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) +} +inline ::std::string* FileOptions::mutable_swift_prefix() { + set_has_swift_prefix(); + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) + return swift_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline ::std::string* FileOptions::release_swift_prefix() { + // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.swift_prefix) + clear_has_swift_prefix(); + return swift_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); +} +inline void FileOptions::set_allocated_swift_prefix(::std::string* swift_prefix) { + if (swift_prefix != NULL) { + set_has_swift_prefix(); + } else { + clear_has_swift_prefix(); + } + swift_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), swift_prefix); + // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.swift_prefix) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int FileOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -6695,9 +6840,6 @@ FileOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FileOptions* FileOptions::internal_default_instance() { - return &FileOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MessageOptions @@ -6828,9 +6970,6 @@ MessageOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MessageOptions* MessageOptions::internal_default_instance() { - return &MessageOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // FieldOptions @@ -6862,13 +7001,13 @@ inline void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value // optional bool packed = 2; inline bool FieldOptions::has_packed() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void FieldOptions::set_has_packed() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000004u; } inline void FieldOptions::clear_has_packed() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000004u; } inline void FieldOptions::clear_packed() { packed_ = false; @@ -6886,13 +7025,13 @@ inline void FieldOptions::set_packed(bool value) { // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; inline bool FieldOptions::has_jstype() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void FieldOptions::set_has_jstype() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void FieldOptions::clear_has_jstype() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void FieldOptions::clear_jstype() { jstype_ = 0; @@ -7011,9 +7150,6 @@ FieldOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const FieldOptions* FieldOptions::internal_default_instance() { - return &FieldOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // OneofOptions @@ -7048,9 +7184,6 @@ OneofOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const OneofOptions* OneofOptions::internal_default_instance() { - return &OneofOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumOptions @@ -7133,9 +7266,6 @@ EnumOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumOptions* EnumOptions::internal_default_instance() { - return &EnumOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValueOptions @@ -7194,9 +7324,6 @@ EnumValueOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const EnumValueOptions* EnumValueOptions::internal_default_instance() { - return &EnumValueOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // ServiceOptions @@ -7255,9 +7382,6 @@ ServiceOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const ServiceOptions* ServiceOptions::internal_default_instance() { - return &ServiceOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // MethodOptions @@ -7286,6 +7410,31 @@ inline void MethodOptions::set_deprecated(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated) } +// optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; +inline bool MethodOptions::has_idempotency_level() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void MethodOptions::set_has_idempotency_level() { + _has_bits_[0] |= 0x00000002u; +} +inline void MethodOptions::clear_has_idempotency_level() { + _has_bits_[0] &= ~0x00000002u; +} +inline void MethodOptions::clear_idempotency_level() { + idempotency_level_ = 0; + clear_has_idempotency_level(); +} +inline ::google::protobuf::MethodOptions_IdempotencyLevel MethodOptions::idempotency_level() const { + // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.idempotency_level) + return static_cast< ::google::protobuf::MethodOptions_IdempotencyLevel >(idempotency_level_); +} +inline void MethodOptions::set_idempotency_level(::google::protobuf::MethodOptions_IdempotencyLevel value) { + assert(::google::protobuf::MethodOptions_IdempotencyLevel_IsValid(value)); + set_has_idempotency_level(); + idempotency_level_ = value; + // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.idempotency_level) +} + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; inline int MethodOptions::uninterpreted_option_size() const { return uninterpreted_option_.size(); @@ -7316,9 +7465,6 @@ MethodOptions::uninterpreted_option() const { return uninterpreted_option_; } -inline const MethodOptions* MethodOptions::internal_default_instance() { - return &MethodOptions_default_instance_.get(); -} // ------------------------------------------------------------------- // UninterpretedOption_NamePart @@ -7339,7 +7485,7 @@ inline void UninterpretedOption_NamePart::clear_name_part() { } inline const ::std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_part_.GetNoArena(); } inline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) { set_has_name_part(); @@ -7401,9 +7547,6 @@ inline void UninterpretedOption_NamePart::set_is_extension(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension) } -inline const UninterpretedOption_NamePart* UninterpretedOption_NamePart::internal_default_instance() { - return &UninterpretedOption_NamePart_default_instance_.get(); -} // ------------------------------------------------------------------- // UninterpretedOption @@ -7440,13 +7583,13 @@ UninterpretedOption::name() const { // optional string identifier_value = 3; inline bool UninterpretedOption::has_identifier_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void UninterpretedOption::set_has_identifier_value() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void UninterpretedOption::clear_has_identifier_value() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7454,7 +7597,7 @@ inline void UninterpretedOption::clear_identifier_value() { } inline const ::std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) - return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return identifier_value_.GetNoArena(); } inline void UninterpretedOption::set_identifier_value(const ::std::string& value) { set_has_identifier_value(); @@ -7494,13 +7637,13 @@ inline void UninterpretedOption::set_allocated_identifier_value(::std::string* i // optional uint64 positive_int_value = 4; inline bool UninterpretedOption::has_positive_int_value() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void UninterpretedOption::set_has_positive_int_value() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } inline void UninterpretedOption::clear_has_positive_int_value() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } inline void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = GOOGLE_ULONGLONG(0); @@ -7518,13 +7661,13 @@ inline void UninterpretedOption::set_positive_int_value(::google::protobuf::uint // optional int64 negative_int_value = 5; inline bool UninterpretedOption::has_negative_int_value() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void UninterpretedOption::set_has_negative_int_value() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } inline void UninterpretedOption::clear_has_negative_int_value() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } inline void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = GOOGLE_LONGLONG(0); @@ -7542,13 +7685,13 @@ inline void UninterpretedOption::set_negative_int_value(::google::protobuf::int6 // optional double double_value = 6; inline bool UninterpretedOption::has_double_value() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void UninterpretedOption::set_has_double_value() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } inline void UninterpretedOption::clear_has_double_value() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } inline void UninterpretedOption::clear_double_value() { double_value_ = 0; @@ -7566,13 +7709,13 @@ inline void UninterpretedOption::set_double_value(double value) { // optional bytes string_value = 7; inline bool UninterpretedOption::has_string_value() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void UninterpretedOption::set_has_string_value() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000002u; } inline void UninterpretedOption::clear_has_string_value() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000002u; } inline void UninterpretedOption::clear_string_value() { string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7580,7 +7723,7 @@ inline void UninterpretedOption::clear_string_value() { } inline const ::std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) - return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return string_value_.GetNoArena(); } inline void UninterpretedOption::set_string_value(const ::std::string& value) { set_has_string_value(); @@ -7620,13 +7763,13 @@ inline void UninterpretedOption::set_allocated_string_value(::std::string* strin // optional string aggregate_value = 8; inline bool UninterpretedOption::has_aggregate_value() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void UninterpretedOption::set_has_aggregate_value() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000004u; } inline void UninterpretedOption::clear_has_aggregate_value() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000004u; } inline void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7634,7 +7777,7 @@ inline void UninterpretedOption::clear_aggregate_value() { } inline const ::std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) - return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return aggregate_value_.GetNoArena(); } inline void UninterpretedOption::set_aggregate_value(const ::std::string& value) { set_has_aggregate_value(); @@ -7672,9 +7815,6 @@ inline void UninterpretedOption::set_allocated_aggregate_value(::std::string* ag // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value) } -inline const UninterpretedOption* UninterpretedOption::internal_default_instance() { - return &UninterpretedOption_default_instance_.get(); -} // ------------------------------------------------------------------- // SourceCodeInfo_Location @@ -7741,13 +7881,13 @@ SourceCodeInfo_Location::mutable_span() { // optional string leading_comments = 3; inline bool SourceCodeInfo_Location::has_leading_comments() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void SourceCodeInfo_Location::set_has_leading_comments() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000001u; } inline void SourceCodeInfo_Location::clear_has_leading_comments() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000001u; } inline void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7755,7 +7895,7 @@ inline void SourceCodeInfo_Location::clear_leading_comments() { } inline const ::std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) - return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return leading_comments_.GetNoArena(); } inline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) { set_has_leading_comments(); @@ -7795,13 +7935,13 @@ inline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::strin // optional string trailing_comments = 4; inline bool SourceCodeInfo_Location::has_trailing_comments() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void SourceCodeInfo_Location::set_has_trailing_comments() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000002u; } inline void SourceCodeInfo_Location::clear_has_trailing_comments() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000002u; } inline void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7809,7 +7949,7 @@ inline void SourceCodeInfo_Location::clear_trailing_comments() { } inline const ::std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) - return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return trailing_comments_.GetNoArena(); } inline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) { set_has_trailing_comments(); @@ -7902,9 +8042,6 @@ SourceCodeInfo_Location::mutable_leading_detached_comments() { return &leading_detached_comments_; } -inline const SourceCodeInfo_Location* SourceCodeInfo_Location::internal_default_instance() { - return &SourceCodeInfo_Location_default_instance_.get(); -} // ------------------------------------------------------------------- // SourceCodeInfo @@ -7939,9 +8076,6 @@ SourceCodeInfo::location() const { return location_; } -inline const SourceCodeInfo* SourceCodeInfo::internal_default_instance() { - return &SourceCodeInfo_default_instance_.get(); -} // ------------------------------------------------------------------- // GeneratedCodeInfo_Annotation @@ -7978,13 +8112,13 @@ GeneratedCodeInfo_Annotation::mutable_path() { // optional string source_file = 2; inline bool GeneratedCodeInfo_Annotation::has_source_file() const { - return (_has_bits_[0] & 0x00000002u) != 0; + return (_has_bits_[0] & 0x00000001u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_source_file() { - _has_bits_[0] |= 0x00000002u; + _has_bits_[0] |= 0x00000001u; } inline void GeneratedCodeInfo_Annotation::clear_has_source_file() { - _has_bits_[0] &= ~0x00000002u; + _has_bits_[0] &= ~0x00000001u; } inline void GeneratedCodeInfo_Annotation::clear_source_file() { source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); @@ -7992,7 +8126,7 @@ inline void GeneratedCodeInfo_Annotation::clear_source_file() { } inline const ::std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return source_file_.GetNoArena(); } inline void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) { set_has_source_file(); @@ -8032,13 +8166,13 @@ inline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::strin // optional int32 begin = 3; inline bool GeneratedCodeInfo_Annotation::has_begin() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000002u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_begin() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000002u; } inline void GeneratedCodeInfo_Annotation::clear_has_begin() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000002u; } inline void GeneratedCodeInfo_Annotation::clear_begin() { begin_ = 0; @@ -8056,13 +8190,13 @@ inline void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 va // optional int32 end = 4; inline bool GeneratedCodeInfo_Annotation::has_end() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000004u) != 0; } inline void GeneratedCodeInfo_Annotation::set_has_end() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000004u; } inline void GeneratedCodeInfo_Annotation::clear_has_end() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000004u; } inline void GeneratedCodeInfo_Annotation::clear_end() { end_ = 0; @@ -8078,9 +8212,6 @@ inline void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 valu // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end) } -inline const GeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::internal_default_instance() { - return &GeneratedCodeInfo_Annotation_default_instance_.get(); -} // ------------------------------------------------------------------- // GeneratedCodeInfo @@ -8115,9 +8246,6 @@ GeneratedCodeInfo::annotation() const { return annotation_; } -inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { - return &GeneratedCodeInfo_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -8170,6 +8298,7 @@ inline const GeneratedCodeInfo* GeneratedCodeInfo::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google @@ -8202,6 +8331,11 @@ template <> inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_JSType>() { return ::google::protobuf::FieldOptions_JSType_descriptor(); } +template <> struct is_proto_enum< ::google::protobuf::MethodOptions_IdempotencyLevel> : ::google::protobuf::internal::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::MethodOptions_IdempotencyLevel>() { + return ::google::protobuf::MethodOptions_IdempotencyLevel_descriptor(); +} } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 558ae23e..eae31601 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -157,7 +157,6 @@ message FieldDescriptorProto { LABEL_OPTIONAL = 1; LABEL_REQUIRED = 2; LABEL_REPEATED = 3; - // TODO(sanjay): Should we add LABEL_MAP? }; optional string name = 1; @@ -367,6 +366,12 @@ message FileOptions { // Namespace for generated classes; defaults to the package. optional string csharp_namespace = 37; + // By default Swift generators will take the proto package and CamelCase it + // replacing '.' with underscore and use that to prefix the types/symbols + // defined. When this options is provided, they will use this value instead + // to prefix the types/symbols defined. + optional string swift_prefix = 39; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -431,13 +436,14 @@ message MessageOptions { // parser. optional bool map_entry = 7; + reserved 8; // javalite_serializable + + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; // Clients can define custom options in extensions of this message. See above. extensions 1000 to max; - - reserved 8; // javalite_serializable } message FieldOptions { @@ -551,6 +557,7 @@ message EnumOptions { // is a formalization for deprecating enums. optional bool deprecated = 3 [default=false]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -605,6 +612,17 @@ message MethodOptions { // this is a formalization for deprecating methods. optional bool deprecated = 33 [default=false]; + // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + // or neither? HTTP based RPC implementation may choose GET verb for safe + // methods, and PUT verb for idempotent methods instead of the default POST. + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0; + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects + } + optional IdempotencyLevel idempotency_level = + 34 [default=IDEMPOTENCY_UNKNOWN]; + // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 2117c020..57ae960f 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -97,11 +97,12 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( // Try to look up the symbol to make sure a super-symbol doesn't already // exist. - typename map<string, Value>::iterator iter = FindLastLessOrEqual(name); + typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name); if (iter == by_symbol_.end()) { // Apparently the map is currently empty. Just insert and be done with it. - by_symbol_.insert(typename map<string, Value>::value_type(name, value)); + by_symbol_.insert( + typename std::map<string, Value>::value_type(name, value)); return true; } @@ -128,7 +129,8 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol( // Insert the new symbol using the iterator as a hint, the new entry will // appear immediately before the one the iterator is pointing at. - by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value)); + by_symbol_.insert(iter, + typename std::map<string, Value>::value_type(name, value)); return true; } @@ -179,7 +181,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile( template <typename Value> Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol( const string& name) { - typename map<string, Value>::iterator iter = FindLastLessOrEqual(name); + typename std::map<string, Value>::iterator iter = FindLastLessOrEqual(name); return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ? iter->second : Value(); @@ -196,8 +198,8 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension( template <typename Value> bool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers( const string& containing_type, - vector<int>* output) { - typename map<pair<string, int>, Value>::const_iterator it = + std::vector<int>* output) { + typename std::map<pair<string, int>, Value>::const_iterator it = by_extension_.lower_bound(std::make_pair(containing_type, 0)); bool success = false; @@ -217,7 +219,8 @@ SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual( // Find the last key in the map which sorts less than or equal to the // symbol name. Since upper_bound() returns the *first* key that sorts // *greater* than the input, we want the element immediately before that. - typename map<string, Value>::iterator iter = by_symbol_.upper_bound(name); + typename std::map<string, Value>::iterator iter = + by_symbol_.upper_bound(name); if (iter != by_symbol_.begin()) --iter; return iter; } @@ -284,7 +287,7 @@ bool SimpleDescriptorDatabase::FindFileContainingExtension( bool SimpleDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } @@ -340,7 +343,7 @@ bool EncodedDescriptorDatabase::FindFileContainingSymbol( bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( const string& symbol_name, string* output) { - pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name); + std::pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name); if (encoded_file.first == NULL) return false; // Optimization: The name should be the first field in the encoded message. @@ -352,7 +355,7 @@ bool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol( FileDescriptorProto::kNameFieldNumber, internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - if (input.ReadTag() == kNameTag) { + if (input.ReadTagNoLastTag() == kNameTag) { // Success! return internal::WireFormatLite::ReadString(&input, output); } else { @@ -376,12 +379,12 @@ bool EncodedDescriptorDatabase::FindFileContainingExtension( bool EncodedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { return index_.FindAllExtensionNumbers(extendee_type, output); } bool EncodedDescriptorDatabase::MaybeParse( - pair<const void*, int> encoded_file, + std::pair<const void*, int> encoded_file, FileDescriptorProto* output) { if (encoded_file.first == NULL) return false; return output->ParseFromArray(encoded_file.first, encoded_file.second); @@ -431,11 +434,11 @@ bool DescriptorPoolDatabase::FindFileContainingExtension( bool DescriptorPoolDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { + std::vector<int>* output) { const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type); if (extendee == NULL) return false; - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool_.FindAllExtensions(extendee, &extensions); for (int i = 0; i < extensions.size(); ++i) { @@ -454,7 +457,7 @@ MergedDescriptorDatabase::MergedDescriptorDatabase( sources_.push_back(source2); } MergedDescriptorDatabase::MergedDescriptorDatabase( - const vector<DescriptorDatabase*>& sources) + const std::vector<DescriptorDatabase*>& sources) : sources_(sources) {} MergedDescriptorDatabase::~MergedDescriptorDatabase() {} @@ -517,23 +520,23 @@ bool MergedDescriptorDatabase::FindFileContainingExtension( bool MergedDescriptorDatabase::FindAllExtensionNumbers( const string& extendee_type, - vector<int>* output) { - set<int> merged_results; - vector<int> results; + std::vector<int>* output) { + std::set<int> merged_results; + std::vector<int> results; bool success = false; for (int i = 0; i < sources_.size(); i++) { if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) { - std::copy( - results.begin(), results.end(), - insert_iterator<set<int> >(merged_results, merged_results.begin())); + std::copy(results.begin(), results.end(), + std::insert_iterator<std::set<int> >(merged_results, + merged_results.begin())); success = true; } results.clear(); } std::copy(merged_results.begin(), merged_results.end(), - insert_iterator<vector<int> >(*output, output->end())); + std::insert_iterator<std::vector<int> >(*output, output->end())); return success; } diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 86002d56..be97a6d8 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -97,7 +97,7 @@ class LIBPROTOBUF_EXPORT DescriptorDatabase { // This method has a default implementation that always returns // false. virtual bool FindAllExtensionNumbers(const string& /* extendee_type */, - vector<int>* /* output */) { + std::vector<int>* /* output */) { return false; } @@ -150,7 +150,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: // So that it can use DescriptorIndex. @@ -175,12 +175,12 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { Value FindSymbol(const string& name); Value FindExtension(const string& containing_type, int field_number); bool FindAllExtensionNumbers(const string& containing_type, - vector<int>* output); + std::vector<int>* output); private: - map<string, Value> by_name_; - map<string, Value> by_symbol_; - map<pair<string, int>, Value> by_extension_; + std::map<string, Value> by_name_; + std::map<string, Value> by_symbol_; + std::map<std::pair<string, int>, Value> by_extension_; // Invariant: The by_symbol_ map does not contain any symbols which are // prefixes of other symbols in the map. For example, "foo.bar" is a @@ -235,7 +235,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { // Find the last entry in the by_symbol_ map whose key is less than or // equal to the given name. - typename map<string, Value>::iterator FindLastLessOrEqual( + typename std::map<string, Value>::iterator FindLastLessOrEqual( const string& name); // True if either the arguments are equal or super_symbol identifies a @@ -250,7 +250,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { DescriptorIndex<const FileDescriptorProto*> index_; - vector<const FileDescriptorProto*> files_to_delete_; + std::vector<const FileDescriptorProto*> files_to_delete_; // If file is non-NULL, copy it into *output and return true, otherwise // return false. @@ -295,15 +295,16 @@ class LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: - SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_; - vector<void*> files_to_delete_; + SimpleDescriptorDatabase::DescriptorIndex<std::pair<const void*, int> > + index_; + std::vector<void*> files_to_delete_; // If encoded_file.first is non-NULL, parse the data into *output and return // true, otherwise return false. - bool MaybeParse(pair<const void*, int> encoded_file, + bool MaybeParse(std::pair<const void*, int> encoded_file, FileDescriptorProto* output); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase); @@ -324,7 +325,7 @@ class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase { int field_number, FileDescriptorProto* output); bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: const DescriptorPool& pool_; @@ -341,7 +342,8 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { // Merge more than two databases. The sources remain property of the caller. // The vector may be deleted after the constructor returns but the // DescriptorDatabases need to stick around. - explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources); + explicit MergedDescriptorDatabase( + const std::vector<DescriptorDatabase*>& sources); ~MergedDescriptorDatabase(); // implements DescriptorDatabase ----------------------------------- @@ -355,11 +357,11 @@ class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { // Merges the results of calling all databases. Returns true iff any // of the databases returned true. bool FindAllExtensionNumbers(const string& extendee_type, - vector<int>* output); + std::vector<int>* output); private: - vector<DescriptorDatabase*> sources_; + std::vector<DescriptorDatabase*> sources_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); }; diff --git a/src/google/protobuf/descriptor_database_unittest.cc b/src/google/protobuf/descriptor_database_unittest.cc index 4f568f7d..05d67656 100644 --- a/src/google/protobuf/descriptor_database_unittest.cc +++ b/src/google/protobuf/descriptor_database_unittest.cc @@ -410,7 +410,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { "extension { name:\"waldo\" extendee: \"Bar\" number:56 } "); { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(database_->FindAllExtensionNumbers("Foo", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -419,7 +419,7 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { } { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(database_->FindAllExtensionNumbers("corge.Bar", &numbers)); // Note: won't find extension 56 due to the name not being fully qualified. ASSERT_EQ(1, numbers.size()); @@ -428,13 +428,13 @@ TEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) { { // Can't find extensions for non-existent types. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(database_->FindAllExtensionNumbers("NoSuchType", &numbers)); } { // Can't find extensions for unqualified types. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(database_->FindAllExtensionNumbers("Bar", &numbers)); } } @@ -708,7 +708,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindFileContainingExtension) { TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Message only has extension in database1_ - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Foo", &numbers)); ASSERT_EQ(1, numbers.size()); EXPECT_EQ(3, numbers[0]); @@ -716,7 +716,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Message only has extension in database2_ - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Bar", &numbers)); ASSERT_EQ(1, numbers.size()); EXPECT_EQ(5, numbers[0]); @@ -724,7 +724,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Merge results from the two databases. - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers("Baz", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -733,7 +733,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { } { - vector<int> numbers; + std::vector<int> numbers; EXPECT_TRUE(reverse_merged_.FindAllExtensionNumbers("Baz", &numbers)); ASSERT_EQ(2, numbers.size()); std::sort(numbers.begin(), numbers.end()); @@ -743,7 +743,7 @@ TEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) { { // Can't find extensions for a non-existent message. - vector<int> numbers; + std::vector<int> numbers; EXPECT_FALSE(reverse_merged_.FindAllExtensionNumbers("Blah", &numbers)); } } diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index f6b3f1c5..7ec75156 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -41,8 +41,11 @@ #include <vector> #include <google/protobuf/compiler/importer.h> +#include <google/protobuf/compiler/parser.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/unittest_custom_options.pb.h> +#include <google/protobuf/unittest_proto3_arena.pb.h> +#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> @@ -55,6 +58,7 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/logging.h> +#include <google/protobuf/stubs/stringprintf.h> #include <google/protobuf/testing/googletest.h> #include <gtest/gtest.h> @@ -488,6 +492,65 @@ TEST_F(FileDescriptorTest, Syntax) { } } +void ExtractDebugString( + const FileDescriptor* file, std::set<string>* visited, + std::vector<std::pair<string, string> >* debug_strings) { + if (!visited->insert(file->name()).second) { + return; + } + for (int i = 0; i < file->dependency_count(); ++i) { + ExtractDebugString(file->dependency(i), visited, debug_strings); + } + debug_strings->push_back(make_pair(file->name(), file->DebugString())); +} + +class SimpleErrorCollector : public google::protobuf::io::ErrorCollector { + public: + // implements ErrorCollector --------------------------------------- + void AddError(int line, int column, const string& message) { + last_error_ = StringPrintf("%d:%d:", line, column) + message; + } + + const string& last_error() { return last_error_; } + + private: + string last_error_; +}; +// Test that the result of FileDescriptor::DebugString() can be used to create +// the original descriptors. +TEST_F(FileDescriptorTest, DebugStringRoundTrip) { + std::set<string> visited; + std::vector<std::pair<string, string> > debug_strings; + ExtractDebugString(protobuf_unittest::TestAllTypes::descriptor()->file(), + &visited, &debug_strings); + ExtractDebugString( + protobuf_unittest::TestMessageWithCustomOptions::descriptor()->file(), + &visited, &debug_strings); + ExtractDebugString(proto3_arena_unittest::TestAllTypes::descriptor()->file(), + &visited, &debug_strings); + ASSERT_GE(debug_strings.size(), 3); + + DescriptorPool pool; + for (int i = 0; i < debug_strings.size(); ++i) { + const string& name = debug_strings[i].first; + const string& content = debug_strings[i].second; + google::protobuf::io::ArrayInputStream input_stream(content.data(), content.size()); + SimpleErrorCollector error_collector; + google::protobuf::io::Tokenizer tokenizer(&input_stream, &error_collector); + google::protobuf::compiler::Parser parser; + parser.RecordErrorsTo(&error_collector); + FileDescriptorProto proto; + ASSERT_TRUE(parser.Parse(&tokenizer, &proto)) + << error_collector.last_error() << "\n" + << content; + ASSERT_EQ("", error_collector.last_error()); + proto.set_name(name); + const FileDescriptor* descriptor = pool.BuildFile(proto); + ASSERT_TRUE(descriptor != NULL) << proto.DebugString(); + EXPECT_EQ(content, descriptor->DebugString()); + } +} + // =================================================================== // Test simple flat messages and fields. @@ -1861,7 +1924,7 @@ TEST_F(ExtensionDescriptorTest, FindExtensionByName) { } TEST_F(ExtensionDescriptorTest, FindAllExtensions) { - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool_.FindAllExtensions(foo_, &extensions); ASSERT_EQ(4, extensions.size()); EXPECT_EQ(10, extensions[0]->number()); @@ -2625,7 +2688,7 @@ TEST_P(AllowUnknownDependenciesTest, CustomOption) { // Verify that no extension options were set, but they were left as // uninterpreted_options. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; file->options().GetReflection()->ListFields(file->options(), &fields); ASSERT_EQ(2, fields.size()); EXPECT_TRUE(file->options().has_optimize_for()); @@ -3276,6 +3339,85 @@ TEST(CustomOptions, OptionsWithRequiredEnums) { EXPECT_EQ(protobuf_unittest::NewOptionType::NEW_VALUE, new_enum_opt.value()); } +// Test that FileDescriptor::DebugString() formats custom options correctly. +TEST(CustomOptions, DebugString) { + DescriptorPool pool; + + FileDescriptorProto file_proto; + MessageOptions::descriptor()->file()->CopyTo(&file_proto); + ASSERT_TRUE(pool.BuildFile(file_proto) != NULL); + + // Add "foo.proto": + // import "google/protobuf/descriptor.proto"; + // package "protobuf_unittest"; + // option (protobuf_unittest.cc_option1) = 1; + // option (protobuf_unittest.cc_option2) = 2; + // extend google.protobuf.FieldOptions { + // optional int32 cc_option1 = 7736974; + // optional int32 cc_option2 = 7736975; + // } + ASSERT_TRUE(TextFormat::ParseFromString( + "name: \"foo.proto\" " + "package: \"protobuf_unittest\" " + "dependency: \"google/protobuf/descriptor.proto\" " + "options { " + " uninterpreted_option { " + " name { " + " name_part: \"protobuf_unittest.cc_option1\" " + " is_extension: true " + " } " + " positive_int_value: 1 " + " } " + " uninterpreted_option { " + " name { " + " name_part: \"protobuf_unittest.cc_option2\" " + " is_extension: true " + " } " + " positive_int_value: 2 " + " } " + "} " + "extension { " + " name: \"cc_option1\" " + " extendee: \".google.protobuf.FileOptions\" " + // This field number is intentionally chosen to be the same as + // (.fileopt1) defined in unittest_custom_options.proto (linked + // in this test binary). This is to test whether we are messing + // generated pool with custom descriptor pools when dealing with + // custom options. + " number: 7736974 " + " label: LABEL_OPTIONAL " + " type: TYPE_INT32 " + "}" + "extension { " + " name: \"cc_option2\" " + " extendee: \".google.protobuf.FileOptions\" " + " number: 7736975 " + " label: LABEL_OPTIONAL " + " type: TYPE_INT32 " + "}", + &file_proto)); + const FileDescriptor* descriptor = pool.BuildFile(file_proto); + ASSERT_TRUE(descriptor != NULL); + + EXPECT_EQ(2, descriptor->extension_count()); + + ASSERT_EQ( + "syntax = \"proto2\";\n" + "\n" + "import \"google/protobuf/descriptor.proto\";\n" + "package protobuf_unittest;\n" + "\n" + "option (.protobuf_unittest.cc_option1) = 1;\n" + "option (.protobuf_unittest.cc_option2) = 2;\n" + "\n" + "extend .google.protobuf.FileOptions {\n" + " optional int32 cc_option1 = 7736974;\n" + " optional int32 cc_option2 = 7736975;\n" + "}\n" + "\n", + descriptor->DebugString()); +} + // =================================================================== class ValidationErrorTest : public testing::Test { @@ -5169,7 +5311,7 @@ TEST_F(ValidationErrorTest, ErrorsReportedToLogError) { "message_type { name: \"Foo\" } ", &file_proto)); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -5598,8 +5740,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { "}", "foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is " "PascalCased (BarBaz), this value label conflicts with " - "FOO_ENUM_BAR_BAZ. This " - "will make the proto fail to compile for some languages, such as C#.\n"); + "FOO_ENUM_BAR_BAZ. This will make the proto fail to compile for some " + "languages, such as C#.\n"); BuildFileWithErrors( "syntax: 'proto3'" @@ -5611,8 +5753,8 @@ TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) { "}", "foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is " "PascalCased (BarBaz), this value label conflicts with " - "FOO_ENUM__BAR_BAZ. This " - "will make the proto fail to compile for some languages, such as C#.\n"); + "FOO_ENUM__BAR_BAZ. This will make the proto fail to compile for some " + "languages, such as C#.\n"); // This isn't an error because the underscore will cause the PascalCase to // differ by case (BarBaz vs. Barbaz). @@ -6159,7 +6301,7 @@ TEST_F(DatabaseBackedPoolTest, FindAllExtensions) { for (int i = 0; i < 2; ++i) { // Repeat the lookup twice, to check that we get consistent // results despite the fallback database lookup mutating the pool. - vector<const FieldDescriptor*> extensions; + std::vector<const FieldDescriptor*> extensions; pool.FindAllExtensions(foo, &extensions); ASSERT_EQ(1, extensions.size()); EXPECT_EQ(5, extensions[0]->number()); @@ -6170,7 +6312,7 @@ TEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) { ErrorDescriptorDatabase error_database; DescriptorPool pool(&error_database); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index f7cc647f..12135b80 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -19,85 +19,88 @@ namespace google { namespace protobuf { +class DurationDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Duration> {}; +DurationDefaultTypeInternal _Duration_default_instance_; namespace { -const ::google::protobuf::Descriptor* Duration_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Duration_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/duration.proto"); - GOOGLE_CHECK(file != NULL); - Duration_descriptor_ = file->message_type(0); - static const int Duration_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_), }; - Duration_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Duration_descriptor_, - Duration::internal_default_instance(), - Duration_offsets_, - -1, - -1, - -1, - sizeof(Duration), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Duration)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Duration_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/duration.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fduration_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Duration_descriptor_, Duration::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() { - Duration_default_instance_.Shutdown(); - delete Duration_reflection_; + _Duration_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Duration_default_instance_.DefaultConstruct(); - Duration_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Duration_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + static const char descriptor[] = { + "\n\036google/protobuf/duration.proto\022\017google" + ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" + "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" + "rationProtoP\001Z*github.com/golang/protobu" + "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" + "obuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\036google/protobuf/duration.proto\022\017google" - ".protobuf\"*\n\010Duration\022\017\n\007seconds\030\001 \001(\003\022\r" - "\n\005nanos\030\002 \001(\005B|\n\023com.google.protobufB\rDu" - "rationProtoP\001Z*github.com/golang/protobu" - "f/ptypes/duration\370\001\001\242\002\003GPB\252\002\036Google.Prot" - "obuf.WellKnownTypesb\006proto3", 227); + descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/duration.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto); @@ -115,16 +118,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -134,7 +127,9 @@ const int Duration::kNanosFieldNumber; Duration::Duration() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Duration) } @@ -148,15 +143,14 @@ Duration::Duration(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Duration) } - -void Duration::InitAsDefaultInstance() { -} - Duration::Duration(const Duration& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&seconds_, &from.seconds_, + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration) } @@ -192,7 +186,7 @@ void Duration::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Duration::descriptor() { protobuf_AssignDescriptorsOnce(); - return Duration_descriptor_; + return file_level_metadata[0].descriptor; } const Duration& Duration::default_instance() { @@ -200,35 +194,14 @@ const Duration& Duration::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_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) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Duration, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Duration*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(seconds_, nanos_); - -#undef ZR_HELPER_ -#undef ZR_ - + ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); } bool Duration::MergePartialFromCodedStream( @@ -237,13 +210,13 @@ bool Duration::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Duration) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 seconds = 1; + // int64 seconds = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +224,12 @@ bool Duration::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_nanos; break; } - // optional int32 nanos = 2; + // int32 nanos = 2; case 2: { - if (tag == 16) { - parse_nanos: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +237,6 @@ bool Duration::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +264,12 @@ failure: void Duration::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Duration) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } @@ -311,12 +281,12 @@ void Duration::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } @@ -329,14 +299,14 @@ size_t Duration::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration) size_t total_size = 0; - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->seconds()); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -352,7 +322,7 @@ size_t Duration::ByteSizeLong() const { void Duration::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Duration* source = ::google::protobuf::internal::DynamicCastToGenerated<const Duration>( &from); @@ -361,21 +331,14 @@ void Duration::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Duration::MergeFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Duration::UnsafeMergeFrom(const Duration& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -395,11 +358,10 @@ void Duration::CopyFrom(const Duration& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Duration::IsInitialized() const { - return true; } @@ -408,10 +370,13 @@ void Duration::Swap(Duration* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Duration temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Duration* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Duration::UnsafeArenaSwap(Duration* other) { @@ -422,22 +387,18 @@ void Duration::UnsafeArenaSwap(Duration* other) { void Duration::InternalSwap(Duration* other) { std::swap(seconds_, other->seconds_); std::swap(nanos_, other->nanos_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Duration::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Duration_descriptor_; - metadata.reflection = Duration_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Duration -// optional int64 seconds = 1; +// int64 seconds = 1; void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -451,7 +412,7 @@ void Duration::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; void Duration::clear_nanos() { nanos_ = 0; } @@ -465,9 +426,6 @@ void Duration::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) } -inline const Duration* Duration::internal_default_instance() { - return &Duration_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 3ed1a6d3..24414d28 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Duration; +class DurationDefaultTypeInternal; +extern DurationDefaultTypeInternal _Duration_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); - -class Duration; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Duration& default_instance(); - static const Duration* internal_default_instance(); + static inline const Duration* internal_default_instance() { + return reinterpret_cast<const Duration*>( + &_Duration_default_instance_); + } void UnsafeArenaSwap(Duration* other); void Swap(Duration* other); // implements Message ---------------------------------------------- - inline Duration* New() const { return New(NULL); } + inline Duration* New() const PROTOBUF_FINAL { return New(NULL); } - Duration* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Duration* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Duration& from); void MergeFrom(const Duration& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Duration* other); - void UnsafeMergeFrom(const Duration& from); protected: explicit Duration(::google::protobuf::Arena* arena); private: @@ -109,19 +117,19 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 seconds = 1; + // int64 seconds = 1; void clear_seconds(); static const int kSecondsFieldNumber = 1; ::google::protobuf::int64 seconds() const; void set_seconds(::google::protobuf::int64 value); - // optional int32 nanos = 2; + // int32 nanos = 2; void clear_nanos(); static const int kNanosFieldNumber = 2; ::google::protobuf::int32 nanos() const; @@ -139,13 +147,10 @@ class LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@prot mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fduration_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fduration_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_default_instance_; - // =================================================================== @@ -154,7 +159,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Duration> Duration_de #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Duration -// optional int64 seconds = 1; +// int64 seconds = 1; inline void Duration::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -168,7 +173,7 @@ inline void Duration::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; inline void Duration::clear_nanos() { nanos_ = 0; } @@ -182,13 +187,11 @@ inline void Duration::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos) } -inline const Duration* Duration::internal_default_instance() { - return &Duration_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/dynamic_message.cc b/src/google/protobuf/dynamic_message.cc index f51bc9d6..d686e01e 100644 --- a/src/google/protobuf/dynamic_message.cc +++ b/src/google/protobuf/dynamic_message.cc @@ -88,11 +88,11 @@ namespace google { namespace protobuf { -using internal::WireFormat; +using internal::DynamicMapField; using internal::ExtensionSet; using internal::GeneratedMessageReflection; +using internal::InternalMetadataWithArena; using internal::MapField; -using internal::DynamicMapField; using internal::ArenaStringPtr; @@ -221,7 +221,7 @@ class DynamicMessage : public Message { int size; int has_bits_offset; int oneof_case_offset; - int unknown_fields_offset; + int internal_metadata_offset; int extensions_offset; // Not owned by the TypeInfo. @@ -231,7 +231,8 @@ class DynamicMessage : public Message { // Warning: The order in which the following pointers are defined is // important (the prototype must be deleted *before* the offsets). - google::protobuf::scoped_array<int> offsets; + google::protobuf::scoped_array<uint32> offsets; + google::protobuf::scoped_array<uint32> has_bits_indices; google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection; // Don't use a scoped_ptr to hold the prototype: the destructor for // DynamicMessage needs to know whether it is the prototype, and does so by @@ -327,14 +328,15 @@ void DynamicMessage::SharedCtor() { // Initialize oneof cases. for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) { - new(OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i)) + new (OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i)) uint32(0); } - new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet; + new (OffsetToPointer(type_info_->internal_metadata_offset)) + InternalMetadataWithArena; if (type_info_->extensions_offset != -1) { - new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; + new (OffsetToPointer(type_info_->extensions_offset)) ExtensionSet; } for (int i = 0; i < descriptor->field_count(); i++) { @@ -379,10 +381,10 @@ void DynamicMessage::SharedCtor() { if (is_prototype()) { default_value = &field->default_value_string(); } else { - default_value = - &(reinterpret_cast<const ArenaStringPtr*>( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i]))->Get(NULL)); + default_value = &(reinterpret_cast<const ArenaStringPtr*>( + type_info_->prototype->OffsetToPointer( + type_info_->offsets[i])) + ->Get()); } ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr(); asp->UnsafeSetDefault(default_value); @@ -413,8 +415,9 @@ void DynamicMessage::SharedCtor() { DynamicMessage::~DynamicMessage() { const Descriptor* descriptor = type_info_->type; - reinterpret_cast<UnknownFieldSet*>( - OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet(); + reinterpret_cast<InternalMetadataWithArena*>( + OffsetToPointer(type_info_->internal_metadata_offset)) + ->~InternalMetadataWithArena(); if (type_info_->extensions_offset != -1) { reinterpret_cast<ExtensionSet*>( @@ -445,10 +448,10 @@ DynamicMessage::~DynamicMessage() { case FieldOptions::STRING: { const ::std::string* default_value = &(reinterpret_cast<const ArenaStringPtr*>( - reinterpret_cast<uint8*>( - type_info_->default_oneof_instance) - + type_info_->offsets[i]) - ->Get(NULL)); + reinterpret_cast<uint8*>( + type_info_->default_oneof_instance) + + type_info_->offsets[i]) + ->Get()); reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( default_value, NULL); break; @@ -506,8 +509,9 @@ DynamicMessage::~DynamicMessage() { case FieldOptions::STRING: { const ::std::string* default_value = &(reinterpret_cast<const ArenaStringPtr*>( - type_info_->prototype->OffsetToPointer( - type_info_->offsets[i]))->Get(NULL)); + type_info_->prototype->OffsetToPointer( + type_info_->offsets[i])) + ->Get()); reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy( default_value, NULL); break; @@ -649,7 +653,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( // or not that field is set. // Compute size and offsets. - int* offsets = new int[type->field_count() + type->oneof_decl_count()]; + uint32* offsets = + new uint32[type->field_count() + type->oneof_decl_count()]; type_info->offsets.reset(offsets); // Decide all field offsets by packing in order. @@ -667,6 +672,12 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( DivideRoundingUp(type->field_count(), bitsizeof(uint32)); size += has_bits_array_size * sizeof(uint32); size = AlignOffset(size); + + uint32* has_bits_indices = new uint32[type->field_count()]; + for (int i = 0; i < type->field_count(); i++) { + has_bits_indices[i] = i; + } + type_info->has_bits_indices.reset(has_bits_indices); } // The oneof_case, if any. It is an array of uint32s. @@ -687,6 +698,8 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( } // All the fields. + // + // TODO(b/31226269): Optimize the order of fields to minimize padding. for (int i = 0; i < type->field_count(); i++) { // Make sure field is aligned to avoid bus errors. // Oneof fields do not use any space. @@ -705,10 +718,10 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( size += kMaxOneofUnionSize; } - // Add the UnknownFieldSet to the end. + // Add the InternalMetadataWithArena to the end. size = AlignOffset(size); - type_info->unknown_fields_offset = size; - size += sizeof(UnknownFieldSet); + type_info->internal_metadata_offset = size; + size += sizeof(InternalMetadataWithArena); // Align the final size to make sure no clever allocators think that // alignment is not necessary. @@ -728,6 +741,10 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( DynamicMessage* prototype = new(base) DynamicMessage(type_info); // Construct the reflection object. + + void* default_oneof_instance = NULL; + int oneof_case_offset = -1; + if (type->oneof_decl_count() > 0) { // Compute the size of default oneof instance and offsets of default // oneof fields. @@ -746,19 +763,24 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( ConstructDefaultOneofInstance(type_info->type, type_info->offsets.get(), type_info->default_oneof_instance); - type_info->reflection.reset(new GeneratedMessageReflection( - type_info->type, type_info->prototype, type_info->offsets.get(), - type_info->has_bits_offset, type_info->unknown_fields_offset, - type_info->extensions_offset, type_info->default_oneof_instance, - type_info->oneof_case_offset, type_info->pool, this, type_info->size, - -1 /* arena_offset */)); - } else { - type_info->reflection.reset(new GeneratedMessageReflection( - type_info->type, type_info->prototype, type_info->offsets.get(), - type_info->has_bits_offset, type_info->unknown_fields_offset, - type_info->extensions_offset, type_info->pool, this, type_info->size, - -1 /* arena_offset */)); + default_oneof_instance = type_info->default_oneof_instance; + oneof_case_offset = type_info->oneof_case_offset; } + + internal::ReflectionSchema schema = { + type_info->prototype, + type_info->offsets.get(), + type_info->has_bits_indices.get(), + type_info->has_bits_offset, + type_info->internal_metadata_offset, + type_info->extensions_offset, + default_oneof_instance, + oneof_case_offset, + type_info->size}; + + type_info->reflection.reset(new GeneratedMessageReflection( + type_info->type, schema, type_info->pool, this)); + // Cross link prototypes. prototype->CrossLinkPrototypes(); @@ -767,7 +789,7 @@ const Message* DynamicMessageFactory::GetPrototypeNoLock( void DynamicMessageFactory::ConstructDefaultOneofInstance( const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance) { for (int i = 0; i < type->oneof_decl_count(); i++) { for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { @@ -813,7 +835,7 @@ void DynamicMessageFactory::ConstructDefaultOneofInstance( void DynamicMessageFactory::DeleteDefaultOneofInstance( const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance) { for (int i = 0; i < type->oneof_decl_count(); i++) { for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) { diff --git a/src/google/protobuf/dynamic_message.h b/src/google/protobuf/dynamic_message.h index f74cd7dd..7ff80f26 100644 --- a/src/google/protobuf/dynamic_message.h +++ b/src/google/protobuf/dynamic_message.h @@ -136,11 +136,11 @@ class LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory { // Construct default oneof instance for reflection usage if oneof // is defined. static void ConstructDefaultOneofInstance(const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance); // Delete default oneof instance. Called by ~DynamicMessageFactory. static void DeleteDefaultOneofInstance(const Descriptor* type, - const int offsets[], + const uint32 offsets[], void* default_oneof_instance); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index f19bf2a6..19f4aefe 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -19,82 +19,85 @@ namespace google { namespace protobuf { +class EmptyDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Empty> {}; +EmptyDefaultTypeInternal _Empty_default_instance_; namespace { -const ::google::protobuf::Descriptor* Empty_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Empty_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/empty.proto"); - GOOGLE_CHECK(file != NULL); - Empty_descriptor_ = file->message_type(0); - static const int Empty_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ }; - Empty_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Empty_descriptor_, - Empty::internal_default_instance(), - Empty_offsets_, - -1, - -1, - -1, - sizeof(Empty), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Empty)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Empty_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/empty.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fempty_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Empty_descriptor_, Empty::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() { - Empty_default_instance_.Shutdown(); - delete Empty_reflection_; + _Empty_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Empty_default_instance_.DefaultConstruct(); - Empty_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Empty_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + static const char descriptor[] = { + "\n\033google/protobuf/empty.proto\022\017google.pr" + "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" + "EmptyProtoP\001Z\'github.com/golang/protobuf" + "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" + ".WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\033google/protobuf/empty.proto\022\017google.pr" - "otobuf\"\007\n\005EmptyBv\n\023com.google.protobufB\n" - "EmptyProtoP\001Z\'github.com/golang/protobuf" - "/ptypes/empty\370\001\001\242\002\003GPB\252\002\036Google.Protobuf" - ".WellKnownTypesb\006proto3", 183); + descriptor, 183); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/empty.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto); @@ -112,16 +115,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -129,7 +122,9 @@ static void MergeFromFail(int line) { Empty::Empty() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Empty) } @@ -143,15 +138,11 @@ Empty::Empty(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty) } - -void Empty::InitAsDefaultInstance() { -} - Empty::Empty(const Empty& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty) } @@ -185,7 +176,7 @@ void Empty::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Empty::descriptor() { protobuf_AssignDescriptorsOnce(); - return Empty_descriptor_; + return file_level_metadata[0].descriptor; } const Empty& Empty::default_instance() { @@ -193,8 +184,6 @@ const Empty& Empty::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_; - Empty* Empty::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Empty>(arena); } @@ -209,7 +198,7 @@ bool Empty::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Empty) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; handle_unusual: @@ -256,7 +245,7 @@ size_t Empty::ByteSizeLong() const { void Empty::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Empty* source = ::google::protobuf::internal::DynamicCastToGenerated<const Empty>( &from); @@ -265,21 +254,14 @@ void Empty::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Empty::MergeFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Empty::UnsafeMergeFrom(const Empty& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); } void Empty::CopyFrom(const ::google::protobuf::Message& from) { @@ -293,11 +275,10 @@ void Empty::CopyFrom(const Empty& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Empty::IsInitialized() const { - return true; } @@ -306,10 +287,13 @@ void Empty::Swap(Empty* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Empty temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Empty* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Empty::UnsafeArenaSwap(Empty* other) { @@ -318,24 +302,17 @@ void Empty::UnsafeArenaSwap(Empty* other) { InternalSwap(other); } void Empty::InternalSwap(Empty* other) { - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Empty::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Empty_descriptor_; - metadata.reflection = Empty_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Empty -inline const Empty* Empty::internal_default_instance() { - return &Empty_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 29309366..e2aca67d 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Empty; +class EmptyDefaultTypeInternal; +extern EmptyDefaultTypeInternal _Empty_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); - -class Empty; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Empty& default_instance(); - static const Empty* internal_default_instance(); + static inline const Empty* internal_default_instance() { + return reinterpret_cast<const Empty*>( + &_Empty_default_instance_); + } void UnsafeArenaSwap(Empty* other); void Swap(Empty* other); // implements Message ---------------------------------------------- - inline Empty* New() const { return New(NULL); } + inline Empty* New() const PROTOBUF_FINAL { return New(NULL); } - Empty* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Empty* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Empty& from); void MergeFrom(const Empty& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Empty* other); - void UnsafeMergeFrom(const Empty& from); protected: explicit Empty(::google::protobuf::Arena* arena); private: @@ -109,7 +117,7 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -125,13 +133,10 @@ class LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fempty_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fempty_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_instance_; - // =================================================================== @@ -140,13 +145,11 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Empty> Empty_default_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Empty -inline const Empty* Empty::internal_default_instance() { - return &Empty_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc index ad164e3e..955c079b 100644 --- a/src/google/protobuf/extension_set.cc +++ b/src/google/protobuf/extension_set.cc @@ -76,7 +76,7 @@ inline bool is_packable(WireFormatLite::WireType type) { } // Registry stuff. -typedef hash_map<pair<const MessageLite*, int>, +typedef hash_map<std::pair<const MessageLite*, int>, ExtensionInfo> ExtensionRegistry; ExtensionRegistry* registry_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_); @@ -1371,7 +1371,7 @@ size_t ExtensionSet::ByteSize() const { bool ExtensionSet::MaybeNewExtension(int number, const FieldDescriptor* descriptor, Extension** result) { - pair<ExtensionMap::iterator, bool> insert_result = + std::pair<ExtensionMap::iterator, bool> insert_result = extensions_.insert(std::make_pair(number, Extension())); *result = &insert_result.first->second; (*result)->descriptor = descriptor; diff --git a/src/google/protobuf/extension_set_heavy.cc b/src/google/protobuf/extension_set_heavy.cc index 1bbc8fef..2c37ade9 100644 --- a/src/google/protobuf/extension_set_heavy.cc +++ b/src/google/protobuf/extension_set_heavy.cc @@ -656,7 +656,7 @@ bool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input, string message_data; while (true) { - const uint32 tag = input->ReadTag(); + const uint32 tag = input->ReadTagNoLastTag(); if (tag == 0) return false; switch (tag) { diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index a70a2ff6..d6b823c0 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -331,7 +331,7 @@ TEST(ExtensionSetTest, SwapExtension) { unittest::TestAllExtensions message2; TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; // Swap empty fields. const Reflection* reflection = message1.GetReflection(); @@ -363,7 +363,7 @@ TEST(ExtensionSetTest, SwapExtensionWithEmpty) { TestUtil::SetAllExtensions(&message3); const Reflection* reflection = message3.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message3, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -380,7 +380,7 @@ TEST(ExtensionSetTest, SwapExtensionBothFull) { TestUtil::SetAllExtensions(&message2); const Reflection* reflection = message1.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -490,7 +490,7 @@ TEST(ExtensionSetTest, SwapFieldsOfExtensionBothFullWithArena) { TestUtil::SetAllExtensions(message2); const Reflection* reflection = message1->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message1, &fields); reflection->SwapFields(message1, message2, fields); TestUtil::ExpectAllExtensionsSet(*message1); @@ -504,7 +504,7 @@ TEST(ExtensionSetTest, SwapExtensionWithSelf) { TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message1, fields); diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 5d80d297..b7925b88 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -19,84 +19,87 @@ namespace google { namespace protobuf { +class FieldMaskDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> {}; +FieldMaskDefaultTypeInternal _FieldMask_default_instance_; namespace { -const ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FieldMask_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/field_mask.proto"); - GOOGLE_CHECK(file != NULL); - FieldMask_descriptor_ = file->message_type(0); - static const int FieldMask_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_), }; - FieldMask_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FieldMask_descriptor_, - FieldMask::internal_default_instance(), - FieldMask_offsets_, - -1, - -1, - -1, - sizeof(FieldMask), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(FieldMask)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_FieldMask_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/field_mask.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FieldMask_descriptor_, FieldMask::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() { - FieldMask_default_instance_.Shutdown(); - delete FieldMask_reflection_; + _FieldMask_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::internal::GetEmptyString(); - FieldMask_default_instance_.DefaultConstruct(); - FieldMask_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _FieldMask_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + static const char descriptor[] = { + "\n google/protobuf/field_mask.proto\022\017goog" + "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" + "\211\001\n\023com.google.protobufB\016FieldMaskProtoP" + "\001Z9google.golang.org/genproto/protobuf/f" + "ield_mask;field_mask\242\002\003GPB\252\002\036Google.Prot" + "obuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n google/protobuf/field_mask.proto\022\017goog" - "le.protobuf\"\032\n\tFieldMask\022\r\n\005paths\030\001 \003(\tB" - "N\n\023com.google.protobufB\016FieldMaskProtoP\001" - "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" - "\006proto3", 167); + descriptor, 227); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/field_mask.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto); @@ -114,16 +117,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -132,19 +125,18 @@ const int FieldMask::kPathsFieldNumber; FieldMask::FieldMask() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FieldMask) } - -void FieldMask::InitAsDefaultInstance() { -} - FieldMask::FieldMask(const FieldMask& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + paths_(from.paths_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask) } @@ -167,7 +159,7 @@ void FieldMask::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FieldMask::descriptor() { protobuf_AssignDescriptorsOnce(); - return FieldMask_descriptor_; + return file_level_metadata[0].descriptor; } const FieldMask& FieldMask::default_instance() { @@ -175,8 +167,6 @@ const FieldMask& FieldMask::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_; - FieldMask* FieldMask::New(::google::protobuf::Arena* arena) const { FieldMask* n = new FieldMask; if (arena != NULL) { @@ -196,14 +186,13 @@ bool FieldMask::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FieldMask) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated string paths = 1; case 1: { - if (tag == 10) { - parse_paths: + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_paths())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,8 +203,6 @@ bool FieldMask::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_paths; - if (input->ExpectAtEnd()) goto success; break; } @@ -295,7 +282,7 @@ size_t FieldMask::ByteSizeLong() const { void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FieldMask* source = ::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>( &from); @@ -304,22 +291,15 @@ void FieldMask::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FieldMask::MergeFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FieldMask::UnsafeMergeFrom(const FieldMask& from) { - GOOGLE_DCHECK(&from != this); - paths_.UnsafeMergeFrom(from.paths_); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + paths_.MergeFrom(from.paths_); } void FieldMask::CopyFrom(const ::google::protobuf::Message& from) { @@ -333,11 +313,10 @@ void FieldMask::CopyFrom(const FieldMask& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FieldMask::IsInitialized() const { - return true; } @@ -347,16 +326,12 @@ void FieldMask::Swap(FieldMask* other) { } void FieldMask::InternalSwap(FieldMask* other) { paths_.UnsafeArenaSwap(&other->paths_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FieldMask::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FieldMask_descriptor_; - metadata.reflection = FieldMask_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -417,9 +392,6 @@ FieldMask::mutable_paths() { return &paths_; } -inline const FieldMask* FieldMask::internal_default_instance() { - return &FieldMask_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 17cb6bbf..6b4c5f99 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class FieldMask; +class FieldMaskDefaultTypeInternal; +extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); - -class FieldMask; // =================================================================== @@ -57,49 +60,52 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro static const ::google::protobuf::Descriptor* descriptor(); static const FieldMask& default_instance(); - static const FieldMask* internal_default_instance(); + static inline const FieldMask* internal_default_instance() { + return reinterpret_cast<const FieldMask*>( + &_FieldMask_default_instance_); + } void Swap(FieldMask* other); // implements Message ---------------------------------------------- - inline FieldMask* New() const { return New(NULL); } + inline FieldMask* New() const PROTOBUF_FINAL { return New(NULL); } - FieldMask* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FieldMask* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FieldMask& from); void MergeFrom(const FieldMask& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FieldMask* other); - void UnsafeMergeFrom(const FieldMask& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -129,13 +135,10 @@ class LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ffield_5fmask_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FieldMask> FieldMask_default_instance_; - // =================================================================== @@ -199,13 +202,11 @@ FieldMask::mutable_paths() { return &paths_; } -inline const FieldMask* FieldMask::internal_default_instance() { - return &FieldMask_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/field_mask.proto b/src/google/protobuf/field_mask.proto index b6d32a79..c68d247c 100644 --- a/src/google/protobuf/field_mask.proto +++ b/src/google/protobuf/field_mask.proto @@ -37,6 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "FieldMaskProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/field_mask;field_mask"; // `FieldMask` represents a set of symbolic field paths, for example: // diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index 6f418433..08742232 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -44,6 +44,7 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/map_field.h> #include <google/protobuf/repeated_field.h> +// #include "google/protobuf/bridge/compatibility_mode_support.h" #define GOOGLE_PROTOBUF_HAS_ONEOF @@ -84,6 +85,22 @@ inline bool SupportsArenas(const Descriptor* descriptor) { namespace { +template <class To> +To* GetPointerAtOffset(Message* message, uint32 offset) { + return reinterpret_cast<To*>(reinterpret_cast<char*>(message) + offset); +} + +template <class To> +const To* GetConstPointerAtOffset(const Message* message, uint32 offset) { + return reinterpret_cast<const To*>(reinterpret_cast<const char*>(message) + + offset); +} + +template <class To> +const To& GetConstRefAtOffset(const Message& message, uint32 offset) { + return *GetConstPointerAtOffset<To>(&message, offset); +} + void ReportReflectionUsageError( const Descriptor* descriptor, const FieldDescriptor* field, const char* method, const char* description) { @@ -173,43 +190,25 @@ static void ReportReflectionUsageEnumTypeError( // =================================================================== GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, const Message* default_instance, - const int offsets[], int has_bits_offset, int unknown_fields_offset, - int extensions_offset, const DescriptorPool* descriptor_pool, - MessageFactory* factory, int object_size, int arena_offset) - : descriptor_(descriptor), - default_instance_(default_instance), - offsets_(offsets), - has_bits_offset_(has_bits_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_(arena_offset), - object_size_(object_size), - descriptor_pool_((descriptor_pool == NULL) - ? DescriptorPool::generated_pool() - : descriptor_pool), - message_factory_(factory) {} - -GeneratedMessageReflection::GeneratedMessageReflection( - const Descriptor* descriptor, const Message* default_instance, - const int offsets[], int has_bits_offset, int unknown_fields_offset, - int extensions_offset, const void* default_oneof_instance, - int oneof_case_offset, const DescriptorPool* descriptor_pool, - MessageFactory* factory, int object_size, int arena_offset) + const Descriptor* descriptor, const ReflectionSchema& schema, + const DescriptorPool* pool, MessageFactory* factory) : descriptor_(descriptor), - default_instance_(default_instance), - default_oneof_instance_(default_oneof_instance), - offsets_(offsets), - has_bits_offset_(has_bits_offset), - oneof_case_offset_(oneof_case_offset), - unknown_fields_offset_(unknown_fields_offset), - extensions_offset_(extensions_offset), - arena_offset_(arena_offset), - object_size_(object_size), - descriptor_pool_((descriptor_pool == NULL) - ? DescriptorPool::generated_pool() - : descriptor_pool), - message_factory_(factory) {} + schema_(schema), + descriptor_pool_((pool == NULL) ? DescriptorPool::generated_pool() + : pool), + message_factory_(factory), + // TODO(haberman) remove this when upb is using our table driven. + default_instance_(schema_.default_instance_), + default_oneof_instance_(schema_.default_oneof_instance_), + offsets_(schema_.offsets_), + has_bits_indices_(schema_.has_bit_indices_), + has_bits_offset_(schema_.has_bits_offset_), + oneof_case_offset_(schema_.oneof_case_offset_), + unknown_fields_offset_(-1), + extensions_offset_(schema_.extensions_offset_), + arena_offset_(schema_.metadata_offset_), + object_size_(schema_.object_size_) { +} GeneratedMessageReflection::~GeneratedMessageReflection() {} @@ -236,39 +235,33 @@ const UnknownFieldSet& GetEmptyUnknownFieldSet() { const UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields( const Message& message) const { if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) { + // We have to ensure that any mutations made to the return value of + // MutableUnknownFields() are not reflected here. return GetEmptyUnknownFieldSet(); - } - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { + } else { return GetInternalMetadataWithArena(message).unknown_fields(); } - const void* ptr = reinterpret_cast<const uint8*>(&message) + - unknown_fields_offset_; - return *reinterpret_cast<const UnknownFieldSet*>(ptr); } UnknownFieldSet* GeneratedMessageReflection::MutableUnknownFields( Message* message) const { - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { - return MutableInternalMetadataWithArena(message)-> - mutable_unknown_fields(); - } - void* ptr = reinterpret_cast<uint8*>(message) + unknown_fields_offset_; - return reinterpret_cast<UnknownFieldSet*>(ptr); + return MutableInternalMetadataWithArena(message)->mutable_unknown_fields(); } int GeneratedMessageReflection::SpaceUsed(const Message& message) const { // object_size_ already includes the in-memory representation of each field // in the message, so we only need to account for additional memory used by // the fields. - int total_size = object_size_; + int total_size = schema_.GetObjectSize(); total_size += GetUnknownFields(message).SpaceUsedExcludingSelf(); - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { total_size += GetExtensionSet(message).SpaceUsedExcludingSelf(); } - for (int i = 0; i < descriptor_->field_count(); i++) { + const int field_count = descriptor_->field_count(); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { @@ -337,9 +330,9 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const { // the prototype. Only count the string if it has been changed // from the default value. const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + &DefaultRaw<ArenaStringPtr>(field).Get(); const string* ptr = - &GetField<ArenaStringPtr>(message, field).Get(default_ptr); + &GetField<ArenaStringPtr>(message, field).Get(); if (ptr != default_ptr) { // string fields are represented by just a pointer, so also @@ -353,7 +346,7 @@ int GeneratedMessageReflection::SpaceUsed(const Message& message) const { } case FieldDescriptor::CPPTYPE_MESSAGE: - if (&message == default_instance_) { + if (schema_.IsDefaultInstance(message)) { // For singular fields, the prototype just stores a pointer to the // external type's prototype, so there is no extra memory usage. } else { @@ -475,9 +468,9 @@ void GeneratedMessageReflection::SwapField( string1->Swap(string2); } else { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - const string temp = string1->Get(default_ptr); - string1->Set(default_ptr, string2->Get(default_ptr), arena1); + &DefaultRaw<ArenaStringPtr>(field).Get(); + const string temp = string1->Get(); + string1->Set(default_ptr, string2->Get(), arena1); string2->Set(default_ptr, temp, arena2); } } @@ -638,16 +631,16 @@ void GeneratedMessageReflection::Swap( // Slow copy path. // Use our arena as temp space, if available. Message* temp = message1->New(GetArena(message1)); - temp->MergeFrom(*message1); - message1->CopyFrom(*message2); - message2->CopyFrom(*temp); + temp->MergeFrom(*message2); + message2->CopyFrom(*message1); + Swap(message1, temp); if (GetArena(message1) == NULL) { delete temp; } return; } - if (has_bits_offset_ != -1) { + if (schema_.HasHasbits()) { uint32* has_bits1 = MutableHasBits(message1); uint32* has_bits2 = MutableHasBits(message2); int has_bits_size = (descriptor_->field_count() + 31) / 32; @@ -657,18 +650,20 @@ void GeneratedMessageReflection::Swap( } } - for (int i = 0; i < descriptor_->field_count(); i++) { + const int field_count = descriptor_->field_count(); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (!field->containing_oneof()) { SwapField(message1, message2, field); } } - for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { + const int oneof_decl_count = descriptor_->oneof_decl_count(); + for (int i = 0; i < oneof_decl_count; i++) { SwapOneofField(message1, message2, descriptor_->oneof_decl(i)); } - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2)); } @@ -678,7 +673,7 @@ void GeneratedMessageReflection::Swap( void GeneratedMessageReflection::SwapFields( Message* message1, Message* message2, - const vector<const FieldDescriptor*>& fields) const { + const std::vector<const FieldDescriptor*>& fields) const { if (message1 == message2) return; // TODO(kenton): Other Reflection methods should probably check this too. @@ -699,7 +694,8 @@ void GeneratedMessageReflection::SwapFields( std::set<int> swapped_oneof; - for (int i = 0; i < fields.size(); i++) { + const int fields_size = static_cast<int>(fields.size()); + for (int i = 0; i < fields_size; i++) { const FieldDescriptor* field = fields[i]; if (field->is_extension()) { MutableExtensionSet(message1)->SwapExtension( @@ -821,9 +817,9 @@ void GeneratedMessageReflection::ClearField( default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - MutableRaw<ArenaStringPtr>(message, field)->Destroy(default_ptr, - GetArena(message)); + &DefaultRaw<ArenaStringPtr>(field).Get(); + MutableRaw<ArenaStringPtr>(message, field)->SetAllocated( + default_ptr, NULL, GetArena(message)); break; } } @@ -831,7 +827,7 @@ void GeneratedMessageReflection::ClearField( } case FieldDescriptor::CPPTYPE_MESSAGE: - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { // Proto3 does not have has-bits and we need to set a message field // to NULL in order to indicate its un-presence. if (GetArena(message) == NULL) { @@ -1008,28 +1004,35 @@ struct FieldNumberSorter { } }; -inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) { - return ((has_bit_set[index / 32] >> (index % 32)) & static_cast<uint32>(1)) - != 0; +inline bool IsIndexInHasBitSet( + const uint32* has_bit_set, uint32 has_bit_index) { + return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) & + static_cast<uint32>(1)) != 0; } } // namespace void GeneratedMessageReflection::ListFields( const Message& message, - vector<const FieldDescriptor*>* output) const { + std::vector<const FieldDescriptor*>* output) const { output->clear(); // Optimization: The default instance never has any fields set. - if (&message == default_instance_) return; + if (schema_.IsDefaultInstance(message)) return; // Optimization: Avoid calling GetHasBits() and HasOneofField() many times - // within the field loop. - const uint32* const has_bits = GetHasBits(message); - const uint32* const oneof_case_array = reinterpret_cast<const uint32*>( - reinterpret_cast<const uint8*>(&message) + oneof_case_offset_); - - output->reserve(descriptor_->field_count()); - for (int i = 0; i < descriptor_->field_count(); i++) { + // within the field loop. We allow this violation of ReflectionSchema + // encapsulation because this function takes a noticable about of CPU + // fleetwide and properly allowing this optimization through public interfaces + // seems more trouble than it is worth. + const uint32* const has_bits = + schema_.HasHasbits() ? GetHasBits(message) : NULL; + const uint32* const has_bits_indices = schema_.has_bit_indices_; + const uint32* const oneof_case_array = + &GetConstRefAtOffset<uint32>(message, schema_.oneof_case_offset_); + + const int field_count = descriptor_->field_count(); + output->reserve(field_count); + for (int i = 0; i < field_count; i++) { const FieldDescriptor* field = descriptor_->field(i); if (field->is_repeated()) { if (FieldSize(message, field) > 0) { @@ -1044,7 +1047,7 @@ void GeneratedMessageReflection::ListFields( } } else if (has_bits) { // Equivalent to: HasBit(message, field) - if (IsIndexInHasBitSet(has_bits, i)) { + if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) { output->push_back(field); } } else if (HasBit(message, field)) { // Fall back on proto3-style HasBit. @@ -1053,7 +1056,7 @@ void GeneratedMessageReflection::ListFields( } } - if (extensions_offset_ != -1) { + if (schema_.HasExtensionSet()) { GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_, output); } @@ -1147,9 +1150,7 @@ string GeneratedMessageReflection::GetString( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get(default_ptr); + return GetField<ArenaStringPtr>(message, field).Get(); } } @@ -1169,9 +1170,7 @@ const string& GeneratedMessageReflection::GetStringReference( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get(default_ptr); + return GetField<ArenaStringPtr>(message, field).Get(); } } @@ -1192,8 +1191,7 @@ void GeneratedMessageReflection::SetString( switch (field->options().ctype()) { default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + const string* default_ptr = &DefaultRaw<ArenaStringPtr>(field).Get(); if (field->containing_oneof() && !HasOneofField(*message, field)) { ClearOneof(message, field->containing_oneof()); MutableField<ArenaStringPtr>(message, field)->UnsafeSetDefault( @@ -1727,11 +1725,10 @@ void* GeneratedMessageReflection::MutableRawRepeatedField( } else { // Trigger transform for MapField if (IsMapFieldInApi(field)) { - return reinterpret_cast<MapFieldBase*>(reinterpret_cast<uint8*>(message) + - offsets_[field->index()]) + return MutableRawNonOneof<MapFieldBase>(message, field) ->MutableRepeatedField(); } - return reinterpret_cast<uint8*>(message) + offsets_[field->index()]; + return MutableRawNonOneof<void>(message, field); } } @@ -1758,11 +1755,9 @@ const void* GeneratedMessageReflection::GetRawRepeatedField( } else { // Trigger transform for MapField if (IsMapFieldInApi(field)) { - return &(reinterpret_cast<const MapFieldBase*>( - reinterpret_cast<const uint8*>(&message) + - offsets_[field->index()])->GetRepeatedField()); + return &(GetRawNonOneof<MapFieldBase>(message, field).GetRepeatedField()); } - return reinterpret_cast<const uint8*>(&message) + offsets_[field->index()]; + return &GetRawNonOneof<char>(message, field); } } @@ -1844,7 +1839,7 @@ int GeneratedMessageReflection::MapSize( const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const string& name) const { - if (extensions_offset_ == -1) return NULL; + if (!schema_.HasExtensionSet()) return NULL; const FieldDescriptor* result = descriptor_pool_->FindExtensionByName(name); if (result != NULL && result->containing_type() == descriptor_) { @@ -1856,7 +1851,8 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const Descriptor* type = descriptor_pool_->FindMessageTypeByName(name); if (type != NULL) { // Look for a matching extension in the foreign type's scope. - for (int i = 0; i < type->extension_count(); i++) { + const int type_extension_count = type->extension_count(); + for (int i = 0; i < type_extension_count; i++) { const FieldDescriptor* extension = type->extension(i); if (extension->containing_type() == descriptor_ && extension->type() == FieldDescriptor::TYPE_MESSAGE && @@ -1874,7 +1870,7 @@ const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName( const FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByNumber( int number) const { - if (extensions_offset_ == -1) return NULL; + if (!schema_.HasExtensionSet()) return NULL; return descriptor_pool_->FindExtensionByNumber(descriptor_, number); } @@ -1887,202 +1883,176 @@ bool GeneratedMessageReflection::SupportsUnknownEnumValues() const { // These simple template accessors obtain pointers (or references) to // the given field. + +template <class Type> +const Type& GeneratedMessageReflection::GetRawNonOneof( + const Message& message, const FieldDescriptor* field) const { + return GetConstRefAtOffset<Type>(message, + schema_.GetFieldOffsetNonOneof(field)); +} + +template <class Type> +Type* GeneratedMessageReflection::MutableRawNonOneof( + Message* message, const FieldDescriptor* field) const { + return GetPointerAtOffset<Type>(message, + schema_.GetFieldOffsetNonOneof(field)); +} + template <typename Type> -inline const Type& GeneratedMessageReflection::GetRaw( +const Type& GeneratedMessageReflection::GetRaw( const Message& message, const FieldDescriptor* field) const { if (field->containing_oneof() && !HasOneofField(message, field)) { return DefaultRaw<Type>(field); } - int index = field->containing_oneof() ? - descriptor_->field_count() + field->containing_oneof()->index() : - field->index(); - const void* ptr = reinterpret_cast<const uint8*>(&message) + - offsets_[index]; - return *reinterpret_cast<const Type*>(ptr); + return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field)); } template <typename Type> -inline Type* GeneratedMessageReflection::MutableRaw( - Message* message, const FieldDescriptor* field) const { - int index = field->containing_oneof() ? - descriptor_->field_count() + field->containing_oneof()->index() : - field->index(); - void* ptr = reinterpret_cast<uint8*>(message) + offsets_[index]; - return reinterpret_cast<Type*>(ptr); +Type* GeneratedMessageReflection::MutableRaw(Message* message, + const FieldDescriptor* field) const { + return GetPointerAtOffset<Type>(message, schema_.GetFieldOffset(field)); } -template <typename Type> -inline const Type& GeneratedMessageReflection::DefaultRaw( - const FieldDescriptor* field) const { - const void* ptr = field->containing_oneof() ? - reinterpret_cast<const uint8*>(default_oneof_instance_) + - offsets_[field->index()] : - reinterpret_cast<const uint8*>(default_instance_) + - offsets_[field->index()]; - return *reinterpret_cast<const Type*>(ptr); -} inline const uint32* GeneratedMessageReflection::GetHasBits( const Message& message) const { - if (has_bits_offset_ == -1) { // proto3 with no has-bits. - return NULL; - } - const void* ptr = reinterpret_cast<const uint8*>(&message) + has_bits_offset_; - return reinterpret_cast<const uint32*>(ptr); + GOOGLE_DCHECK(schema_.HasHasbits()); + return &GetConstRefAtOffset<uint32>(message, schema_.HasBitsOffset()); } + inline uint32* GeneratedMessageReflection::MutableHasBits( Message* message) const { - if (has_bits_offset_ == -1) { - return NULL; - } - void* ptr = reinterpret_cast<uint8*>(message) + has_bits_offset_; - return reinterpret_cast<uint32*>(ptr); + GOOGLE_DCHECK(schema_.HasHasbits()); + return GetPointerAtOffset<uint32>(message, schema_.HasBitsOffset()); } inline uint32 GeneratedMessageReflection::GetOneofCase( - const Message& message, - const OneofDescriptor* oneof_descriptor) const { - const void* ptr = reinterpret_cast<const uint8*>(&message) - + oneof_case_offset_; - return reinterpret_cast<const uint32*>(ptr)[oneof_descriptor->index()]; + const Message& message, const OneofDescriptor* oneof_descriptor) const { + return GetConstRefAtOffset<uint32>( + message, schema_.GetOneofCaseOffset(oneof_descriptor)); } inline uint32* GeneratedMessageReflection::MutableOneofCase( - Message* message, - const OneofDescriptor* oneof_descriptor) const { - void* ptr = reinterpret_cast<uint8*>(message) + oneof_case_offset_; - return &(reinterpret_cast<uint32*>(ptr)[oneof_descriptor->index()]); + Message* message, const OneofDescriptor* oneof_descriptor) const { + return GetPointerAtOffset<uint32>( + message, schema_.GetOneofCaseOffset(oneof_descriptor)); } inline const ExtensionSet& GeneratedMessageReflection::GetExtensionSet( const Message& message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - const void* ptr = reinterpret_cast<const uint8*>(&message) + - extensions_offset_; - return *reinterpret_cast<const ExtensionSet*>(ptr); + return GetConstRefAtOffset<ExtensionSet>(message, + schema_.GetExtensionSetOffset()); } + inline ExtensionSet* GeneratedMessageReflection::MutableExtensionSet( Message* message) const { - GOOGLE_DCHECK_NE(extensions_offset_, -1); - void* ptr = reinterpret_cast<uint8*>(message) + extensions_offset_; - return reinterpret_cast<ExtensionSet*>(ptr); + return GetPointerAtOffset<ExtensionSet>(message, + schema_.GetExtensionSetOffset()); } inline Arena* GeneratedMessageReflection::GetArena(Message* message) const { - if (arena_offset_ == kNoArenaPointer) { - return NULL; - } - - if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) { - // zero-overhead arena pointer overloading UnknownFields - return GetInternalMetadataWithArena(*message).arena(); - } - - // Baseline case: message class has a dedicated arena pointer. - void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_; - return *reinterpret_cast<Arena**>(ptr); + return GetInternalMetadataWithArena(*message).arena(); } inline const InternalMetadataWithArena& GeneratedMessageReflection::GetInternalMetadataWithArena( const Message& message) const { - const void* ptr = reinterpret_cast<const uint8*>(&message) + arena_offset_; - return *reinterpret_cast<const InternalMetadataWithArena*>(ptr); + return GetConstRefAtOffset<InternalMetadataWithArena>( + message, schema_.GetMetadataOffset()); } inline InternalMetadataWithArena* GeneratedMessageReflection::MutableInternalMetadataWithArena( Message* message) const { - void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_; - return reinterpret_cast<InternalMetadataWithArena*>(ptr); + return GetPointerAtOffset<InternalMetadataWithArena>( + message, schema_.GetMetadataOffset()); } -inline bool -GeneratedMessageReflection::GetIsDefaultInstance( - const Message& message) const { - return &message == default_instance_; +template <typename Type> +inline const Type& GeneratedMessageReflection::DefaultRaw( + const FieldDescriptor* field) const { + return *reinterpret_cast<const Type*>(schema_.GetFieldDefault(field)); } // Simple accessors for manipulating has_bits_. inline bool GeneratedMessageReflection::HasBit( const Message& message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { - // proto3: no has-bits. All fields present except messages, which are - // present only if their message-field pointer is non-NULL. - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - return !GetIsDefaultInstance(message) && - GetRaw<const Message*>(message, field) != NULL; - } else { - // Non-message field (and non-oneof, since that was handled in HasField() - // before calling us), and singular (again, checked in HasField). So, this - // field must be a scalar. - - // Scalar primitive (numeric or string/bytes) fields are present if - // their value is non-zero (numeric) or non-empty (string/bytes). N.B.: - // we must use this definition here, rather than the "scalar fields - // always present" in the proto3 docs, because MergeFrom() semantics - // require presence as "present on wire", and reflection-based merge - // (which uses HasField()) needs to be consistent with this. - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_STRING: - switch (field->options().ctype()) { - default: { - const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); - return GetField<ArenaStringPtr>(message, field).Get( - default_ptr).size() > 0; - } + if (schema_.HasHasbits()) { + return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field)); + } + + // proto3: no has-bits. All fields present except messages, which are + // present only if their message-field pointer is non-NULL. + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + return !schema_.IsDefaultInstance(message) && + GetRaw<const Message*>(message, field) != NULL; + } else { + // Non-message field (and non-oneof, since that was handled in HasField() + // before calling us), and singular (again, checked in HasField). So, this + // field must be a scalar. + + // Scalar primitive (numeric or string/bytes) fields are present if + // their value is non-zero (numeric) or non-empty (string/bytes). N.B.: + // we must use this definition here, rather than the "scalar fields + // always present" in the proto3 docs, because MergeFrom() semantics + // require presence as "present on wire", and reflection-based merge + // (which uses HasField()) needs to be consistent with this. + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_STRING: + switch (field->options().ctype()) { + default: { + return GetField<ArenaStringPtr>(message, field).Get().size() > 0; } - return false; - case FieldDescriptor::CPPTYPE_BOOL: - return GetRaw<bool>(message, field) != false; - case FieldDescriptor::CPPTYPE_INT32: - return GetRaw<int32>(message, field) != 0; - case FieldDescriptor::CPPTYPE_INT64: - return GetRaw<int64>(message, field) != 0; - case FieldDescriptor::CPPTYPE_UINT32: - return GetRaw<uint32>(message, field) != 0; - case FieldDescriptor::CPPTYPE_UINT64: - return GetRaw<uint64>(message, field) != 0; - case FieldDescriptor::CPPTYPE_FLOAT: - return GetRaw<float>(message, field) != 0.0; - case FieldDescriptor::CPPTYPE_DOUBLE: - return GetRaw<double>(message, field) != 0.0; - case FieldDescriptor::CPPTYPE_ENUM: - return GetRaw<int>(message, field) != 0; - case FieldDescriptor::CPPTYPE_MESSAGE: - // handled above; avoid warning - GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit()."; - break; - } + } + return false; + case FieldDescriptor::CPPTYPE_BOOL: + return GetRaw<bool>(message, field) != false; + case FieldDescriptor::CPPTYPE_INT32: + return GetRaw<int32>(message, field) != 0; + case FieldDescriptor::CPPTYPE_INT64: + return GetRaw<int64>(message, field) != 0; + case FieldDescriptor::CPPTYPE_UINT32: + return GetRaw<uint32>(message, field) != 0; + case FieldDescriptor::CPPTYPE_UINT64: + return GetRaw<uint64>(message, field) != 0; + case FieldDescriptor::CPPTYPE_FLOAT: + return GetRaw<float>(message, field) != 0.0; + case FieldDescriptor::CPPTYPE_DOUBLE: + return GetRaw<double>(message, field) != 0.0; + case FieldDescriptor::CPPTYPE_ENUM: + return GetRaw<int>(message, field) != 0; + case FieldDescriptor::CPPTYPE_MESSAGE: + // handled above; avoid warning + break; } + GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit()."; + return false; } - return IsIndexInHasBitSet(GetHasBits(message), field->index()); } inline void GeneratedMessageReflection::SetBit( Message* message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } - const uint32 index = static_cast<uint32>(field->index()); + const uint32 index = schema_.HasBitIndex(field); MutableHasBits(message)[index / 32] |= (static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::ClearBit( Message* message, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } - const uint32 index = static_cast<uint32>(field->index()); + const uint32 index = schema_.HasBitIndex(field); MutableHasBits(message)[index / 32] &= ~(static_cast<uint32>(1) << (index % 32)); } inline void GeneratedMessageReflection::SwapBit( Message* message1, Message* message2, const FieldDescriptor* field) const { - if (has_bits_offset_ == -1) { + if (!schema_.HasHasbits()) { return; } bool temp_has_bit = HasBit(*message1, field); @@ -2135,7 +2105,7 @@ inline void GeneratedMessageReflection::ClearOneof( default: // TODO(kenton): Support other string reps. case FieldOptions::STRING: { const string* default_ptr = - &DefaultRaw<ArenaStringPtr>(field).Get(NULL); + &DefaultRaw<ArenaStringPtr>(field).Get(); MutableField<ArenaStringPtr>(message, field)-> Destroy(default_ptr, GetArena(message)); break; @@ -2247,7 +2217,7 @@ void* GeneratedMessageReflection::RepeatedFieldData( return MutableExtensionSet(message)->MutableRawRepeatedField( field->number(), field->type(), field->is_packed(), field); } else { - return reinterpret_cast<uint8*>(message) + offsets_[field->index()]; + return MutableRawNonOneof<char>(message, field); } } @@ -2259,42 +2229,165 @@ MapFieldBase* GeneratedMessageReflection::MapData( return MutableRaw<MapFieldBase>(message, field); } -GeneratedMessageReflection* -GeneratedMessageReflection::NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const void* default_oneof_instance, - int oneof_case_offset, - int object_size, - int arena_offset, - int is_default_instance_offset) { - return new GeneratedMessageReflection( - descriptor, default_instance, offsets, has_bits_offset, - unknown_fields_offset, extensions_offset, default_oneof_instance, - oneof_case_offset, DescriptorPool::generated_pool(), - MessageFactory::generated_factory(), object_size, arena_offset); -} - -GeneratedMessageReflection* -GeneratedMessageReflection::NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - int object_size, - int arena_offset, - int is_default_instance_offset) { - return new GeneratedMessageReflection( - descriptor, default_instance, offsets, has_bits_offset, - unknown_fields_offset, extensions_offset, - DescriptorPool::generated_pool(), MessageFactory::generated_factory(), - object_size, arena_offset); +namespace { + +// Helper function to transform migration schema into reflection schema. +ReflectionSchema MigrationToReflectionSchema( + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MigrationSchema migration_schema) { + ReflectionSchema result; + result.default_instance_ = default_instance_data->default_instance; + // First 5 offsets are offsets to the special fields. The following offsets + // are the proto fields. + result.offsets_ = offsets + migration_schema.offsets_index + 4; + result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index; + result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0]; + result.metadata_offset_ = offsets[migration_schema.offsets_index + 1]; + result.extensions_offset_ = offsets[migration_schema.offsets_index + 2]; + result.default_oneof_instance_ = default_instance_data->default_oneof_instance; + result.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3]; + result.object_size_ = migration_schema.object_size; + return result; +} + +ReflectionSchema MigrationToReflectionSchema( + const DefaultInstanceData* default_instance_data, const uint32* offsets, + ReflectionSchema schema) { + return schema; +} + +template<typename Schema> +class AssignDescriptorsHelper { + public: + AssignDescriptorsHelper(MessageFactory* factory, + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const Schema* schemas, + const DefaultInstanceData* default_instance_data, + const uint32* offsets) + : factory_(factory), + file_level_metadata_(file_level_metadata), + file_level_enum_descriptors_(file_level_enum_descriptors), + schemas_(schemas), + default_instance_data_(default_instance_data), + offsets_(offsets) {} + + void AssignMessageDescriptor(const Descriptor* descriptor) { + for (int i = 0; i < descriptor->nested_type_count(); i++) { + AssignMessageDescriptor(descriptor->nested_type(i)); + } + + file_level_metadata_->descriptor = descriptor; + + if (!descriptor->options().map_entry()) { + // Only set reflection for non map types. + file_level_metadata_->reflection = new GeneratedMessageReflection( + descriptor, MigrationToReflectionSchema(default_instance_data_++, + offsets_, *schemas_), + ::google::protobuf::DescriptorPool::generated_pool(), factory_); + for (int i = 0; i < descriptor->enum_type_count(); i++) { + AssignEnumDescriptor(descriptor->enum_type(i)); + } + schemas_++; + } + file_level_metadata_++; + } + + void AssignEnumDescriptor(const EnumDescriptor* descriptor) { + *file_level_enum_descriptors_ = descriptor; + file_level_enum_descriptors_++; + } + + private: + MessageFactory* factory_; + Metadata* file_level_metadata_; + const EnumDescriptor** file_level_enum_descriptors_; + const Schema* schemas_; + const DefaultInstanceData* default_instance_data_; + const uint32* offsets_; +}; + +} // namespace + +void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors) { + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename); + GOOGLE_CHECK(file != NULL); + + if (!factory) factory = MessageFactory::generated_factory(); + + AssignDescriptorsHelper<MigrationSchema> helper(factory, file_level_metadata, + file_level_enum_descriptors, schemas, + default_instance_data, offsets); + + for (int i = 0; i < file->message_type_count(); i++) { + helper.AssignMessageDescriptor(file->message_type(i)); + } + + for (int i = 0; i < file->enum_type_count(); i++) { + helper.AssignEnumDescriptor(file->enum_type(i)); + } + if (file->options().cc_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + file_level_service_descriptors[i] = file->service(i); + } + } +} + +void AssignDescriptors( + const string& filename, const ReflectionSchema* schemas, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors) { + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(filename); + GOOGLE_CHECK(file != NULL); + + if (!factory) factory = MessageFactory::generated_factory(); + + AssignDescriptorsHelper<ReflectionSchema> helper(factory, file_level_metadata, + file_level_enum_descriptors, schemas, + NULL, NULL); + + for (int i = 0; i < file->message_type_count(); i++) { + helper.AssignMessageDescriptor(file->message_type(i)); + } + + for (int i = 0; i < file->enum_type_count(); i++) { + helper.AssignEnumDescriptor(file->enum_type(i)); + } + if (file->options().cc_generic_services()) { + for (int i = 0; i < file->service_count(); i++) { + file_level_service_descriptors[i] = file->service(i); + } + } +} + +void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) { + for (int i = 0; i < size; i++) { + const GeneratedMessageReflection* reflection = + static_cast<const GeneratedMessageReflection*>( + file_level_metadata[i].reflection); + if (reflection) { + // It's not a map type + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + file_level_metadata[i].descriptor, + reflection->schema_.default_instance_); + } + } +} + +void RegisterAllTypes(const Metadata* file_level_metadata, int size) { + RegisterAllTypesInternal(file_level_metadata, size); } } // namespace internal diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index 1413b110..ea97a7c8 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -45,6 +45,7 @@ // TODO(jasonh): Remove this once the compiler change to directly include this // is released to components. #include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/metadata.h> #include <google/protobuf/unknown_field_set.h> @@ -73,6 +74,157 @@ class GeneratedMessageReflection; // Defined in other files. class ExtensionSet; // extension_set.h +// This struct describes the internal layout of the message, hence this is +// used to act on the message reflectively. +// default_instance: The default instance of the message. This is only +// used to obtain pointers to default instances of embedded +// messages, which GetMessage() will return if the particular +// sub-message has not been initialized yet. (Thus, all +// embedded message fields *must* have non-NULL pointers +// in the default instance.) +// offsets: An array of ints giving the byte offsets. +// For each oneof field, the offset is relative to the +// default_oneof_instance. These can be computed at compile +// time using the +// PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro. +// For each none oneof field, the offset is related to +// the start of the message object. These can be computed +// at compile time using the +// GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro. +// Besides offsets for all fields, this array also contains +// offsets for oneof unions. The offset of the i-th oneof +// union is offsets[descriptor->field_count() + i]. +// has_bit_indices: Mapping from field indexes to their index in the has +// bit array. +// has_bits_offset: Offset in the message of an array of uint32s of size +// descriptor->field_count()/32, rounded up. This is a +// bitfield where each bit indicates whether or not the +// corresponding field of the message has been initialized. +// The bit for field index i is obtained by the expression: +// has_bits[i / 32] & (1 << (i % 32)) +// unknown_fields_offset: Offset in the message of the UnknownFieldSet for +// the message. +// extensions_offset: Offset in the message of the ExtensionSet for the +// message, or -1 if the message type has no extension +// ranges. +// default_oneof_instance: The default instance of the oneofs. It is a +// struct holding the default value of all oneof fields +// for this message. It is only used to obtain pointers +// to default instances of oneof fields, which Get +// methods will return if the field is not set. +// oneof_case_offset: Offset in the message of an array of uint32s of +// size descriptor->oneof_decl_count(). Each uint32 +// indicates what field is set for each oneof. +// object_size: The size of a message object of this type, as measured +// by sizeof(). +// arena_offset: If a message doesn't have a unknown_field_set that stores +// the arena, it must have a direct pointer to the arena. +struct ReflectionSchema { + public: + // Size of a google::protobuf::Message object of this type. + uint32 GetObjectSize() const { return object_size_; } + + // Offset of a non-oneof field. Getting a field offset is slightly more + // efficient when we know statically that it is not a oneof field. + uint32 GetFieldOffsetNonOneof(const FieldDescriptor* field) const { + GOOGLE_DCHECK(!field->containing_oneof()); + return offsets_[field->index()]; + } + + // Offset of any field. + uint32 GetFieldOffset(const FieldDescriptor* field) const { + if (field->containing_oneof()) { + size_t offset = field->containing_type()->field_count() + + field->containing_oneof()->index(); + return offsets_[offset]; + } else { + return GetFieldOffsetNonOneof(field); + } + } + + uint32 GetOneofCaseOffset(const OneofDescriptor* oneof_descriptor) const { + return oneof_case_offset_ + (oneof_descriptor->index() * sizeof(uint32)); + } + + bool HasHasbits() const { return has_bits_offset_ != -1; } + + // Bit index within the bit array of hasbits. Bit order is low-to-high. + uint32 HasBitIndex(const FieldDescriptor* field) const { + GOOGLE_DCHECK(HasHasbits()); + return has_bit_indices_[field->index()]; + } + + // Byte offset of the hasbits array. + uint32 HasBitsOffset() const { + GOOGLE_DCHECK(HasHasbits()); + return has_bits_offset_; + } + + // The offset of the InternalMetadataWithArenaOffset member. + // For Lite this will actually be an InternalMetadataWithArenaOffsetLite. + // The schema doesn't contain enough information to distinguish between + // these two cases. + uint32 GetMetadataOffset() const { + return metadata_offset_; + } + + // Whether this message has an ExtensionSet. + bool HasExtensionSet() const { return extensions_offset_ != -1; } + + // The offset of the ExtensionSet in this message. + uint32 GetExtensionSetOffset() const { + GOOGLE_DCHECK(HasExtensionSet()); + return extensions_offset_; + } + + bool IsDefaultInstance(const Message& message) const { + return &message == default_instance_; + } + + // Returns a pointer to the default value for this field. The size and type + // of the underlying data depends on the field's type. + const void *GetFieldDefault(const FieldDescriptor* field) const { + return field->containing_oneof() + ? reinterpret_cast<const uint8*>(default_oneof_instance_) + + offsets_[field->index()] + : reinterpret_cast<const uint8*>(default_instance_) + + offsets_[field->index()]; + } + + // These members are intended to be private, but we cannot actually make them + // private because this prevents us from using aggregate initialization of + // them, ie. + // + // ReflectionSchema schema = {a, b, c, d, e, ...}; + // private: + const Message* default_instance_; + const uint32* offsets_; + const uint32* has_bit_indices_; + int has_bits_offset_; + int metadata_offset_; + int extensions_offset_; + const void* default_oneof_instance_; + int oneof_case_offset_; + int object_size_; +}; + +// Structs that the code generator emits directly to describe a message. +// These should never used directly except to build a ReflectionSchema +// object. +// +// EXPERIMENTAL: these are changing rapidly, and may completely disappear +// or merge with ReflectionSchema. +struct DefaultInstanceData { + const Message* default_instance; + const void* default_oneof_instance; +}; + +struct MigrationSchema { + int32 offsets_index; + int32 has_bit_indices_index; + int object_size; +}; + // THIS CLASS IS NOT INTENDED FOR DIRECT USE. It is intended for use // by generated code. This class is just a big hack that reduces code // size. @@ -97,109 +249,23 @@ class ExtensionSet; // extension_set.h // of whatever type the individual field would be. Strings and // Messages use RepeatedPtrFields while everything else uses // RepeatedFields. -class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { +class LIBPROTOBUF_EXPORT GeneratedMessageReflection PROTOBUF_FINAL : public Reflection { public: // Constructs a GeneratedMessageReflection. // Parameters: // descriptor: The descriptor for the message type being implemented. - // default_instance: The default instance of the message. This is only - // used to obtain pointers to default instances of embedded - // messages, which GetMessage() will return if the particular - // sub-message has not been initialized yet. (Thus, all - // embedded message fields *must* have non-NULL pointers - // in the default instance.) - // offsets: An array of ints giving the byte offsets, relative to - // the start of the message object, of each field. These can - // be computed at compile time using the - // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined - // below. - // has_bits_offset: Offset in the message of an array of uint32s of size - // descriptor->field_count()/32, rounded up. This is a - // bitfield where each bit indicates whether or not the - // corresponding field of the message has been initialized. - // The bit for field index i is obtained by the expression: - // has_bits[i / 32] & (1 << (i % 32)) - // unknown_fields_offset: Offset in the message of the UnknownFieldSet for - // the message. - // extensions_offset: Offset in the message of the ExtensionSet for the - // message, or -1 if the message type has no extension - // ranges. + // schema: The description of the internal guts of the message. // pool: DescriptorPool to search for extension definitions. Only // used by FindKnownExtensionByName() and // FindKnownExtensionByNumber(). // factory: MessageFactory to use to construct extension messages. - // object_size: The size of a message object of this type, as measured - // by sizeof(). GeneratedMessageReflection(const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], int has_bits_offset, - int unknown_fields_offset, int extensions_offset, + const ReflectionSchema& schema, const DescriptorPool* pool, - MessageFactory* factory, int object_size, - int arena_offset); + MessageFactory* factory); - // Similar with the construction above. Call this construction if the - // message has oneof definition. - // Parameters: - // offsets: An array of ints giving the byte offsets. - // For each oneof field, the offset is relative to the - // default_oneof_instance. These can be computed at compile - // time using the - // PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro. - // For each none oneof field, the offset is related to - // the start of the message object. These can be computed - // at compile time using the - // GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro. - // Besides offsets for all fields, this array also contains - // offsets for oneof unions. The offset of the i-th oneof - // union is offsets[descriptor->field_count() + i]. - // default_oneof_instance: The default instance of the oneofs. It is a - // struct holding the default value of all oneof fields - // for this message. It is only used to obtain pointers - // to default instances of oneof fields, which Get - // methods will return if the field is not set. - // oneof_case_offset: Offset in the message of an array of uint32s of - // size descriptor->oneof_decl_count(). Each uint32 - // indicates what field is set for each oneof. - // other parameters are the same with the construction above. - GeneratedMessageReflection(const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], int has_bits_offset, - int unknown_fields_offset, int extensions_offset, - const void* default_oneof_instance, - int oneof_case_offset, const DescriptorPool* pool, - MessageFactory* factory, int object_size, - int arena_offset); ~GeneratedMessageReflection(); - // Shorter-to-call helpers for the above two constructions that work if the - // pool and factory are the usual, namely, DescriptorPool::generated_pool() - // and MessageFactory::generated_factory(). - - static GeneratedMessageReflection* NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - const void* default_oneof_instance, - int oneof_case_offset, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); - - static GeneratedMessageReflection* NewGeneratedMessageReflection( - const Descriptor* descriptor, - const Message* default_instance, - const int offsets[], - int has_bits_offset, - int unknown_fields_offset, - int extensions_offset, - int object_size, - int arena_offset, - int is_default_instance_offset = -1); - // implements Reflection ------------------------------------------- const UnknownFieldSet& GetUnknownFields(const Message& message) const; @@ -424,36 +490,42 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { private: friend class GeneratedMessage; - - // To parse directly into a proto2 generated class, the class GMR_Handlers - // needs access to member offsets and hasbits. friend class upb::google_opensource::GMR_Handlers; - const Descriptor* descriptor_; - const Message* default_instance_; - const void* default_oneof_instance_; - const int* offsets_; - - int has_bits_offset_; - int oneof_case_offset_; - int unknown_fields_offset_; - int extensions_offset_; - int arena_offset_; - int object_size_; + const Descriptor* const descriptor_; + const ReflectionSchema schema_; + const DescriptorPool* const descriptor_pool_; + MessageFactory* const message_factory_; - const DescriptorPool* descriptor_pool_; - MessageFactory* message_factory_; + // To parse directly into a proto2 generated class, the class GMR_Handlers + // needs access to member offsets and hasbits. + // upb still needs these. + // TODO(haberman) clean this up. + const Message* const default_instance_; + const void* const default_oneof_instance_; + const uint32* const offsets_; + const uint32* const has_bits_indices_; + const int has_bits_offset_; + const int oneof_case_offset_; + const int unknown_fields_offset_; + const int extensions_offset_; + const int arena_offset_; + const int object_size_; + + template <class T> + const T& GetRawNonOneof(const Message& message, + const FieldDescriptor* field) const; + template <class T> + T* MutableRawNonOneof(Message* message, const FieldDescriptor* field) const; template <typename Type> - inline const Type& GetRaw(const Message& message, + const Type& GetRaw(const Message& message, const FieldDescriptor* field) const; template <typename Type> inline Type* MutableRaw(Message* message, const FieldDescriptor* field) const; template <typename Type> inline const Type& DefaultRaw(const FieldDescriptor* field) const; - template <typename Type> - inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const; inline const uint32* GetHasBits(const Message& message) const; inline uint32* MutableHasBits(Message* message) const; @@ -466,12 +538,12 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { inline const ExtensionSet& GetExtensionSet(const Message& message) const; inline ExtensionSet* MutableExtensionSet(Message* message) const; inline Arena* GetArena(Message* message) const; - inline const internal::InternalMetadataWithArena& - GetInternalMetadataWithArena(const Message& message) const; - inline internal::InternalMetadataWithArena* - MutableInternalMetadataWithArena(Message* message) const; - inline bool GetIsDefaultInstance(const Message& message) const; + inline const InternalMetadataWithArena& GetInternalMetadataWithArena( + const Message& message) const; + + inline InternalMetadataWithArena* + MutableInternalMetadataWithArena(Message* message) const; inline bool HasBit(const Message& message, const FieldDescriptor* field) const; @@ -559,6 +631,9 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { internal::MapFieldBase* MapData( Message* message, const FieldDescriptor* field) const; + friend inline // inline so nobody can call this function. + void + RegisterAllTypesInternal(const Metadata* file_level_metadata, int size); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection); }; @@ -592,7 +667,7 @@ class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection { #endif #define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \ - static_cast<int>( \ + static_cast< ::google::protobuf::uint32>( \ reinterpret_cast<const char*>(&(ONEOF->FIELD)) \ - reinterpret_cast<const char*>(ONEOF)) @@ -664,6 +739,25 @@ T* DynamicCastToGenerated(Message* from) { return const_cast<T*>(DynamicCastToGenerated<const T>(message_const)); } +LIBPROTOBUF_EXPORT void AssignDescriptors( + const string& filename, const MigrationSchema* schemas, + const DefaultInstanceData* default_instance_data, const uint32* offsets, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors); + +LIBPROTOBUF_EXPORT void AssignDescriptors( + const string& filename, const ReflectionSchema* schemas, + MessageFactory* factory, + // update the following descriptor arrays. + Metadata* file_level_metadata, + const EnumDescriptor** file_level_enum_descriptors, + const ServiceDescriptor** file_level_service_descriptors); + +LIBPROTOBUF_EXPORT void RegisterAllTypes(const Metadata* file_level_metadata, int size); + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/generated_message_reflection_unittest.cc b/src/google/protobuf/generated_message_reflection_unittest.cc index 6276b667..e2c6cdc0 100644 --- a/src/google/protobuf/generated_message_reflection_unittest.cc +++ b/src/google/protobuf/generated_message_reflection_unittest.cc @@ -222,7 +222,7 @@ TEST(GeneratedMessageReflectionTest, SwapFields) { message2.set_optional_string("hello"); message2.mutable_repeated_int64()->Add(30); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Descriptor* descriptor = message1.GetDescriptor(); fields.push_back(descriptor->FindFieldByName("optional_double")); fields.push_back(descriptor->FindFieldByName("repeated_int32")); @@ -255,7 +255,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAll) { TestUtil::SetAllFields(&message2); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message2, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -270,7 +270,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) { TestUtil::SetAllExtensions(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message1, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -306,7 +306,7 @@ TEST(GeneratedMessageReflectionTest, SwapFieldsOneof) { unittest::TestOneof2 message1, message2; TestUtil::SetOneof1(&message1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Descriptor* descriptor = message1.GetDescriptor(); for (int i = 0; i < descriptor->field_count(); i++) { fields.push_back(descriptor->field(i)); @@ -608,7 +608,7 @@ TEST(GeneratedMessageReflectionTest, ListFieldsOneOf) { TestUtil::SetOneof1(&message); const Reflection* reflection = message.GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); EXPECT_EQ(4, fields.size()); } diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 73f55927..b4d2c9c1 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -51,9 +51,7 @@ double NaN() { ExplicitlyConstructed< ::std::string> fixed_address_empty_string; GOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_); -void DeleteEmptyString() { - GetEmptyStringAlreadyInited().~string(); -} +void DeleteEmptyString() { fixed_address_empty_string.Shutdown(); } void InitEmptyString() { fixed_address_empty_string.DefaultConstruct(); @@ -73,10 +71,8 @@ int StringSpaceUsedExcludingSelf(const string& str) { -void MergeFromFail(const char* file, int line) { - GOOGLE_CHECK(false) << file << ":" << line; - // Open-source GOOGLE_CHECK(false) is not NORETURN. - exit(1); +void InitProtobufDefaults() { + GetEmptyString(); } } // namespace internal diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 8dc64c49..19bac7dc 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -45,6 +45,14 @@ #include <google/protobuf/stubs/once.h> #include <google/protobuf/has_bits.h> +#ifndef PROTOBUF_FINAL +#if __cplusplus >= 201103L +#define PROTOBUF_FINAL final +#else +#define PROTOBUF_FINAL +#endif +#endif // !PROTOBUF_FINAL + namespace google { namespace protobuf { @@ -91,7 +99,13 @@ class ExplicitlyConstructed { } } - const T& get() const { return reinterpret_cast<const T&>(union_); } +#if __cplusplus >= 201103L + constexpr +#endif + const T& + get() const { + return reinterpret_cast<const T&>(union_); + } T* get_mutable() { return reinterpret_cast<T*>(&union_); } private: @@ -111,7 +125,7 @@ class ExplicitlyConstructed { // Default empty string object. Don't use this directly. Instead, call // GetEmptyString() to get the reference. -extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; +LIBPROTOBUF_EXPORT extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; LIBPROTOBUF_EXPORT void InitEmptyString(); @@ -140,9 +154,7 @@ template <class Type> bool AllAreInitialized(const Type& t) { return true; } -// Helper function to crash on merge failure. -// Moved out of generated code to reduce binary size. -LIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN; +LIBPROTOBUF_EXPORT void InitProtobufDefaults(); // We compute sizes as size_t but cache them as int. This function converts a // computed size to a cached size. Since we don't proceed with serialization if diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index 08394ca7..93748ee3 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -47,7 +47,6 @@ #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/stl_util.h> -#include <google/protobuf/stubs/port.h> namespace google { @@ -550,9 +549,15 @@ bool CodedInputStream::ReadVarint64Slow(uint64* value) { uint32 b; do { - if (count == kMaxVarintBytes) return false; + if (count == kMaxVarintBytes) { + *value = 0; + return false; + } while (buffer_ == buffer_end_) { - if (!Refresh()) return false; + if (!Refresh()) { + *value = 0; + return false; + } } b = *buffer_; result |= static_cast<uint64>(b & 0x7F) << (7 * count); @@ -602,13 +607,13 @@ bool CodedInputStream::Refresh() { if (total_bytes_warning_threshold_ >= 0 && total_bytes_read_ >= total_bytes_warning_threshold_) { - GOOGLE_LOG(WARNING) << "Reading dangerously large protocol message. If the " - "message turns out to be larger than " - << total_bytes_limit_ << " bytes, parsing will be halted " - "for security reasons. To increase the limit (or to " - "disable these warnings), see " - "CodedInputStream::SetTotalBytesLimit() in " - "google/protobuf/io/coded_stream.h."; + GOOGLE_LOG(INFO) << "Reading dangerously large protocol message. If the " + "message turns out to be larger than " + << total_bytes_limit_ << " bytes, parsing will be halted " + "for security reasons. To increase the limit (or to " + "disable these warnings), see " + "CodedInputStream::SetTotalBytesLimit() in " + "google/protobuf/io/coded_stream.h."; // Don't warn again for this stream, and print total size at the end. total_bytes_warning_threshold_ = -2; @@ -789,104 +794,12 @@ void CodedOutputStream::WriteVarint32SlowPath(uint32 value) { WriteRaw(bytes, size); } -inline uint8* CodedOutputStream::WriteVarint64ToArrayInline( - uint64 value, uint8* target) { - // Splitting into 32-bit pieces gives better performance on 32-bit - // processors. - uint32 part0 = static_cast<uint32>(value ); - uint32 part1 = static_cast<uint32>(value >> 28); - uint32 part2 = static_cast<uint32>(value >> 56); - - int size; - - // Here we can't really optimize for small numbers, since the value is - // split into three parts. Cheking for numbers < 128, for instance, - // would require three comparisons, since you'd have to make sure part1 - // and part2 are zero. However, if the caller is using 64-bit integers, - // it is likely that they expect the numbers to often be very large, so - // we probably don't want to optimize for small numbers anyway. Thus, - // we end up with a hardcoded binary search tree... - if (part2 == 0) { - if (part1 == 0) { - if (part0 < (1 << 14)) { - if (part0 < (1 << 7)) { - size = 1; goto size1; - } else { - size = 2; goto size2; - } - } else { - if (part0 < (1 << 21)) { - size = 3; goto size3; - } else { - size = 4; goto size4; - } - } - } else { - if (part1 < (1 << 14)) { - if (part1 < (1 << 7)) { - size = 5; goto size5; - } else { - size = 6; goto size6; - } - } else { - if (part1 < (1 << 21)) { - size = 7; goto size7; - } else { - size = 8; goto size8; - } - } - } - } else { - if (part2 < (1 << 7)) { - size = 9; goto size9; - } else { - size = 10; goto size10; - } - } - - GOOGLE_LOG(FATAL) << "Can't get here."; - - size10: target[9] = static_cast<uint8>((part2 >> 7) | 0x80); - size9 : target[8] = static_cast<uint8>((part2 ) | 0x80); - size8 : target[7] = static_cast<uint8>((part1 >> 21) | 0x80); - size7 : target[6] = static_cast<uint8>((part1 >> 14) | 0x80); - size6 : target[5] = static_cast<uint8>((part1 >> 7) | 0x80); - size5 : target[4] = static_cast<uint8>((part1 ) | 0x80); - size4 : target[3] = static_cast<uint8>((part0 >> 21) | 0x80); - size3 : target[2] = static_cast<uint8>((part0 >> 14) | 0x80); - size2 : target[1] = static_cast<uint8>((part0 >> 7) | 0x80); - size1 : target[0] = static_cast<uint8>((part0 ) | 0x80); - - target[size-1] &= 0x7F; - return target + size; -} - -void CodedOutputStream::WriteVarint64(uint64 value) { - if (buffer_size_ >= kMaxVarintBytes) { - // Fast path: We have enough bytes left in the buffer to guarantee that - // this write won't cross the end, so we can skip the checks. - uint8* target = buffer_; - - uint8* end = WriteVarint64ToArrayInline(value, target); - int size = end - target; - Advance(size); - } else { - // Slow path: This write might cross the end of the buffer, so we - // compose the bytes first then use WriteRaw(). - uint8 bytes[kMaxVarintBytes]; - int size = 0; - while (value > 0x7F) { - bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80; - value >>= 7; - } - bytes[size++] = static_cast<uint8>(value) & 0x7F; - WriteRaw(bytes, size); - } -} - -uint8* CodedOutputStream::WriteVarint64ToArray( - uint64 value, uint8* target) { - return WriteVarint64ToArrayInline(value, target); +void CodedOutputStream::WriteVarint64SlowPath(uint64 value) { + uint8 bytes[kMaxVarintBytes]; + uint8* target = &bytes[0]; + uint8* end = WriteVarint64ToArray(value, target); + int size = end - target; + WriteRaw(bytes, size); } bool CodedOutputStream::Refresh() { @@ -904,17 +817,22 @@ bool CodedOutputStream::Refresh() { } size_t CodedOutputStream::VarintSize32Fallback(uint32 value) { + // This computes floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..31 range. GOOGLE_DCHECK_NE(0, value); // This is enforced by our caller. - return 1 + Bits::Log2FloorNonZero(value) / 7; + uint32 log2value = Bits::Log2FloorNonZero(value); + return static_cast<size_t>((log2value * 9 + 73) / 64); } size_t CodedOutputStream::VarintSize64(uint64 value) { - if (value < (1 << 7)) { - return 1; - } - - return 1 + Bits::Log2FloorNonZero64(value) / 7; + // This computes value == 0 ? 1 : floor(log2(value)) / 7 + 1 + // Use an explicit multiplication to implement the divide of + // a number in the 1..63 range. + // Explicit OR 0x1 to avoid calling clz(0), which is undefined. + uint32 log2value = Bits::Log2FloorNonZero64(value | 0x1); + return static_cast<size_t>((log2value * 9 + 73) / 64); } uint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str, diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index 1402cc17..d2a3e279 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -249,12 +249,16 @@ class LIBPROTOBUF_EXPORT CodedInputStream { bool ReadVarintSizeAsInt(int* value); // Read a tag. This calls ReadVarint32() and returns the result, or returns - // zero (which is not a valid tag) if ReadVarint32() fails. Also, it updates - // the last tag value, which can be checked with LastTagWas(). + // zero (which is not a valid tag) if ReadVarint32() fails. Also, ReadTag + // (but not ReadTagNoLastTag) updates the last tag value, which can be checked + // with LastTagWas(). + // // Always inline because this is only called in one place per parse loop // but it is called for every iteration of said loop, so it should be fast. // GCC doesn't want to inline this by default. GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag(); + GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagNoLastTag(); + // This usually a faster alternative to ReadTag() when cutoff is a manifest // constant. It does particularly well for cutoff >= 127. The first part @@ -266,6 +270,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // to avoid an extra "is tag == 0?" check here.) GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff( uint32 cutoff); + GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoffNoLastTag( + uint32 cutoff); // Usually returns true if calling ReadVarint32() now would produce the given // value. Will always return false if ReadVarint32() would not return the @@ -293,8 +299,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // zero, and ConsumedEntireMessage() will return true. bool ExpectAtEnd(); - // If the last call to ReadTag() or ReadTagWithCutoff() returned the - // given value, returns true. Otherwise, returns false; + // If the last call to ReadTag() or ReadTagWithCutoff() returned the given + // value, returns true. Otherwise, returns false. + // ReadTagNoLastTag/ReadTagWithCutoffNoLastTag do not preserve the last + // returned value. // // This is needed because parsers for some types of embedded messages // (with field type TYPE_GROUP) don't actually know that they've reached the @@ -612,6 +620,13 @@ class LIBPROTOBUF_EXPORT CodedInputStream { int ReadVarintSizeAsIntSlow(); bool ReadLittleEndian32Fallback(uint32* value); bool ReadLittleEndian64Fallback(uint64* value); + + template<bool update_last_tag> + GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTagImplementation(); + template<bool update_last_tag> + GOOGLE_ATTRIBUTE_ALWAYS_INLINE + std::pair<uint32, bool> ReadTagWithCutoffImplementation(uint32 cutoff); + // Fallback/slow methods for reading tags. These do not update last_tag_, // but will set legitimate_message_end_ if we are at the end of the input // stream. @@ -622,7 +637,7 @@ class LIBPROTOBUF_EXPORT CodedInputStream { // Return the size of the buffer. int BufferSize() const; - static const int kDefaultTotalBytesLimit = 64 << 20; // 64MB + static const int kDefaultTotalBytesLimit = INT_MAX; static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB @@ -842,10 +857,10 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { serialization_deterministic_override_ = value; } // See above. Also, note that users of this CodedOutputStream may need to - // call IsSerializationDeterminstic() to serialize in the intended way. This + // call IsSerializationDeterministic() to serialize in the intended way. This // CodedOutputStream cannot enforce a desire for deterministic serialization // by itself. - bool IsSerializationDeterminstic() const { + bool IsSerializationDeterministic() const { return serialization_deterministic_is_overridden_ ? serialization_deterministic_override_ : default_serialization_deterministic_; @@ -879,16 +894,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { // If this write might cross the end of the buffer, we compose the bytes first // then use WriteRaw(). void WriteVarint32SlowPath(uint32 value); - - // Always-inlined versions of WriteVarint* functions so that code can be - // reused, while still controlling size. For instance, WriteVarint32ToArray() - // should not directly call this: since it is inlined itself, doing so - // would greatly increase the size of generated code. Instead, it should call - // WriteVarint32FallbackToArray. Meanwhile, WriteVarint32() is already - // out-of-line, so it should just invoke this directly to avoid any extra - // function call overhead. - GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline( - uint64 value, uint8* target); + void WriteVarint64SlowPath(uint64 value); static size_t VarintSize32Fallback(uint32 value); @@ -1007,21 +1013,47 @@ inline bool CodedInputStream::ReadLittleEndian64(uint64* value) { } inline uint32 CodedInputStream::ReadTag() { + return ReadTagImplementation<true>(); +} + +inline uint32 CodedInputStream::ReadTagNoLastTag() { + return ReadTagImplementation<false>(); +} + +template<bool update_last_tag> +inline uint32 CodedInputStream::ReadTagImplementation() { uint32 v = 0; if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) { v = *buffer_; if (v < 0x80) { - last_tag_ = v; + if (update_last_tag) { + last_tag_ = v; + } Advance(1); return v; } } - last_tag_ = ReadTagFallback(v); - return last_tag_; + v = ReadTagFallback(v); + if (update_last_tag) { + last_tag_ = v; + } + return v; } inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( uint32 cutoff) { + return ReadTagWithCutoffImplementation<true>(cutoff); +} + +inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoffNoLastTag( + uint32 cutoff) { + return ReadTagWithCutoffImplementation<false>(cutoff); +} + +template<bool update_last_tag> +inline std::pair<uint32, bool> +CodedInputStream::ReadTagWithCutoffImplementation( + uint32 cutoff) { // In performance-sensitive code we can expect cutoff to be a compile-time // constant, and things like "cutoff >= kMax1ByteVarint" to be evaluated at // compile time. @@ -1033,7 +1065,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( first_byte_or_zero = buffer_[0]; if (static_cast<int8>(buffer_[0]) > 0) { const uint32 kMax1ByteVarint = 0x7f; - uint32 tag = last_tag_ = buffer_[0]; + uint32 tag = buffer_[0]; + if (update_last_tag) { + last_tag_ = tag; + } Advance(1); return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff); } @@ -1044,7 +1079,10 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) && GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) { const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f; - uint32 tag = last_tag_ = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80); + uint32 tag = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80); + if (update_last_tag) { + last_tag_ = tag; + } Advance(2); // It might make sense to test for tag == 0 now, but it is so rare that // that we don't bother. A varint-encoded 0 should be one byte unless @@ -1057,8 +1095,11 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff( } } // Slow path - last_tag_ = ReadTagFallback(first_byte_or_zero); - return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff); + const uint32 tag = ReadTagFallback(first_byte_or_zero); + if (update_last_tag) { + last_tag_ = tag; + } + return std::make_pair(tag, static_cast<uint32>(tag - 1) < cutoff); } inline bool CodedInputStream::LastTagWas(uint32 expected) { @@ -1153,21 +1194,24 @@ inline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value, return target + 1; } -inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) { - if (value < 0) { - WriteVarint64(static_cast<uint64>(value)); - } else { - WriteVarint32(static_cast<uint32>(value)); +inline uint8* CodedOutputStream::WriteVarint64ToArray(uint64 value, + uint8* target) { + while (value >= 0x80) { + *target = static_cast<uint8>(value | 0x80); + value >>= 7; + ++target; } + *target = static_cast<uint8>(value); + return target + 1; +} + +inline void CodedOutputStream::WriteVarint32SignExtended(int32 value) { + WriteVarint64(static_cast<uint64>(value)); } inline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray( int32 value, uint8* target) { - if (value < 0) { - return WriteVarint64ToArray(static_cast<uint64>(value), target); - } else { - return WriteVarint32ToArray(static_cast<uint32>(value), target); - } + return WriteVarint64ToArray(static_cast<uint64>(value), target); } inline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value, @@ -1216,6 +1260,19 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) { } } +inline void CodedOutputStream::WriteVarint64(uint64 value) { + if (buffer_size_ >= 10) { + // Fast path: We have enough bytes left in the buffer to guarantee that + // this write won't cross the end, so we can skip the checks. + uint8* target = buffer_; + uint8* end = WriteVarint64ToArray(value, target); + int size = static_cast<int>(end - target); + Advance(size); + } else { + WriteVarint64SlowPath(value); + } +} + inline void CodedOutputStream::WriteTag(uint32 value) { WriteVarint32(value); } diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index 9f1ebc3f..31574d5b 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -135,7 +135,7 @@ class CodedStreamTest : public testing::Test { // for further information. static void SetupTotalBytesLimitWarningTest( int total_bytes_limit, int warning_threshold, - vector<string>* out_errors, vector<string>* out_warnings); + std::vector<string>* out_errors, std::vector<string>* out_warnings); // Buffer used during most of the tests. This assumes tests run sequentially. static const int kBufferSize = 1024 * 64; @@ -245,7 +245,7 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) { int count_; } in; CodedInputStream input(&in); - input.ReadTag(); + input.ReadTagNoLastTag(); EXPECT_TRUE(input.ConsumedEntireMessage()); } @@ -446,6 +446,21 @@ TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) { EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); } +TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState, + kVarintErrorCases, kBlockSizes) { + memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); + ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + kBlockSizes_case); + CodedInputStream coded_input(&input); + + uint32 value = 0; + EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value)); + // While the specific value following a failure is not critical, we do want to + // ensure that it doesn't get set to an uninitialized value. (This check fails + // in MSAN mode if value has been set to an uninitialized value.) + EXPECT_EQ(value, value); +} + TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); ArrayInputStream input(buffer_, kVarintErrorCases_case.size, @@ -456,6 +471,21 @@ TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) { EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); } +TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState, + kVarintErrorCases, kBlockSizes) { + memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size); + ArrayInputStream input(buffer_, kVarintErrorCases_case.size, + kBlockSizes_case); + CodedInputStream coded_input(&input); + + uint64 value = 0; + EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value)); + // While the specific value following a failure is not critical, we do want to + // ensure that it doesn't get set to an uninitialized value. (This check fails + // in MSAN mode if value has been set to an uninitialized value.) + EXPECT_EQ(value, value); +} + // ------------------------------------------------------------------- // VarintSize @@ -495,6 +525,28 @@ TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) { CodedOutputStream::VarintSize64(kVarintSizeCases_case.value)); } +TEST_F(CodedStreamTest, VarintSize32PowersOfTwo) { + int expected = 1; + for (int i = 1; i < 32; i++) { + if (i % 7 == 0) { + expected += 1; + } + EXPECT_EQ(expected, + CodedOutputStream::VarintSize32(static_cast<uint32>(0x1u << i))); + } +} + +TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) { + int expected = 1; + for (int i = 1; i < 64; i++) { + if (i % 7 == 0) { + expected += 1; + } + EXPECT_EQ(expected, CodedOutputStream::VarintSize64( + static_cast<uint64>(0x1ull << i))); + } +} + // ------------------------------------------------------------------- // Fixed-size int tests @@ -1177,7 +1229,7 @@ TEST_F(CodedStreamTest, TotalBytesLimit) { EXPECT_TRUE(coded_input.ReadString(&str, 16)); EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit()); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog error_log; @@ -1211,7 +1263,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // Read a tag. Should fail, but report being a valid endpoint since it's // a regular limit. - EXPECT_EQ(0, coded_input.ReadTag()); + EXPECT_EQ(0, coded_input.ReadTagNoLastTag()); EXPECT_TRUE(coded_input.ConsumedEntireMessage()); // Pop the limit. @@ -1219,7 +1271,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // Read a tag. Should fail, and report *not* being a valid endpoint, since // this time we're hitting the total bytes limit. - EXPECT_EQ(0, coded_input.ReadTag()); + EXPECT_EQ(0, coded_input.ReadTagNoLastTag()); EXPECT_FALSE(coded_input.ConsumedEntireMessage()); } @@ -1229,7 +1281,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) { // vectors. void CodedStreamTest::SetupTotalBytesLimitWarningTest( int total_bytes_limit, int warning_threshold, - vector<string>* out_errors, vector<string>* out_warnings) { + std::vector<string>* out_errors, std::vector<string>* out_warnings) { ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128); ScopedMemoryLog scoped_log; @@ -1245,25 +1297,21 @@ void CodedStreamTest::SetupTotalBytesLimitWarningTest( } TEST_F(CodedStreamTest, TotalBytesLimitWarning) { - vector<string> errors; - vector<string> warnings; + std::vector<string> errors; + std::vector<string> warnings; SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings); EXPECT_EQ(0, errors.size()); - ASSERT_EQ(2, warnings.size()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, - "Reading dangerously large protocol message. If the message turns out to " - "be larger than 10240 bytes, parsing will be halted for security reasons.", - warnings[0]); + EXPECT_EQ(1, warnings.size()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "The total number of bytes read was 2048", - warnings[1]); + warnings[0]); } TEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) { - vector<string> errors; - vector<string> warnings; + std::vector<string> errors; + std::vector<string> warnings; // Test with -1 SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings); @@ -1362,7 +1410,7 @@ TEST_F(CodedStreamTest, InputOver2G) { // input.BackUp() with the correct number of bytes on destruction. ReallyBigInputStream input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog error_log; diff --git a/src/google/protobuf/io/gzip_stream.cc b/src/google/protobuf/io/gzip_stream.cc index 9c621b6a..a569eff0 100644 --- a/src/google/protobuf/io/gzip_stream.cc +++ b/src/google/protobuf/io/gzip_stream.cc @@ -168,7 +168,7 @@ void GzipInputStream::BackUp(int count) { } bool GzipInputStream::Skip(int count) { const void* data; - int size; + int size = 0; bool ok = Next(&data, &size); while (ok && (size < count)) { count -= size; diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 7532b098..99e895f5 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -70,8 +70,8 @@ Printer::~Printer() { } bool Printer::GetSubstitutionRange(const char* varname, - pair<size_t, size_t>* range) { - map<string, pair<size_t, size_t> >::const_iterator iter = + std::pair<size_t, size_t>* range) { + std::map<string, std::pair<size_t, size_t> >::const_iterator iter = substitutions_.find(varname); if (iter == substitutions_.end()) { GOOGLE_LOG(DFATAL) << " Undefined variable in annotation: " << varname; @@ -87,12 +87,12 @@ bool Printer::GetSubstitutionRange(const char* varname, } void Printer::Annotate(const char* begin_varname, const char* end_varname, - const string& file_path, const vector<int>& path) { + const string& file_path, const std::vector<int>& path) { if (annotation_collector_ == NULL) { // Can't generate signatures with this Printer. return; } - pair<size_t, size_t> begin, end; + std::pair<size_t, size_t> begin, end; if (!GetSubstitutionRange(begin_varname, &begin) || !GetSubstitutionRange(end_varname, &end)) { return; @@ -106,7 +106,8 @@ void Printer::Annotate(const char* begin_varname, const char* end_varname, } } -void Printer::Print(const map<string, string>& variables, const char* text) { +void Printer::Print(const std::map<string, string>& variables, + const char* text) { int size = strlen(text); int pos = 0; // The number of bytes we've written so far. substitutions_.clear(); @@ -143,14 +144,15 @@ void Printer::Print(const map<string, string>& variables, const char* text) { WriteRaw(&variable_delimiter_, 1); } else { // Replace with the variable's value. - map<string, string>::const_iterator iter = variables.find(varname); + std::map<string, string>::const_iterator iter = variables.find(varname); if (iter == variables.end()) { GOOGLE_LOG(DFATAL) << " Undefined variable: " << varname; } else { size_t begin = offset_; WriteRaw(iter->second.data(), iter->second.size()); - pair<map<string, pair<size_t, size_t> >::iterator, bool> inserted = - substitutions_.insert( + std::pair<std::map<string, std::pair<size_t, size_t> >::iterator, + bool> + inserted = substitutions_.insert( std::make_pair(varname, std::make_pair(begin, offset_))); if (!inserted.second) { // This variable was used multiple times. Make its span have @@ -172,13 +174,13 @@ void Printer::Print(const map<string, string>& variables, const char* text) { } void Printer::Print(const char* text) { - static map<string, string> empty; + static std::map<string, string> empty; Print(empty, text); } void Printer::Print(const char* text, const char* variable, const string& value) { - map<string, string> vars; + std::map<string, string> vars; vars[variable] = value; Print(vars, text); } @@ -186,7 +188,7 @@ void Printer::Print(const char* text, void Printer::Print(const char* text, const char* variable1, const string& value1, const char* variable2, const string& value2) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; Print(vars, text); @@ -196,7 +198,7 @@ void Printer::Print(const char* text, const char* variable1, const string& value1, const char* variable2, const string& value2, const char* variable3, const string& value3) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -208,7 +210,7 @@ void Printer::Print(const char* text, const char* variable2, const string& value2, const char* variable3, const string& value3, const char* variable4, const string& value4) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -222,7 +224,7 @@ void Printer::Print(const char* text, const char* variable3, const string& value3, const char* variable4, const string& value4, const char* variable5, const string& value5) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -238,7 +240,7 @@ void Printer::Print(const char* text, const char* variable4, const string& value4, const char* variable5, const string& value5, const char* variable6, const string& value6) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -256,7 +258,7 @@ void Printer::Print(const char* text, const char* variable5, const string& value5, const char* variable6, const string& value6, const char* variable7, const string& value7) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; @@ -276,7 +278,7 @@ void Printer::Print(const char* text, const char* variable6, const string& value6, const char* variable7, const string& value7, const char* variable8, const string& value8) { - map<string, string> vars; + std::map<string, string> vars; vars[variable1] = value1; vars[variable2] = value2; vars[variable3] = value3; diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index e78e2efd..e666445b 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -55,7 +55,7 @@ class LIBPROTOBUF_EXPORT AnnotationCollector { // before end_offset are associated with the SourceCodeInfo-style path. virtual void AddAnnotation(size_t begin_offset, size_t end_offset, const string& file_path, - const vector<int>& path) = 0; + const std::vector<int>& path) = 0; virtual ~AnnotationCollector() {} }; @@ -73,7 +73,8 @@ class AnnotationProtoCollector : public AnnotationCollector { // Override for AnnotationCollector::AddAnnotation. virtual void AddAnnotation(size_t begin_offset, size_t end_offset, - const string& file_path, const vector<int>& path) { + const string& file_path, + const std::vector<int>& path) { typename AnnotationProto::Annotation* annotation = annotation_proto_->add_annotation(); for (int i = 0; i < path.size(); ++i) { @@ -195,7 +196,7 @@ class LIBPROTOBUF_EXPORT Printer { // of building the location path. return; } - vector<int> path; + std::vector<int> path; descriptor->GetLocationPath(&path); Annotate(begin_varname, end_varname, descriptor->file()->name(), path); } @@ -216,7 +217,7 @@ class LIBPROTOBUF_EXPORT Printer { // Annotations aren't turned on for this Printer. return; } - vector<int> empty_path; + std::vector<int> empty_path; Annotate(begin_varname, end_varname, file_name, empty_path); } @@ -225,7 +226,7 @@ class LIBPROTOBUF_EXPORT Printer { // substituted are identified by their names surrounded by delimiter // characters (as given to the constructor). The variable bindings are // defined by the given map. - void Print(const map<string, string>& variables, const char* text); + void Print(const std::map<string, string>& variables, const char* text); // Like the first Print(), except the substitutions are given as parameters. void Print(const char* text); @@ -308,7 +309,7 @@ class LIBPROTOBUF_EXPORT Printer { // substituted for end_varname. Note that begin_varname and end_varname // may refer to the same variable. void Annotate(const char* begin_varname, const char* end_varname, - const string& file_path, const vector<int>& path); + const string& file_path, const std::vector<int>& path); const char variable_delimiter_; @@ -331,13 +332,14 @@ class LIBPROTOBUF_EXPORT Printer { // start offset is the beginning of the substitution; the end offset is the // last byte of the substitution plus one (such that (end - start) is the // length of the substituted string). - map<string, pair<size_t, size_t> > substitutions_; + std::map<string, std::pair<size_t, size_t> > substitutions_; // Returns true and sets range to the substitution range in the output for // varname if varname was used once in the last call to Print. If varname // was not used, or if it was used multiple times, returns false (and // fails a debug assertion). - bool GetSubstitutionRange(const char* varname, pair<size_t, size_t>* range); + bool GetSubstitutionRange(const char* varname, + std::pair<size_t, size_t>* range); // If non-null, annotation_collector_ is used to store annotations about // generated code. diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc index 95f3afa2..0435228a 100644 --- a/src/google/protobuf/io/printer_unittest.cc +++ b/src/google/protobuf/io/printer_unittest.cc @@ -121,7 +121,7 @@ TEST(Printer, VariableSubstitution) { { Printer printer(&output, '$'); - map<string, string> vars; + std::map<string, string> vars; vars["foo"] = "World"; vars["bar"] = "$foo$"; @@ -187,7 +187,7 @@ class MockDescriptorFile { // annotations. class MockDescriptor { public: - MockDescriptor(const string& file, const vector<int>& path) + MockDescriptor(const string& file, const std::vector<int>& path) : file_(file), path_(path) {} // The mock file in which this descriptor was defined. @@ -201,7 +201,7 @@ class MockDescriptor { void GetLocationPath(std::vector<int>* output) const { *output = path_; } MockDescriptorFile file_; - vector<int> path_; + std::vector<int> path_; }; TEST(Printer, AnnotateMap) { @@ -211,13 +211,13 @@ TEST(Printer, AnnotateMap) { AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info); { Printer printer(&output, '$', &info_collector); - map<string, string> vars; + std::map<string, string> vars; vars["foo"] = "3"; vars["bar"] = "5"; printer.Print(vars, "012$foo$4$bar$\n"); - vector<int> path_1; + std::vector<int> path_1; path_1.push_back(33); - vector<int> path_2; + std::vector<int> path_2; path_2.push_back(11); path_2.push_back(22); MockDescriptor descriptor_1("path_1", path_1); @@ -255,9 +255,9 @@ TEST(Printer, AnnotateInline) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path_1; + std::vector<int> path_1; path_1.push_back(33); - vector<int> path_2; + std::vector<int> path_2; path_2.push_back(11); path_2.push_back(22); MockDescriptor descriptor_1("path_1", path_1); @@ -295,7 +295,7 @@ TEST(Printer, AnnotateRange) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("foo", "bar", &descriptor); @@ -320,7 +320,7 @@ TEST(Printer, AnnotateEmptyRange) { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$baz$$bam$$bar$\n", "foo", "3", "bar", "5", "baz", "", "bam", ""); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("baz", "bam", &descriptor); @@ -344,7 +344,7 @@ TEST(Printer, AnnotateDespiteUnrelatedMultipleUses) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); printer.Annotate("bar", "bar", &descriptor); @@ -368,7 +368,7 @@ TEST(Printer, Indenting) { { Printer printer(&output, '$'); - map<string, string> vars; + std::map<string, string> vars; vars["newline"] = "\n"; @@ -432,7 +432,7 @@ TEST(Printer, AnnotateMultipleUsesDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("foo", "foo", &descriptor), "multiple"); @@ -447,7 +447,7 @@ TEST(Printer, AnnotateNegativeLengthDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$bar$\n", "foo", "3", "bar", "5"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("bar", "foo", &descriptor), "negative"); @@ -462,7 +462,7 @@ TEST(Printer, AnnotateUndefinedDeath) { { Printer printer(&output, '$', &info_collector); printer.Print("012$foo$4$foo$\n", "foo", "3"); - vector<int> path; + std::vector<int> path; path.push_back(33); MockDescriptor descriptor("path", path); EXPECT_DEBUG_DEATH(printer.Annotate("bar", "bar", &descriptor), diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc index b3550dfb..916d1606 100644 --- a/src/google/protobuf/io/tokenizer.cc +++ b/src/google/protobuf/io/tokenizer.cc @@ -665,7 +665,7 @@ namespace { class CommentCollector { public: CommentCollector(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments) : prev_trailing_comments_(prev_trailing_comments), detached_comments_(detached_comments), @@ -737,7 +737,7 @@ class CommentCollector { private: string* prev_trailing_comments_; - vector<string>* detached_comments_; + std::vector<string>* detached_comments_; string* next_leading_comments_; string comment_buffer_; @@ -757,7 +757,7 @@ class CommentCollector { } // namespace bool Tokenizer::NextWithComments(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments) { CommentCollector collector(prev_trailing_comments, detached_comments, next_leading_comments); diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h index 77a873bc..e80d564c 100644 --- a/src/google/protobuf/io/tokenizer.h +++ b/src/google/protobuf/io/tokenizer.h @@ -191,7 +191,7 @@ class LIBPROTOBUF_EXPORT Tokenizer { // * grault. */ // optional int32 grault = 6; bool NextWithComments(string* prev_trailing_comments, - vector<string>* detached_comments, + std::vector<string>* detached_comments, string* next_leading_comments); // Parse helpers --------------------------------------------------- diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index ae0811f8..a2c19522 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -693,7 +693,7 @@ TEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) { EXPECT_EQ("prev", tokenizer2.current().text); string prev_trailing_comments; - vector<string> detached_comments; + std::vector<string> detached_comments; string next_leading_comments; tokenizer.NextWithComments(&prev_trailing_comments, &detached_comments, &next_leading_comments); diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 2d295510..efd421e6 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -523,13 +523,13 @@ class Map { typedef size_t size_type; typedef hash<Key> hasher; - explicit Map(bool old_style = true) + explicit Map(bool old_style = false) : arena_(NULL), default_enum_value_(0), old_style_(old_style) { Init(); } - explicit Map(Arena* arena, bool old_style = true) + explicit Map(Arena* arena, bool old_style = false) : arena_(arena), default_enum_value_(0), old_style_(old_style) { @@ -543,7 +543,7 @@ class Map { insert(other.begin(), other.end()); } template <class InputIt> - Map(const InputIt& first, const InputIt& last, bool old_style = true) + Map(const InputIt& first, const InputIt& last, bool old_style = false) : arena_(NULL), default_enum_value_(0), old_style_(old_style) { @@ -654,7 +654,8 @@ class Map { // To support Visual Studio 2008 size_type max_size() const { - return std::numeric_limits<size_type>::max(); + // parentheses around (std::...:max) prevents macro warning of max() + return (std::numeric_limits<size_type>::max)(); } // To support gcc-4.4, which does not properly @@ -1084,8 +1085,9 @@ class Map { // index_of_first_non_null_, so we skip the code to update it. return InsertUniqueInTree(b, node); } + // parentheses around (std::min) prevents macro expansion of min(...) index_of_first_non_null_ = - std::min(index_of_first_non_null_, result.bucket_index_); + (std::min)(index_of_first_non_null_, result.bucket_index_); return result; } diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index abcd4529..07c24c02 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -244,14 +244,19 @@ class MapEntry : public MapEntryBase { // to distinguish instances of the same MapEntry class. static MapEntry* CreateDefaultInstance(const Descriptor* descriptor) { MapEntry* entry = new MapEntry; - const Reflection* reflection = new GeneratedMessageReflection( - descriptor, entry, offsets_, + ReflectionSchema schema = { + entry, + offsets_, + has_bits_, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _unknown_fields_), -1, - DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(MapEntry), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_)); + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_), + -1, + NULL, + -1, + sizeof(MapEntry)}; + const Reflection* reflection = new GeneratedMessageReflection( + descriptor, schema, DescriptorPool::generated_pool(), + MessageFactory::generated_factory()); entry->descriptor_ = descriptor; entry->reflection_ = reflection; entry->set_default_instance(entry); @@ -278,8 +283,8 @@ class MapEntry : public MapEntryBase { entry_lite_.set_default_instance(&default_instance->entry_lite_); } - static int offsets_[2]; - UnknownFieldSet _unknown_fields_; + static uint32 offsets_[2]; + static uint32 has_bits_[2]; InternalMetadataWithArena _internal_metadata_; MapEntry* default_instance_; EntryLiteType entry_lite_; @@ -297,12 +302,17 @@ class MapEntry : public MapEntryBase { template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, WireFormatLite::FieldType kValueFieldType, int default_enum_value> -int MapEntry<Key, Value, kKeyFieldType, kValueFieldType, +uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>::offsets_[2] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.key_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.value_), }; +template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType, + WireFormatLite::FieldType kValueFieldType, int default_enum_value> +uint32 MapEntry<Key, Value, kKeyFieldType, kValueFieldType, + default_enum_value>::has_bits_[2] = {0, 1}; + } // namespace internal } // namespace protobuf diff --git a/src/google/protobuf/map_entry_lite.h b/src/google/protobuf/map_entry_lite.h index 3fb58220..bb1d7e06 100644 --- a/src/google/protobuf/map_entry_lite.h +++ b/src/google/protobuf/map_entry_lite.h @@ -171,7 +171,7 @@ class MapEntryLite : public MessageLite { // need to care whether the value is unknown enum; // 4) missing key/value: missed key/value will have default value. caller // should take this entry as if key/value is set to default value. - tag = input->ReadTag(); + tag = input->ReadTagNoLastTag(); switch (tag) { case kKeyTag: if (!KeyTypeHandler::Read(input, mutable_key())) { @@ -333,7 +333,7 @@ class MapEntryLite : public MessageLite { int size; input->GetDirectBufferPointerInline(&data, &size); // We could use memcmp here, but we don't bother. The tag is one byte. - assert(kTagSize == 1); + GOOGLE_COMPILE_ASSERT(kTagSize == 1, tag_size_error); if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) { typename Map::size_type size = map_->size(); value_ptr_ = &(*map_)[key_]; @@ -357,15 +357,17 @@ class MapEntryLite : public MessageLite { entry_.reset(mf_->NewEntry()); *entry_->mutable_key() = key_; - if (!entry_->MergePartialFromCodedStream(input)) return false; - return UseKeyAndValueFromEntry(); + const bool result = entry_->MergePartialFromCodedStream(input); + if (result) UseKeyAndValueFromEntry(); + if (entry_->GetArena() != NULL) entry_.release(); + return result; } const Key& key() const { return key_; } const Value& value() const { return *value_ptr_; } private: - bool UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD { + void UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD { // Update key_ in case we need it later (because key() is called). // This is potentially inefficient, especially if the key is // expensive to copy (e.g., a long string), but this is a cold @@ -377,8 +379,6 @@ class MapEntryLite : public MessageLite { ValueTypeHandler::kWireType == WireFormatLite::WIRETYPE_LENGTH_DELIMITED, Value>::Move(entry_->mutable_value(), value_ptr_); - if (entry_->GetArena() != NULL) entry_.release(); - return true; } // After reading a key and value successfully, and inserting that data @@ -400,15 +400,18 @@ class MapEntryLite : public MessageLite { ValueMover::Move(value_ptr_, entry_->mutable_value()); map_->erase(key_); KeyMover::Move(&key_, entry_->mutable_key()); - if (!entry_->MergePartialFromCodedStream(input)) return false; - return UseKeyAndValueFromEntry(); + const bool result = entry_->MergePartialFromCodedStream(input); + if (result) UseKeyAndValueFromEntry(); + if (entry_->GetArena() != NULL) entry_.release(); + return result; } MapField* const mf_; Map* const map_; Key key_; Value* value_ptr_; - // On the fast path entry_ is not used. + // On the fast path entry_ is not used. And, when entry_ is used, it's set + // to mf_->NewEntry(), so in the arena case we must call entry_.release. google::protobuf::scoped_ptr<MapEntryLite> entry_; }; diff --git a/src/google/protobuf/map_field_lite.h b/src/google/protobuf/map_field_lite.h index a9f30f59..cb0a4a45 100644 --- a/src/google/protobuf/map_field_lite.h +++ b/src/google/protobuf/map_field_lite.h @@ -68,13 +68,14 @@ class MapFieldLite { // Set default enum value only for proto2 map field whose value is enum type. void SetDefaultEnumValue(); - // Used in the implementation of parsing. Caller should take the ownership. + // Used in the implementation of parsing. Caller should take the ownership iff + // arena_ is NULL. EntryType* NewEntry() const; // Used in the implementation of serializing enum value type. Caller should - // take the ownership. + // take the ownership iff arena_ is NULL. EntryType* NewEnumEntryWrapper(const Key& key, const T t) const; // Used in the implementation of serializing other value types. Caller should - // take the ownership. + // take the ownership iff arena_ is NULL. EntryType* NewEntryWrapper(const Key& key, const T& t) const; protected: diff --git a/src/google/protobuf/map_proto2_unittest.proto b/src/google/protobuf/map_proto2_unittest.proto index ddc2a582..e9360a5a 100644 --- a/src/google/protobuf/map_proto2_unittest.proto +++ b/src/google/protobuf/map_proto2_unittest.proto @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. syntax = "proto2"; - +option cc_enable_arenas = true; import "google/protobuf/unittest_import.proto"; diff --git a/src/google/protobuf/map_test.cc b/src/google/protobuf/map_test.cc index 03954e75..d0a34d01 100644 --- a/src/google/protobuf/map_test.cc +++ b/src/google/protobuf/map_test.cc @@ -298,7 +298,7 @@ TEST_P(MapImplTest, IteratorBasic) { template <typename Iterator> static int64 median(Iterator i0, Iterator i1) { - vector<int64> v(i0, i1); + std::vector<int64> v(i0, i1); std::nth_element(v.begin(), v.begin() + v.size() / 2, v.end()); return v[v.size() / 2]; } @@ -334,7 +334,7 @@ TEST_P(MapImplTest, BeginIsFast) { GOOGLE_DCHECK_GE(last_key, 0); map[last_key] = last_key ^ 1; } - vector<int64> times; + std::vector<int64> times; // We're going to do map.erase(map.begin()) over and over again. But, // just in case one iteration is fast compared to the granularity of // our time keeping, we measure kChunkSize iterations per outer-loop iter. @@ -379,7 +379,7 @@ TEST_P(MapImplTest, HashFlood) { // 1024 (or 512 or 2048 or ...) entries. This assumes that map_ uses powers // of 2 for table sizes, and that it's sufficient to "flood" with respect to // the low bits of the output of map_.hash_function(). - vector<int64> times; + std::vector<int64> times; std::set<int>::iterator it = s.begin(); int count = 0; do { @@ -506,7 +506,7 @@ static void StressTestIterators(int n, bool test_old_style_proto2_maps) { // Finally, ensure erase(iterator) doesn't reorder anything, because that is // what its documentation says. m[last_key] = m[last_key ^ 999] = 0; - vector<Map<int, int>::iterator> v; + std::vector<Map<int, int>::iterator> v; v.reserve(m.size()); int position_of_last_key = 0; for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it) { @@ -563,7 +563,7 @@ TEST_P(MapImplTest, EraseRevalidates) { map_[3] = map_[13] = map_[20] = 0; const int initial_size = map_.size(); EXPECT_EQ(3, initial_size); - vector<Map<int, int>::iterator> v; + std::vector<Map<int, int>::iterator> v; for (Map<int, int>::iterator it = map_.begin(); it != map_.end(); ++it) { v.push_back(it); } @@ -2437,7 +2437,7 @@ TEST(GeneratedMapFieldReflectionTest, SwapFields) { MapTestUtil::SetMapFields(&message2); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; const Reflection* reflection = message1.GetReflection(); reflection->ListFields(message2, &fields); reflection->SwapFields(&message1, &message2, fields); @@ -2873,6 +2873,33 @@ TEST(WireFormatForMapFieldTest, MapParseHelpers) { // Deterministic Serialization Test ========================================== template <typename T> +static string DeterministicSerializationWithSerializePartialToCodedStream( + const T& t) { + const int size = t.ByteSize(); + string result(size, '\0'); + io::ArrayOutputStream array_stream(string_as_array(&result), size); + io::CodedOutputStream output_stream(&array_stream); + output_stream.SetSerializationDeterministic(true); + t.SerializePartialToCodedStream(&output_stream); + EXPECT_FALSE(output_stream.HadError()); + EXPECT_EQ(size, output_stream.ByteCount()); + return result; +} + +template <typename T> +static string DeterministicSerializationWithSerializeToCodedStream(const T& t) { + const int size = t.ByteSize(); + string result(size, '\0'); + io::ArrayOutputStream array_stream(string_as_array(&result), size); + io::CodedOutputStream output_stream(&array_stream); + output_stream.SetSerializationDeterministic(true); + t.SerializeToCodedStream(&output_stream); + EXPECT_FALSE(output_stream.HadError()); + EXPECT_EQ(size, output_stream.ByteCount()); + return result; +} + +template <typename T> static string DeterministicSerialization(const T& t) { const int size = t.ByteSize(); string result(size, '\0'); @@ -2882,6 +2909,9 @@ static string DeterministicSerialization(const T& t) { t.SerializeWithCachedSizes(&output_stream); EXPECT_FALSE(output_stream.HadError()); EXPECT_EQ(size, output_stream.ByteCount()); + EXPECT_EQ(result, DeterministicSerializationWithSerializeToCodedStream(t)); + EXPECT_EQ(result, + DeterministicSerializationWithSerializePartialToCodedStream(t)); return result; } @@ -2983,6 +3013,18 @@ TEST(TextFormatMapTest, Sorted) { EXPECT_EQ(message2.DebugString(), expected_text); } +TEST(TextFormatMapTest, ParseCorruptedString) { + string serialized_message; + GOOGLE_CHECK_OK(File::GetContents( + TestSourceDir() + + "/google/protobuf/testdata/golden_message_maps", + &serialized_message, true)); + protobuf_unittest::TestMaps message; + GOOGLE_CHECK(message.ParseFromString(serialized_message)); + TestParseCorruptedString<protobuf_unittest::TestMaps, true>(message); + TestParseCorruptedString<protobuf_unittest::TestMaps, false>(message); +} + // arena support ================================================= TEST(ArenaTest, ParsingAndSerializingNoHeapAllocation) { diff --git a/src/google/protobuf/map_test_util.cc b/src/google/protobuf/map_test_util.cc index ae094647..3dd6aae5 100644 --- a/src/google/protobuf/map_test_util.cc +++ b/src/google/protobuf/map_test_util.cc @@ -867,7 +867,7 @@ void MapReflectionTester::RemoveLastMapsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -880,7 +880,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -896,7 +896,7 @@ void MapReflectionTester::ReleaseLastMapsViaReflection( void MapReflectionTester::SwapMapsViaReflection(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i = 0; i < output.size(); ++i) { const FieldDescriptor* field = output[i]; diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index a21c92d9..ac987cbc 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -556,7 +556,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::MapEntryAccessorType& \ MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ Type>::GetExternalReference(const TypeOnMemory& value) { \ - return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ + return value.Get(); \ } \ template <typename Type> \ inline int \ @@ -581,11 +581,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, arena); \ } \ template <typename Type> \ - inline void \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value, \ - Arena* arena, \ - int default_enum) { \ + inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ + ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ + int default_enum) { \ Clear(value, arena); \ } \ template <typename Type> \ @@ -609,11 +607,9 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, &::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ } \ template <typename Type> \ - inline void \ - MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ - Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, \ - Arena* arena) { \ + inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>:: \ + InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ + int default_enum_value, Arena* arena) { \ Initialize(value, arena); \ } \ template <typename Type> \ @@ -631,7 +627,7 @@ inline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::DefaultIfNotInitialized(const TypeOnMemory& value, \ const TypeOnMemory& \ default_value) { \ - return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); \ + return value.Get(); \ } \ template <typename Type> \ inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, \ diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index c8de458c..a5a7feb6 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -96,12 +96,12 @@ bool Message::IsInitialized() const { return ReflectionOps::IsInitialized(*this); } -void Message::FindInitializationErrors(vector<string>* errors) const { +void Message::FindInitializationErrors(std::vector<string>* errors) const { return ReflectionOps::FindInitializationErrors(*this, "", errors); } string Message::InitializationErrorString() const { - vector<string> errors; + std::vector<string> errors; FindInitializationErrors(&errors); return Join(errors, ", "); } @@ -225,38 +225,6 @@ void* Reflection::MutableRawRepeatedString( } -// Default EnumValue API implementations. Real reflection implementations should -// override these. However, there are several legacy implementations that do -// not, and cannot easily be changed at the same time as the Reflection API, so -// we provide these for now. -// TODO: Remove these once all Reflection implementations are updated. -int Reflection::GetEnumValue(const Message& message, - const FieldDescriptor* field) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; - return 0; -} -void Reflection::SetEnumValue(Message* message, - const FieldDescriptor* field, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} -int Reflection::GetRepeatedEnumValue( - const Message& message, - const FieldDescriptor* field, int index) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; - return 0; -} -void Reflection::SetRepeatedEnumValue(Message* message, - const FieldDescriptor* field, int index, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} -void Reflection::AddEnumValue(Message* message, - const FieldDescriptor* field, - int value) const { - GOOGLE_LOG(FATAL) << "Unimplemented EnumValue API."; -} - MapIterator Reflection::MapBegin( Message* message, const FieldDescriptor* field) const { diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index bee25f77..872df7a9 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -519,7 +519,7 @@ class LIBPROTOBUF_EXPORT Reflection { // will only be present when the new unknown-enum-value semantics are enabled // for a message.) virtual int GetEnumValue( - const Message& message, const FieldDescriptor* field) const; + const Message& message, const FieldDescriptor* field) const = 0; // See MutableMessage() for the meaning of the "factory" parameter. virtual const Message& GetMessage(const Message& message, @@ -575,7 +575,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void SetEnumValue(Message* message, const FieldDescriptor* field, - int value) const; + int value) const = 0; // Get a mutable pointer to a field with a message type. If a MessageFactory // is provided, it will be used to construct instances of the sub-message; @@ -646,7 +646,7 @@ class LIBPROTOBUF_EXPORT Reflection { // for a message.) virtual int GetRepeatedEnumValue( const Message& message, - const FieldDescriptor* field, int index) const; + const FieldDescriptor* field, int index) const = 0; virtual const Message& GetRepeatedMessage( const Message& message, const FieldDescriptor* field, int index) const = 0; @@ -693,7 +693,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void SetRepeatedEnumValue(Message* message, const FieldDescriptor* field, int index, - int value) const; + int value) const = 0; // Get a mutable pointer to an element of a repeated field with a message // type. virtual Message* MutableRepeatedMessage( @@ -729,7 +729,7 @@ class LIBPROTOBUF_EXPORT Reflection { // messages with new unknown-enum-value semantics. virtual void AddEnumValue(Message* message, const FieldDescriptor* field, - int value) const; + int value) const = 0; // See MutableMessage() for comments on the "factory" parameter. virtual Message* AddMessage(Message* message, const FieldDescriptor* field, @@ -848,34 +848,31 @@ class LIBPROTOBUF_EXPORT Reflection { // downgrade to a compatible value or use the UnknownFieldSet if not. For // example: // - // int new_value = GetValueFromApplicationLogic(); - // if (reflection->SupportsUnknownEnumValues()) { + // int new_value = GetValueFromApplicationLogic(); + // if (reflection->SupportsUnknownEnumValues()) { // reflection->SetEnumValue(message, field, new_value); - // } else { + // } else { // if (field_descriptor->enum_type()-> // FindValueByNumver(new_value) != NULL) { - // reflection->SetEnumValue(message, field, new_value); + // reflection->SetEnumValue(message, field, new_value); // } else if (emit_unknown_enum_values) { - // reflection->MutableUnknownFields(message)->AddVarint( - // field->number(), - // new_value); + // reflection->MutableUnknownFields(message)->AddVarint( + // field->number(), new_value); // } else { - // // convert value to a compatible/default value. - // new_value = CompatibleDowngrade(new_value); - // reflection->SetEnumValue(message, field, new_value); + // // convert value to a compatible/default value. + // new_value = CompatibleDowngrade(new_value); + // reflection->SetEnumValue(message, field, new_value); // } - // } + // } virtual bool SupportsUnknownEnumValues() const { return false; } // Returns the MessageFactory associated with this message. This can be // useful for determining if a message is a generated message or not, for // example: - // - // if (message->GetReflection()->GetMessageFactory() == - // google::protobuf::MessageFactory::generated_factory()) { - // // This is a generated message. - // } - // + // if (message->GetReflection()->GetMessageFactory() == + // google::protobuf::MessageFactory::generated_factory()) { + // // This is a generated message. + // } // It can also be used to create more messages of this type, though // Message::New() is an easier way to accomplish this. virtual MessageFactory* GetMessageFactory() const; diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 1c6786db..a42e9ec3 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -34,6 +34,7 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <climits> + #include <google/protobuf/arena.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message_lite.h> @@ -238,21 +239,18 @@ bool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const { return SerializePartialToCodedStream(output); } -size_t MessageLite::ByteSizeLong() const { - return internal::FromIntSize(ByteSize()); -} - bool MessageLite::SerializePartialToCodedStream( io::CodedOutputStream* output) const { const size_t size = ByteSizeLong(); // Force size to be cached. if (size > INT_MAX) { - GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << size; return false; } uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size); if (buffer != NULL) { - uint8* end = SerializeWithCachedSizesToArray(buffer); + uint8* end = InternalSerializeWithCachedSizesToArray( + output->IsSerializationDeterministic(), buffer); if (end - buffer != size) { ByteSizeConsistencyError(size, ByteSizeLong(), end - buffer, *this); } @@ -295,7 +293,7 @@ bool MessageLite::AppendPartialToString(string* output) const { size_t old_size = output->size(); size_t byte_size = ByteSizeLong(); if (byte_size > INT_MAX) { - GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB."; + GOOGLE_LOG(ERROR) << "Exceeded maximum protobuf size of 2GB: " << byte_size; return false; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 88455669..d5de8cdb 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -40,6 +40,7 @@ #define GOOGLE_PROTOBUF_MESSAGE_LITE_H__ #include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/logging.h> namespace google { @@ -239,17 +240,22 @@ class LIBPROTOBUF_EXPORT MessageLite { bool AppendPartialToString(string* output) const; // Computes the serialized size of the message. This recursively calls - // ByteSize() on all embedded messages. Subclasses MUST override either - // ByteSize() or ByteSizeLong() (overriding both is fine). + // ByteSizeLong() on all embedded messages. // - // ByteSize() is generally linear in the number of fields defined for the + // ByteSizeLong() is generally linear in the number of fields defined for the // proto. - virtual int ByteSize() const { return static_cast<int>(ByteSizeLong()); } - virtual size_t ByteSizeLong() const; + virtual size_t ByteSizeLong() const = 0; - // Serializes the message without recomputing the size. The message must - // not have changed since the last call to ByteSize(); if it has, the results - // are undefined. + // Legacy ByteSize() API. + int ByteSize() const { + size_t result = ByteSizeLong(); + GOOGLE_DCHECK_LE(result, static_cast<size_t>(INT_MAX)); + return static_cast<int>(result); + } + + // Serializes the message without recomputing the size. The message must not + // have changed since the last call to ByteSize(), and the value returned by + // ByteSize must be non-negative. Otherwise the results are undefined. virtual void SerializeWithCachedSizes( io::CodedOutputStream* output) const = 0; diff --git a/src/google/protobuf/message_unittest.cc b/src/google/protobuf/message_unittest.cc index 3af05808..de39fff8 100644 --- a/src/google/protobuf/message_unittest.cc +++ b/src/google/protobuf/message_unittest.cc @@ -48,6 +48,7 @@ #include <google/protobuf/test_util.h> #include <google/protobuf/unittest.pb.h> #include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> @@ -182,7 +183,7 @@ TEST(MessageTest, ParseHelpers) { TEST(MessageTest, ParseFailsIfNotInitialized) { unittest::TestRequired message; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -286,28 +287,96 @@ TEST(MessageTest, CheckBigOverflow) { #endif // PROTOBUF_HAS_DEATH_TEST namespace { - -class NegativeByteSize : public unittest::TestRequired { +// An input stream that repeats a string's content for a number of times. It +// helps us create a really large input without consuming too much memory. Used +// to test the parsing behavior when the input size exceeds 2G or close to it. +class RepeatedInputStream : public io::ZeroCopyInputStream { public: - virtual int ByteSize() const { return -1; } + RepeatedInputStream(const string& data, size_t count) + : data_(data), count_(count), position_(0), total_byte_count_(0) {} + + virtual bool Next(const void** data, int* size) { + if (position_ == data_.size()) { + if (--count_ == 0) { + return false; + } + position_ = 0; + } + *data = &data_[position_]; + *size = static_cast<int>(data_.size() - position_); + position_ = data_.size(); + total_byte_count_ += *size; + return true; + } - // The implementation of ByteSizeLong() from MessageLite, to simulate what - // would happen if TestRequired *hadn't* overridden it already. - virtual size_t ByteSizeLong() const { - return static_cast<unsigned int>(ByteSize()); + virtual void BackUp(int count) { + position_ -= static_cast<size_t>(count); + total_byte_count_ -= count; } -}; + virtual bool Skip(int count) { + while (count > 0) { + const void* data; + int size; + if (!Next(&data, &size)) { + break; + } + if (size >= count) { + BackUp(size - count); + return true; + } else { + count -= size; + } + } + return false; + } + + virtual int64 ByteCount() const { return total_byte_count_; } + + private: + string data_; + size_t count_; // The number of strings that haven't been consuemd. + size_t position_; // Position in the string for the next read. + int64 total_byte_count_; +}; } // namespace -TEST(MessageTest, SerializationFailsOnNegativeByteSize) { - NegativeByteSize message; - string string_output; - EXPECT_FALSE(message.AppendPartialToString(&string_output)); +TEST(MessageTest, TestParseMessagesCloseTo2G) { + // Create a message with a large string field. + string value = string(64 * 1024 * 1024, 'x'); + protobuf_unittest::TestAllTypes message; + message.set_optional_string(value); + + // Repeat this message in the input stream to make the total input size + // close to 2G. + string data = message.SerializeAsString(); + size_t count = static_cast<size_t>(kint32max) / data.size(); + RepeatedInputStream input(data, count); + + // The parsing should succeed. + protobuf_unittest::TestAllTypes result; + EXPECT_TRUE(result.ParseFromZeroCopyStream(&input)); + + // When there are multiple occurences of a singulr field, the last one + // should win. + EXPECT_EQ(value, result.optional_string()); +} + +TEST(MessageTest, TestParseMessagesOver2G) { + // Create a message with a large string field. + string value = string(64 * 1024 * 1024, 'x'); + protobuf_unittest::TestAllTypes message; + message.set_optional_string(value); + + // Repeat this message in the input stream to make the total input size + // larger than 2G. + string data = message.SerializeAsString(); + size_t count = static_cast<size_t>(kint32max) / data.size() + 1; + RepeatedInputStream input(data, count); - io::ArrayOutputStream coded_raw_output(NULL, 100); - io::CodedOutputStream coded_output(&coded_raw_output); - EXPECT_FALSE(message.SerializePartialToCodedStream(&coded_output)); + // The parsing should fail. + protobuf_unittest::TestAllTypes result; + EXPECT_FALSE(result.ParseFromZeroCopyStream(&input)); } TEST(MessageTest, BypassInitializationCheckOnSerialize) { @@ -319,7 +388,7 @@ TEST(MessageTest, BypassInitializationCheckOnSerialize) { TEST(MessageTest, FindInitializationErrors) { unittest::TestRequired message; - vector<string> errors; + std::vector<string> errors; message.FindInitializationErrors(&errors); ASSERT_EQ(3, errors.size()); EXPECT_EQ("a", errors[0]); diff --git a/src/google/protobuf/metadata.h b/src/google/protobuf/metadata.h index 6e3eef63..f9257534 100644 --- a/src/google/protobuf/metadata.h +++ b/src/google/protobuf/metadata.h @@ -40,6 +40,8 @@ #include <google/protobuf/stubs/common.h> #include <google/protobuf/arena.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/generated_message_util.h> #include <google/protobuf/unknown_field_set.h> namespace google { @@ -56,30 +58,30 @@ namespace internal { // The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to // indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container // pointer. -class LIBPROTOBUF_EXPORT InternalMetadataWithArena { +template <class T, class Derived> +class InternalMetadataWithArenaBase { public: - InternalMetadataWithArena() : ptr_(NULL) {} - explicit InternalMetadataWithArena(Arena* arena) - : ptr_ (arena) {} + InternalMetadataWithArenaBase() : ptr_(NULL) {} + explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {} - ~InternalMetadataWithArena() { + ~InternalMetadataWithArenaBase() { if (have_unknown_fields() && arena() == NULL) { delete PtrValue<Container>(); } ptr_ = NULL; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue<Container>()->unknown_fields_; + return PtrValue<Container>()->unknown_fields; } else { - return *UnknownFieldSet::default_instance(); + return Derived::default_instance(); } } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() { if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) { - return &PtrValue<Container>()->unknown_fields_; + return &PtrValue<Container>()->unknown_fields; } else { return mutable_unknown_fields_slow(); } @@ -87,7 +89,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const { if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) { - return PtrValue<Container>()->arena_; + return PtrValue<Container>()->arena; } else { return PtrValue<Arena>(); } @@ -97,7 +99,7 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { return PtrTag() == kTagContainer; } - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) { + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) { // Semantics here are that we swap only the unknown fields, not the arena // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in @@ -105,7 +107,19 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { // cannot simply swap ptr_ and then restore the arena pointers. We reuse // UFS's swap implementation instead. if (have_unknown_fields() || other->have_unknown_fields()) { - mutable_unknown_fields()->Swap(other->mutable_unknown_fields()); + static_cast<Derived*>(this)->DoSwap(other->mutable_unknown_fields()); + } + } + + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) { + if (other.have_unknown_fields()) { + static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields()); + } + } + + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Clear() { + if (have_unknown_fields()) { + static_cast<Derived*>(this)->DoClear(); } } @@ -131,24 +145,78 @@ class LIBPROTOBUF_EXPORT InternalMetadataWithArena { return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask; } - template<typename T> T* PtrValue() const { - return reinterpret_cast<T*>( + template<typename U> U* PtrValue() const { + return reinterpret_cast<U*>( reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask); } // If ptr_'s tag is kTagContainer, it points to an instance of this struct. struct Container { - UnknownFieldSet unknown_fields_; - Arena* arena_; + T unknown_fields; + Arena* arena; }; - GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() { + GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); Container* container = Arena::Create<Container>(my_arena); ptr_ = reinterpret_cast<void*>( reinterpret_cast<intptr_t>(container) | kTagContainer); - container->arena_ = my_arena; - return &(container->unknown_fields_); + container->arena = my_arena; + return &(container->unknown_fields); + } +}; + +class InternalMetadataWithArena + : public InternalMetadataWithArenaBase<UnknownFieldSet, + InternalMetadataWithArena> { + public: + InternalMetadataWithArena() {} + explicit InternalMetadataWithArena(Arena* arena) + : InternalMetadataWithArenaBase(arena) {} + + void DoSwap(UnknownFieldSet* other) { + mutable_unknown_fields()->Swap(other); + } + + void DoMergeFrom(const UnknownFieldSet& other) { + mutable_unknown_fields()->MergeFrom(other); + } + + void DoClear() { + mutable_unknown_fields()->Clear(); + } + + static const UnknownFieldSet& default_instance() { + return *UnknownFieldSet::default_instance(); + } +}; + +// We store unknown fields as a string right now, because there is currently no +// good interface for reading unknown fields into an ArenaString. We may want +// to revisit this to allow unknown fields to be parsed onto the Arena. +class InternalMetadataWithArenaLite + : public InternalMetadataWithArenaBase<string, + InternalMetadataWithArenaLite> { + public: + InternalMetadataWithArenaLite() {} + + explicit InternalMetadataWithArenaLite(Arena* arena) + : InternalMetadataWithArenaBase(arena) {} + + void DoSwap(string* other) { + mutable_unknown_fields()->swap(*other); + } + + void DoMergeFrom(const string& other) { + mutable_unknown_fields()->append(other); + } + + void DoClear() { + mutable_unknown_fields()->clear(); + } + + static const string& default_instance() { + return GetEmptyStringAlreadyInited(); } }; diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 4629dec2..bb9c7f8b 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -63,7 +63,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) { const Reflection* from_reflection = from.GetReflection(); const Reflection* to_reflection = to->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; from_reflection->ListFields(from, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -129,7 +129,7 @@ void ReflectionOps::Merge(const Message& from, Message* to) { void ReflectionOps::Clear(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); i++) { reflection->ClearField(message, fields[i]); @@ -152,7 +152,7 @@ bool ReflectionOps::IsInitialized(const Message& message) { } // Check that sub-messages are initialized. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -183,7 +183,7 @@ void ReflectionOps::DiscardUnknownFields(Message* message) { reflection->MutableUnknownFields(message)->Clear(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; @@ -224,7 +224,7 @@ static string SubMessagePrefix(const string& prefix, void ReflectionOps::FindInitializationErrors( const Message& message, const string& prefix, - vector<string>* errors) { + std::vector<string>* errors) { const Descriptor* descriptor = message.GetDescriptor(); const Reflection* reflection = message.GetReflection(); @@ -238,7 +238,7 @@ void ReflectionOps::FindInitializationErrors( } // Check sub-messages. - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { const FieldDescriptor* field = fields[i]; diff --git a/src/google/protobuf/reflection_ops_unittest.cc b/src/google/protobuf/reflection_ops_unittest.cc index 88d6bfb6..86453170 100644 --- a/src/google/protobuf/reflection_ops_unittest.cc +++ b/src/google/protobuf/reflection_ops_unittest.cc @@ -419,7 +419,7 @@ TEST(ReflectionOpsTest, OneofIsInitialized) { } static string FindInitializationErrors(const Message& message) { - vector<string> errors; + std::vector<string> errors; ReflectionOps::FindInitializationErrors(message, "", &errors); return Join(errors, ","); } diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 6ede0e1a..bbdef449 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -61,8 +61,9 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message_lite.h> -namespace google { +// Forward-declare these so that we can make them friends. +namespace google { namespace upb { namespace google_opensource { class GMR_Handlers; @@ -104,7 +105,7 @@ inline int CalculateReserve(Iter begin, Iter end) { // not ever use a RepeatedField directly; they will use the get-by-index, // set-by-index, and add accessors that are generated for all repeated fields. template <typename Element> -class RepeatedField { +class RepeatedField PROTOBUF_FINAL { public: RepeatedField(); explicit RepeatedField(Arena* arena); @@ -126,6 +127,8 @@ class RepeatedField { void Set(int index, const Element& value); void Add(const Element& value); + // Appends a new element and return a pointer to it. + // The new element is uninitialized if |Element| is a POD type. Element* Add(); // Remove the last element in the array. void RemoveLast(); @@ -138,7 +141,6 @@ class RepeatedField { void Clear(); void MergeFrom(const RepeatedField& other); - void UnsafeMergeFrom(const RepeatedField& other); void CopyFrom(const RepeatedField& other); // Reserve space to expand the field to at least the given size. If the @@ -149,6 +151,9 @@ class RepeatedField { void Truncate(int new_size); void AddAlreadyReserved(const Element& value); + // Appends a new element and return a pointer to it. + // The new element is uninitialized if |Element| is a POD type. + // Should be called only if Capacity() > Size(). Element* AddAlreadyReserved(); int Capacity() const; @@ -311,7 +316,7 @@ template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator; namespace internal { -// This is a helper template to copy an array of elements effeciently when they +// This is a helper template to copy an array of elements efficiently when they // have a trivial copy constructor, and correctly otherwise. This really // shouldn't be necessary, but our compiler doesn't optimize std::copy very // effectively. @@ -719,7 +724,7 @@ class LIBPROTOBUF_EXPORT StringTypeHandler { // RepeatedPtrField is like RepeatedField, but used for repeated strings or // Messages. template <typename Element> -class RepeatedPtrField : public internal::RepeatedPtrFieldBase { +class RepeatedPtrField PROTOBUF_FINAL : public internal::RepeatedPtrFieldBase { public: RepeatedPtrField(); explicit RepeatedPtrField(::google::protobuf::Arena* arena); @@ -752,7 +757,6 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { void Clear(); void MergeFrom(const RepeatedPtrField& other); - void UnsafeMergeFrom(const RepeatedPtrField& other) { MergeFrom(other); } void CopyFrom(const RepeatedPtrField& other); // Reserve space to expand the field to at least the given size. This only @@ -859,10 +863,10 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { // RepeatedPtrField. // It is also useful in legacy code that uses temporary ownership to avoid // copies. Example: - // RepeatedPtrField<T> temp_field; - // temp_field.AddAllocated(new T); - // ... // Do something with temp_field - // temp_field.ExtractSubrange(0, temp_field.size(), NULL); + // RepeatedPtrField<T> temp_field; + // temp_field.AddAllocated(new T); + // ... // Do something with temp_field + // temp_field.ExtractSubrange(0, temp_field.size(), NULL); // If you put temp_field on the arena this fails, because the ownership // transfers to the arena at the "AddAllocated" call and is not released // anymore causing a double delete. UnsafeArenaAddAllocated prevents this. @@ -944,17 +948,13 @@ class RepeatedPtrField : public internal::RepeatedPtrFieldBase { return GetArenaNoVirtual(); } - protected: - // Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only - // subclass it in one place as a hack for compatibility with proto1. The - // subclass needs to know about TypeHandler in order to call protected - // methods on RepeatedPtrFieldBase. + private: + // Note: RepeatedPtrField SHOULD NOT be subclassed by users. class TypeHandler; // Internal arena accessor expected by helpers in Arena. inline Arena* GetArenaNoVirtual() const; - private: // Implementations for ExtractSubrange(). The copying behavior must be // included only if the type supports the necessary operations (e.g., // MergeFrom()), so we must resolve this at compile time. ExtractSubrange() @@ -997,7 +997,12 @@ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other) : current_size_(0), total_size_(0), rep_(NULL) { - CopyFrom(other); + if (other.current_size_ != 0) { + Reserve(other.current_size_); + CopyArray(rep_->elements, + other.rep_->elements, other.current_size_); + current_size_ = other.current_size_; + } } template <typename Element> @@ -1138,7 +1143,8 @@ inline void RepeatedField<Element>::Clear() { } template <typename Element> -inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) { +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_, @@ -1148,12 +1154,6 @@ inline void RepeatedField<Element>::UnsafeMergeFrom(const RepeatedField& other) } template <typename Element> -inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) { - GOOGLE_CHECK_NE(&other, this); - UnsafeMergeFrom(other); -} - -template <typename Element> inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) { if (&other == this) return; Clear(); @@ -1292,7 +1292,7 @@ void RepeatedField<Element>::Reserve(int new_size) { Element* e = &rep_->elements[0]; Element* limit = &rep_->elements[total_size_]; for (; e < limit; e++) { - new (e) Element(); + new (e) Element; } if (current_size_ > 0) { MoveArray(rep_->elements, old_rep->elements, current_size_); @@ -1792,7 +1792,7 @@ template <typename Element> inline RepeatedPtrField<Element>::RepeatedPtrField( const RepeatedPtrField& other) : RepeatedPtrFieldBase() { - CopyFrom(other); + MergeFrom(other); } template <typename Element> @@ -2469,10 +2469,10 @@ AllocatedRepeatedPtrFieldBackInserter( // UnsafeArenaAddAllocated instead of AddAllocated. // This is slightly faster if that matters. It is also useful in legacy code // that uses temporary ownership to avoid copies. Example: -// RepeatedPtrField<T> temp_field; -// temp_field.AddAllocated(new T); -// ... // Do something with temp_field -// temp_field.ExtractSubrange(0, temp_field.size(), NULL); +// RepeatedPtrField<T> temp_field; +// temp_field.AddAllocated(new T); +// ... // Do something with temp_field +// temp_field.ExtractSubrange(0, temp_field.size(), NULL); // If you put temp_field on the arena this fails, because the ownership // transfers to the arena at the "AddAllocated" call and is not released anymore // causing a double delete. Using UnsafeArenaAddAllocated prevents this. diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index 33547146..ec1074c9 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -268,11 +268,13 @@ TEST(RepeatedField, MergeFrom) { } #ifdef PROTOBUF_HAS_DEATH_TEST +#ifndef NDEBUG TEST(RepeatedField, MergeFromSelf) { RepeatedField<int> me; me.Add(3); EXPECT_DEATH(me.MergeFrom(me), ""); } +#endif // NDEBUG #endif // PROTOBUF_HAS_DEATH_TEST TEST(RepeatedField, CopyFrom) { @@ -344,7 +346,7 @@ TEST(RepeatedField, CopyConstruct) { } TEST(RepeatedField, IteratorConstruct) { - vector<int> values; + std::vector<int> values; values.push_back(1); values.push_back(2); @@ -858,7 +860,7 @@ TEST(RepeatedPtrField, CopyConstruct) { } TEST(RepeatedPtrField, IteratorConstruct_String) { - vector<string> values; + std::vector<string> values; values.push_back("1"); values.push_back("2"); @@ -875,7 +877,7 @@ TEST(RepeatedPtrField, IteratorConstruct_String) { TEST(RepeatedPtrField, IteratorConstruct_Proto) { typedef TestAllTypes::NestedMessage Nested; - vector<Nested> values; + std::vector<Nested> values; values.push_back(Nested()); values.back().set_bb(1); values.push_back(Nested()); @@ -949,7 +951,7 @@ TEST(RepeatedPtrField, ExtractSubrange) { for (int num = 0; num <= sz; ++num) { for (int start = 0; start < sz - num; ++start) { for (int extra = 0; extra < 4; ++extra) { - vector<string*> subject; + std::vector<string*> subject; // Create an array with "sz" elements and "extra" cleared elements. RepeatedPtrField<string> field; @@ -1511,7 +1513,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, Nesteds) { TEST_F(RepeatedFieldInsertionIteratorsTest, AllocatedRepeatedPtrFieldWithStringIntData) { - vector<Nested*> data; + std::vector<Nested*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { Nested* new_data = new Nested; @@ -1530,7 +1532,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, AllocatedRepeatedPtrFieldWithString) { - vector<string*> data; + std::vector<string*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { string* new_data = new string; @@ -1548,7 +1550,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, UnsafeArenaAllocatedRepeatedPtrFieldWithStringIntData) { - vector<Nested*> data; + std::vector<Nested*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { Nested* new_data = new Nested; @@ -1567,7 +1569,7 @@ TEST_F(RepeatedFieldInsertionIteratorsTest, TEST_F(RepeatedFieldInsertionIteratorsTest, UnsafeArenaAllocatedRepeatedPtrFieldWithString) { - vector<string*> data; + std::vector<string*> data; TestAllTypes goldenproto; for (int i = 0; i < 10; ++i) { string* new_data = new string; diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 951a0bcc..b9e5a73b 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -19,84 +19,88 @@ namespace google { namespace protobuf { +class SourceContextDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> {}; +SourceContextDefaultTypeInternal _SourceContext_default_instance_; namespace { -const ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - SourceContext_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/source_context.proto"); - GOOGLE_CHECK(file != NULL); - SourceContext_descriptor_ = file->message_type(0); - static const int SourceContext_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_), }; - SourceContext_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - SourceContext_descriptor_, - SourceContext::internal_default_instance(), - SourceContext_offsets_, - -1, - -1, - -1, - sizeof(SourceContext), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(SourceContext)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_SourceContext_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/source_context.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - SourceContext_descriptor_, SourceContext::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() { - SourceContext_default_instance_.Shutdown(); - delete SourceContext_reflection_; + _SourceContext_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::internal::GetEmptyString(); - SourceContext_default_instance_.DefaultConstruct(); - SourceContext_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _SourceContext_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + static const char descriptor[] = { + "\n$google/protobuf/source_context.proto\022\017" + "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" + "_name\030\001 \001(\tB\225\001\n\023com.google.protobufB\022Sou" + "rceContextProtoP\001ZAgoogle.golang.org/gen" + "proto/protobuf/source_context;source_con" + "text\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTy" + "pesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n$google/protobuf/source_context.proto\022\017" - "google.protobuf\"\"\n\rSourceContext\022\021\n\tfile" - "_name\030\001 \001(\tBR\n\023com.google.protobufB\022Sour" - "ceContextProtoP\001\242\002\003GPB\252\002\036Google.Protobuf" - ".WellKnownTypesb\006proto3", 183); + descriptor, 251); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/source_context.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto); @@ -114,16 +118,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto } } static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -132,19 +126,21 @@ const int SourceContext::kFileNameFieldNumber; SourceContext::SourceContext() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.SourceContext) } - -void SourceContext::InitAsDefaultInstance() { -} - SourceContext::SourceContext(const SourceContext& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.file_name().size() > 0) { + file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) } @@ -169,7 +165,7 @@ void SourceContext::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* SourceContext::descriptor() { protobuf_AssignDescriptorsOnce(); - return SourceContext_descriptor_; + return file_level_metadata[0].descriptor; } const SourceContext& SourceContext::default_instance() { @@ -177,8 +173,6 @@ const SourceContext& SourceContext::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_; - SourceContext* SourceContext::New(::google::protobuf::Arena* arena) const { SourceContext* n = new SourceContext; if (arena != NULL) { @@ -198,13 +192,13 @@ bool SourceContext::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.SourceContext) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string file_name = 1; + // string file_name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_file_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -214,7 +208,6 @@ bool SourceContext::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -242,7 +235,7 @@ failure: void SourceContext::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext) - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->file_name().data(), this->file_name().length(), @@ -259,7 +252,7 @@ void SourceContext::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext) - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->file_name().data(), this->file_name().length(), @@ -278,7 +271,7 @@ size_t SourceContext::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext) size_t total_size = 0; - // optional string file_name = 1; + // string file_name = 1; if (this->file_name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -294,7 +287,7 @@ size_t SourceContext::ByteSizeLong() const { void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const SourceContext* source = ::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>( &from); @@ -303,21 +296,14 @@ void SourceContext::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void SourceContext::MergeFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void SourceContext::UnsafeMergeFrom(const SourceContext& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.file_name().size() > 0) { file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_); @@ -335,11 +321,10 @@ void SourceContext::CopyFrom(const SourceContext& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool SourceContext::IsInitialized() const { - return true; } @@ -349,28 +334,24 @@ void SourceContext::Swap(SourceContext* other) { } void SourceContext::InternalSwap(SourceContext* other) { file_name_.Swap(&other->file_name_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata SourceContext::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = SourceContext_descriptor_; - metadata.reflection = SourceContext_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // SourceContext -// optional string file_name = 1; +// string file_name = 1; void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } const ::std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) - return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return file_name_.GetNoArena(); } void SourceContext::set_file_name(const ::std::string& value) { @@ -408,9 +389,6 @@ void SourceContext::set_allocated_file_name(::std::string* file_name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } -inline const SourceContext* SourceContext::internal_default_instance() { - return &SourceContext_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 18a56941..281249d9 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); - -class SourceContext; // =================================================================== @@ -57,55 +60,58 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ static const ::google::protobuf::Descriptor* descriptor(); static const SourceContext& default_instance(); - static const SourceContext* internal_default_instance(); + static inline const SourceContext* internal_default_instance() { + return reinterpret_cast<const SourceContext*>( + &_SourceContext_default_instance_); + } void Swap(SourceContext* other); // implements Message ---------------------------------------------- - inline SourceContext* New() const { return New(NULL); } + inline SourceContext* New() const PROTOBUF_FINAL { return New(NULL); } - SourceContext* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + SourceContext* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const SourceContext& from); void MergeFrom(const SourceContext& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(SourceContext* other); - void UnsafeMergeFrom(const SourceContext& from); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { - return _internal_metadata_.arena(); + return NULL; } inline void* MaybeArenaPtr() const { - return _internal_metadata_.raw_arena_ptr(); + return NULL; } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string file_name = 1; + // string file_name = 1; void clear_file_name(); static const int kFileNameFieldNumber = 1; const ::std::string& file_name() const; @@ -124,13 +130,10 @@ class LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @ mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fsource_5fcontext_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> SourceContext_default_instance_; - // =================================================================== @@ -139,13 +142,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<SourceContext> Source #if !PROTOBUF_INLINE_NOT_IN_HEADERS // SourceContext -// optional string file_name = 1; +// string file_name = 1; inline void SourceContext::clear_file_name() { file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); } inline const ::std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) - return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return file_name_.GetNoArena(); } inline void SourceContext::set_file_name(const ::std::string& value) { @@ -183,13 +186,11 @@ inline void SourceContext::set_allocated_file_name(::std::string* file_name) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name) } -inline const SourceContext* SourceContext::internal_default_instance() { - return &SourceContext_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/source_context.proto b/src/google/protobuf/source_context.proto index 79137ce8..f3b2c966 100644 --- a/src/google/protobuf/source_context.proto +++ b/src/google/protobuf/source_context.proto @@ -37,6 +37,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "SourceContextProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; // `SourceContext` represents information about the source of a // protobuf element, like the file in which it is defined. diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index c8f5af90..8bd2f8be 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -19,16 +19,17 @@ namespace google { namespace protobuf { +class StructDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Struct> {}; +StructDefaultTypeInternal _Struct_default_instance_; +class ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Value> {}; +ValueDefaultTypeInternal _Value_default_instance_; +class ListValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<ListValue> {}; +ListValueDefaultTypeInternal _ListValue_default_instance_; namespace { -const ::google::protobuf::Descriptor* Struct_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Struct_reflection_ = NULL; -const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Value_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[4]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; struct ValueOneofInstance { int null_value_; double number_value_; @@ -36,157 +37,138 @@ struct ValueOneofInstance { bool bool_value_; const ::google::protobuf::Struct* struct_value_; const ::google::protobuf::ListValue* list_value_; -}* Value_default_oneof_instance_ = NULL; -const ::google::protobuf::Descriptor* ListValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - ListValue_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* NullValue_descriptor_ = NULL; +} Value_default_oneof_instance_; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/struct.proto"); - GOOGLE_CHECK(file != NULL); - Struct_descriptor_ = file->message_type(0); - static const int Struct_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_), - }; - Struct_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Struct_descriptor_, - Struct::internal_default_instance(), - Struct_offsets_, - -1, - -1, - -1, - sizeof(Struct), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_)); - Struct_FieldsEntry_descriptor_ = Struct_descriptor_->nested_type(0); - Value_descriptor_ = file->message_type(1); - static const int Value_offsets_[7] = { - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, null_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, number_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, string_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, bool_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, struct_value_), - PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, list_value_), + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_), + ~0u, // no _extensions_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), null_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), number_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), string_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), bool_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), struct_value_), + PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET((&Value_default_oneof_instance_), list_value_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_), - }; - Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Value_descriptor_, - Value::internal_default_instance(), - Value_offsets_, - -1, - -1, - -1, - Value_default_oneof_instance_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]), - sizeof(Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_)); - ListValue_descriptor_ = file->message_type(2); - static const int ListValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_), }; - ListValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - ListValue_descriptor_, - ListValue::internal_default_instance(), - ListValue_offsets_, - -1, - -1, - -1, - sizeof(ListValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_)); - NullValue_descriptor_ = file->enum_type(0); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Struct)}, + { 5, -1, sizeof(Value)}, + { 16, -1, sizeof(ListValue)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Struct_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Value_default_instance_), &Value_default_oneof_instance_}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_ListValue_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/struct.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 4); + const ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_descriptor_, Struct::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Struct_FieldsEntry_descriptor_, + Struct_FieldsEntry_descriptor, ::google::protobuf::internal::MapEntry< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0>::CreateDefaultInstance( - Struct_FieldsEntry_descriptor_)); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Value_descriptor_, Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - ListValue_descriptor_, ListValue::internal_default_instance()); + Struct_FieldsEntry_descriptor)); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() { - Struct_default_instance_.Shutdown(); - delete Struct_reflection_; - Value_default_instance_.Shutdown(); - delete Value_default_oneof_instance_; - delete Value_reflection_; - ListValue_default_instance_.Shutdown(); - delete ListValue_reflection_; + _Struct_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Value_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _ListValue_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::internal::GetEmptyString(); - Struct_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Value_default_instance_.DefaultConstruct(); - Value_default_oneof_instance_ = new ValueOneofInstance(); - ListValue_default_instance_.DefaultConstruct(); - Struct_default_instance_.get_mutable()->InitAsDefaultInstance(); - Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - ListValue_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Struct_default_instance_.DefaultConstruct(); + _Value_default_instance_.DefaultConstruct(); + _ListValue_default_instance_.DefaultConstruct(); + Value_default_oneof_instance_.null_value_ = 0; + Value_default_oneof_instance_.number_value_ = 0; + Value_default_oneof_instance_.string_value_.UnsafeSetDefault( + &::google::protobuf::internal::GetEmptyStringAlreadyInited()); + Value_default_oneof_instance_.bool_value_ = false; + Value_default_oneof_instance_.struct_value_ = const_cast< ::google::protobuf::Struct*>( + ::google::protobuf::Struct::internal_default_instance()); + Value_default_oneof_instance_.list_value_ = const_cast< ::google::protobuf::ListValue*>( + ::google::protobuf::ListValue::internal_default_instance()); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + static const char descriptor[] = { + "\n\034google/protobuf/struct.proto\022\017google.p" + "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" + "gle.protobuf.Struct.FieldsEntry\032E\n\013Field" + "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo" + "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull" + "_value\030\001 \001(\0162\032.google.protobuf.NullValue" + "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val" + "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru" + "ct_value\030\005 \001(\0132\027.google.protobuf.StructH" + "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf." + "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu" + "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull" + "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro" + "tobufB\013StructProtoP\001Z1github.com/golang/" + "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB" + "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" + "3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\034google/protobuf/struct.proto\022\017google.p" - "rotobuf\"\204\001\n\006Struct\0223\n\006fields\030\001 \003(\0132#.goo" - "gle.protobuf.Struct.FieldsEntry\032E\n\013Field" - "sEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026.goo" - "gle.protobuf.Value:\0028\001\"\352\001\n\005Value\0220\n\nnull" - "_value\030\001 \001(\0162\032.google.protobuf.NullValue" - "H\000\022\026\n\014number_value\030\002 \001(\001H\000\022\026\n\014string_val" - "ue\030\003 \001(\tH\000\022\024\n\nbool_value\030\004 \001(\010H\000\022/\n\014stru" - "ct_value\030\005 \001(\0132\027.google.protobuf.StructH" - "\000\0220\n\nlist_value\030\006 \001(\0132\032.google.protobuf." - "ListValueH\000B\006\n\004kind\"3\n\tListValue\022&\n\006valu" - "es\030\001 \003(\0132\026.google.protobuf.Value*\033\n\tNull" - "Value\022\016\n\nNULL_VALUE\020\000B\201\001\n\023com.google.pro" - "tobufB\013StructProtoP\001Z1github.com/golang/" - "protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB" - "\252\002\036Google.Protobuf.WellKnownTypesb\006proto" - "3", 641); + descriptor, 641); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/struct.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto); @@ -205,7 +187,7 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto { } static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_; const ::google::protobuf::EnumDescriptor* NullValue_descriptor() { protobuf_AssignDescriptorsOnce(); - return NullValue_descriptor_; + return file_level_enum_descriptors[0]; } bool NullValue_IsValid(int value) { switch (value) { @@ -217,15 +199,10 @@ bool NullValue_IsValid(int value) { } -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace +// =================================================================== +#if PROTOBUF_INLINE_NOT_IN_HEADERS +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -235,7 +212,9 @@ const int Struct::kFieldsFieldNumber; Struct::Struct() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Struct) } @@ -250,23 +229,26 @@ Struct::Struct(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Struct) } - -void Struct::InitAsDefaultInstance() { -} - Struct::Struct(const Struct& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; + fields_.SetAssignDescriptorCallback( + protobuf_AssignDescriptorsOnce); + fields_.SetEntryDescriptor( + &Struct_FieldsEntry_descriptor); + fields_.MergeFrom(from.fields_); // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct) } void Struct::SharedCtor() { + const ::google::protobuf::Descriptor*& Struct_FieldsEntry_descriptor = file_level_metadata[0].descriptor; fields_.SetAssignDescriptorCallback( protobuf_AssignDescriptorsOnce); fields_.SetEntryDescriptor( - &::google::protobuf::Struct_FieldsEntry_descriptor_); + &Struct_FieldsEntry_descriptor); _cached_size_ = 0; } @@ -296,7 +278,7 @@ void Struct::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Struct::descriptor() { protobuf_AssignDescriptorsOnce(); - return Struct_descriptor_; + return file_level_metadata[1].descriptor; } const Struct& Struct::default_instance() { @@ -304,8 +286,6 @@ const Struct& Struct::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_; - Struct* Struct::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Struct>(arena); } @@ -321,15 +301,14 @@ bool Struct::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Struct) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // map<string, .google.protobuf.Value> fields = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_fields: Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField< ::std::string, ::google::protobuf::Value, ::google::protobuf::internal::WireFormatLite::TYPE_STRING, @@ -345,9 +324,7 @@ bool Struct::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_fields; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -390,7 +367,7 @@ void Struct::SerializeWithCachedSizes( } }; - if (output->IsSerializationDeterminstic() && + if (output->IsSerializationDeterministic() && this->fields().size() > 1) { ::google::protobuf::scoped_array<SortItem> items( new SortItem[this->fields().size()]); @@ -533,7 +510,7 @@ size_t Struct::ByteSizeLong() const { void Struct::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Struct* source = ::google::protobuf::internal::DynamicCastToGenerated<const Struct>( &from); @@ -542,21 +519,14 @@ void Struct::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Struct) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Struct::MergeFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Struct::UnsafeMergeFrom(const Struct& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); fields_.MergeFrom(from.fields_); } @@ -571,11 +541,10 @@ void Struct::CopyFrom(const Struct& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Struct::IsInitialized() const { - return true; } @@ -584,10 +553,13 @@ void Struct::Swap(Struct* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Struct temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Struct* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Struct::UnsafeArenaSwap(Struct* other) { @@ -597,16 +569,12 @@ void Struct::UnsafeArenaSwap(Struct* other) { } void Struct::InternalSwap(Struct* other) { fields_.Swap(&other->fields_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Struct::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Struct_descriptor_; - metadata.reflection = Struct_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -630,9 +598,6 @@ Struct::mutable_fields() { return fields_.MutableMap(); } -inline const Struct* Struct::internal_default_instance() { - return &Struct_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -648,7 +613,9 @@ const int Value::kListValueFieldNumber; Value::Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Value) } @@ -662,23 +629,41 @@ Value::Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Value) } - -void Value::InitAsDefaultInstance() { - Value_default_oneof_instance_->null_value_ = 0; - Value_default_oneof_instance_->number_value_ = 0; - Value_default_oneof_instance_->string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - Value_default_oneof_instance_->bool_value_ = false; - Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>( - ::google::protobuf::Struct::internal_default_instance()); - Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>( - ::google::protobuf::ListValue::internal_default_instance()); -} - Value::Value(const Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + clear_has_kind(); + switch (from.kind_case()) { + case kNullValue: { + set_null_value(from.null_value()); + break; + } + case kNumberValue: { + set_number_value(from.number_value()); + break; + } + case kStringValue: { + set_string_value(from.string_value()); + break; + } + case kBoolValue: { + set_bool_value(from.bool_value()); + break; + } + case kStructValue: { + mutable_struct_value()->::google::protobuf::Struct::MergeFrom(from.struct_value()); + break; + } + case kListValue: { + mutable_list_value()->::google::protobuf::ListValue::MergeFrom(from.list_value()); + break; + } + case KIND_NOT_SET: { + break; + } + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Value) } @@ -716,7 +701,7 @@ void Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Value_descriptor_; + return file_level_metadata[2].descriptor; } const Value& Value::default_instance() { @@ -724,8 +709,6 @@ const Value& Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_; - Value* Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Value>(arena); } @@ -781,13 +764,13 @@ bool Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -796,13 +779,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional double number_value = 2; + // double number_value = 2; case 2: { - if (tag == 17) { + if (tag == 17u) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -811,13 +793,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional string string_value = 3; + // string string_value = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_string_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -827,13 +808,12 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional bool bool_value = 4; + // bool bool_value = 4; case 4: { - if (tag == 32) { + if (tag == 32u) { clear_kind(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -842,33 +822,28 @@ bool Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - goto after_list_value; break; } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; case 5: { - if (tag == 42) { + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_struct_value())); } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_list_value; break; } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; case 6: { - if (tag == 50) { - parse_list_value: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_list_value())); } else { goto handle_unusual; } - after_list_value: - if (input->ExpectAtEnd()) goto success; break; } @@ -896,18 +871,18 @@ failure: void Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Value) - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; if (has_null_value()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->null_value(), output); } - // optional double number_value = 2; + // double number_value = 2; if (has_number_value()) { ::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->number_value(), output); } - // optional string string_value = 3; + // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->string_value().data(), this->string_value().length(), @@ -917,18 +892,18 @@ void Value::SerializeWithCachedSizes( 3, this->string_value(), output); } - // optional bool bool_value = 4; + // bool bool_value = 4; if (has_bool_value()) { ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->bool_value(), output); } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *kind_.struct_value_, output); } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 6, *kind_.list_value_, output); @@ -941,18 +916,18 @@ void Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value) - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; if (has_null_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->null_value(), target); } - // optional double number_value = 2; + // double number_value = 2; if (has_number_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->number_value(), target); } - // optional string string_value = 3; + // string string_value = 3; if (has_string_value()) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->string_value().data(), this->string_value().length(), @@ -963,19 +938,19 @@ void Value::SerializeWithCachedSizes( 3, this->string_value(), target); } - // optional bool bool_value = 4; + // bool bool_value = 4; if (has_bool_value()) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->bool_value(), target); } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; if (has_struct_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 5, *kind_.struct_value_, false, target); } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; if (has_list_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -991,37 +966,37 @@ size_t Value::ByteSizeLong() const { size_t total_size = 0; switch (kind_case()) { - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; case kNullValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->null_value()); break; } - // optional double number_value = 2; + // double number_value = 2; case kNumberValue: { total_size += 1 + 8; break; } - // optional string string_value = 3; + // string string_value = 3; case kStringValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->string_value()); break; } - // optional bool bool_value = 4; + // bool bool_value = 4; case kBoolValue: { total_size += 1 + 1; break; } - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; case kStructValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( *kind_.struct_value_); break; } - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; case kListValue: { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( @@ -1041,7 +1016,7 @@ size_t Value::ByteSizeLong() const { void Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Value>( &from); @@ -1050,21 +1025,14 @@ void Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Value) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Value::MergeFrom(const Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Value::UnsafeMergeFrom(const Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); switch (from.kind_case()) { case kNullValue: { set_null_value(from.null_value()); @@ -1107,11 +1075,10 @@ void Value::CopyFrom(const Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Value::IsInitialized() const { - return true; } @@ -1120,10 +1087,13 @@ void Value::Swap(Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Value::UnsafeArenaSwap(Value* other) { @@ -1134,22 +1104,18 @@ void Value::UnsafeArenaSwap(Value* other) { void Value::InternalSwap(Value* other) { std::swap(kind_, other->kind_); std::swap(_oneof_case_[0], other->_oneof_case_[0]); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Value_descriptor_; - metadata.reflection = Value_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Value -// optional .google.protobuf.NullValue null_value = 1; +// .google.protobuf.NullValue null_value = 1; bool Value::has_null_value() const { return kind_case() == kNullValue; } @@ -1178,7 +1144,7 @@ void Value::set_null_value(::google::protobuf::NullValue value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value) } -// optional double number_value = 2; +// double number_value = 2; bool Value::has_number_value() const { return kind_case() == kNumberValue; } @@ -1207,7 +1173,7 @@ void Value::set_number_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value) } -// optional string string_value = 3; +// string string_value = 3; bool Value::has_string_value() const { return kind_case() == kStringValue; } @@ -1224,7 +1190,7 @@ void Value::clear_string_value() { const ::std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) if (has_string_value()) { - return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } @@ -1316,7 +1282,7 @@ void Value::unsafe_arena_set_allocated_string_value(::std::string* string_value) // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) } -// optional bool bool_value = 4; +// bool bool_value = 4; bool Value::has_bool_value() const { return kind_case() == kBoolValue; } @@ -1345,7 +1311,7 @@ void Value::set_bool_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value) } -// optional .google.protobuf.Struct struct_value = 5; +// .google.protobuf.Struct struct_value = 5; bool Value::has_struct_value() const { return kind_case() == kStructValue; } @@ -1433,7 +1399,7 @@ void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } -// optional .google.protobuf.ListValue list_value = 6; +// .google.protobuf.ListValue list_value = 6; bool Value::has_list_value() const { return kind_case() == kListValue; } @@ -1530,9 +1496,6 @@ void Value::clear_has_kind() { Value::KindCase Value::kind_case() const { return Value::KindCase(_oneof_case_[0]); } -inline const Value* Value::internal_default_instance() { - return &Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1543,7 +1506,9 @@ const int ListValue::kValuesFieldNumber; ListValue::ListValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.ListValue) } @@ -1558,15 +1523,12 @@ ListValue::ListValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.ListValue) } - -void ListValue::InitAsDefaultInstance() { -} - ListValue::ListValue(const ListValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + values_(from.values_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue) } @@ -1600,7 +1562,7 @@ void ListValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* ListValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return ListValue_descriptor_; + return file_level_metadata[3].descriptor; } const ListValue& ListValue::default_instance() { @@ -1608,8 +1570,6 @@ const ListValue& ListValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_; - ListValue* ListValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<ListValue>(arena); } @@ -1625,23 +1585,20 @@ bool ListValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.ListValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // repeated .google.protobuf.Value values = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(input->IncrementRecursionDepth()); - parse_loop_values: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_values())); } else { goto handle_unusual; } - if (input->ExpectTag(10)) goto parse_loop_values; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -1717,7 +1674,7 @@ size_t ListValue::ByteSizeLong() const { void ListValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const ListValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const ListValue>( &from); @@ -1726,21 +1683,14 @@ void ListValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ListValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void ListValue::MergeFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void ListValue::UnsafeMergeFrom(const ListValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); values_.MergeFrom(from.values_); } @@ -1755,11 +1705,10 @@ void ListValue::CopyFrom(const ListValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool ListValue::IsInitialized() const { - return true; } @@ -1768,10 +1717,13 @@ void ListValue::Swap(ListValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - ListValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + ListValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void ListValue::UnsafeArenaSwap(ListValue* other) { @@ -1781,16 +1733,12 @@ void ListValue::UnsafeArenaSwap(ListValue* other) { } void ListValue::InternalSwap(ListValue* other) { values_.UnsafeArenaSwap(&other->values_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata ListValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = ListValue_descriptor_; - metadata.reflection = ListValue_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1826,9 +1774,6 @@ ListValue::values() const { return values_; } -inline const ListValue* ListValue::internal_default_instance() { - return &ListValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index ff77bb45..4d89c11c 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -24,13 +24,26 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/map.h> #include <google/protobuf/map_field_inl.h> #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class ListValue; +class ListValueDefaultTypeInternal; +extern ListValueDefaultTypeInternal _ListValue_default_instance_; +class Struct; +class StructDefaultTypeInternal; +extern StructDefaultTypeInternal _Struct_default_instance_; +class Value; +class ValueDefaultTypeInternal; +extern ValueDefaultTypeInternal _Value_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -38,12 +51,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - -class ListValue; -class Struct; -class Value; enum NullValue { NULL_VALUE = 0, @@ -67,6 +74,9 @@ inline bool NullValue_Parse( } // =================================================================== + +// ------------------------------------------------------------------- + class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ { public: Struct(); @@ -79,47 +89,52 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Struct& default_instance(); - static const Struct* internal_default_instance(); + static inline const Struct* internal_default_instance() { + return reinterpret_cast<const Struct*>( + &_Struct_default_instance_); + } void UnsafeArenaSwap(Struct* other); void Swap(Struct* other); // implements Message ---------------------------------------------- - inline Struct* New() const { return New(NULL); } + inline Struct* New() const PROTOBUF_FINAL { return New(NULL); } - Struct* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Struct* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Struct& from); void MergeFrom(const Struct& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Struct* other); - void UnsafeMergeFrom(const Struct& from); protected: explicit Struct(::google::protobuf::Arena* arena); private: @@ -134,7 +149,7 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -171,13 +186,10 @@ class LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Struct> Struct_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ { @@ -192,8 +204,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); @@ -209,40 +223,43 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KIND_NOT_SET = 0, }; - static const Value* internal_default_instance(); + static inline const Value* internal_default_instance() { + return reinterpret_cast<const Value*>( + &_Value_default_instance_); + } void UnsafeArenaSwap(Value* other); void Swap(Value* other); // implements Message ---------------------------------------------- - inline Value* New() const { return New(NULL); } + inline Value* New() const PROTOBUF_FINAL { return New(NULL); } - Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Value& from); void MergeFrom(const Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Value* other); - void UnsafeMergeFrom(const Value& from); protected: explicit Value(::google::protobuf::Arena* arena); private: @@ -257,13 +274,13 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional .google.protobuf.NullValue null_value = 1; + // .google.protobuf.NullValue null_value = 1; private: bool has_null_value() const; public: @@ -272,7 +289,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::NullValue null_value() const; void set_null_value(::google::protobuf::NullValue value); - // optional double number_value = 2; + // double number_value = 2; private: bool has_number_value() const; public: @@ -281,7 +298,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ double number_value() const; void set_number_value(double value); - // optional string string_value = 3; + // string string_value = 3; private: bool has_string_value() const; public: @@ -298,7 +315,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_string_value( ::std::string* string_value); - // optional bool bool_value = 4; + // bool bool_value = 4; private: bool has_bool_value() const; public: @@ -307,7 +324,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ bool bool_value() const; void set_bool_value(bool value); - // optional .google.protobuf.Struct struct_value = 5; + // .google.protobuf.Struct struct_value = 5; bool has_struct_value() const; void clear_struct_value(); static const int kStructValueFieldNumber = 5; @@ -325,7 +342,7 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_struct_value( ::google::protobuf::Struct* struct_value); - // optional .google.protobuf.ListValue list_value = 6; + // .google.protobuf.ListValue list_value = 6; bool has_list_value() const; void clear_list_value(); static const int kListValueFieldNumber = 6; @@ -346,12 +363,12 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ KindCase kind_case() const; // @@protoc_insertion_point(class_scope:google.protobuf.Value) private: - inline void set_has_null_value(); - inline void set_has_number_value(); - inline void set_has_string_value(); - inline void set_has_bool_value(); - inline void set_has_struct_value(); - inline void set_has_list_value(); + void set_has_null_value(); + void set_has_number_value(); + void set_has_string_value(); + void set_has_bool_value(); + void set_has_struct_value(); + void set_has_list_value(); inline bool has_kind() const; void clear_kind(); @@ -375,13 +392,10 @@ class LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_ friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Value> Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ { @@ -396,47 +410,52 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const ListValue& default_instance(); - static const ListValue* internal_default_instance(); + static inline const ListValue* internal_default_instance() { + return reinterpret_cast<const ListValue*>( + &_ListValue_default_instance_); + } void UnsafeArenaSwap(ListValue* other); void Swap(ListValue* other); // implements Message ---------------------------------------------- - inline ListValue* New() const { return New(NULL); } + inline ListValue* New() const PROTOBUF_FINAL { return New(NULL); } - ListValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + ListValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const ListValue& from); void MergeFrom(const ListValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(ListValue* other); - void UnsafeMergeFrom(const ListValue& from); protected: explicit ListValue(::google::protobuf::Arena* arena); private: @@ -451,7 +470,7 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -480,19 +499,18 @@ class LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fstruct_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fstruct_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<ListValue> ListValue_default_instance_; - // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + // Struct // map<string, .google.protobuf.Value> fields = 1; @@ -513,14 +531,11 @@ Struct::mutable_fields() { return fields_.MutableMap(); } -inline const Struct* Struct::internal_default_instance() { - return &Struct_default_instance_.get(); -} // ------------------------------------------------------------------- // Value -// optional .google.protobuf.NullValue null_value = 1; +// .google.protobuf.NullValue null_value = 1; inline bool Value::has_null_value() const { return kind_case() == kNullValue; } @@ -549,7 +564,7 @@ inline void Value::set_null_value(::google::protobuf::NullValue value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value) } -// optional double number_value = 2; +// double number_value = 2; inline bool Value::has_number_value() const { return kind_case() == kNumberValue; } @@ -578,7 +593,7 @@ inline void Value::set_number_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value) } -// optional string string_value = 3; +// string string_value = 3; inline bool Value::has_string_value() const { return kind_case() == kStringValue; } @@ -595,7 +610,7 @@ inline void Value::clear_string_value() { inline const ::std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) if (has_string_value()) { - return kind_.string_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return kind_.string_value_.Get(); } return *&::google::protobuf::internal::GetEmptyStringAlreadyInited(); } @@ -687,7 +702,7 @@ inline void Value::unsafe_arena_set_allocated_string_value(::std::string* string // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.string_value) } -// optional bool bool_value = 4; +// bool bool_value = 4; inline bool Value::has_bool_value() const { return kind_case() == kBoolValue; } @@ -716,7 +731,7 @@ inline void Value::set_bool_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value) } -// optional .google.protobuf.Struct struct_value = 5; +// .google.protobuf.Struct struct_value = 5; inline bool Value::has_struct_value() const { return kind_case() == kStructValue; } @@ -804,7 +819,7 @@ inline void Value::unsafe_arena_set_allocated_struct_value(::google::protobuf:: // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Value.struct_value) } -// optional .google.protobuf.ListValue list_value = 6; +// .google.protobuf.ListValue list_value = 6; inline bool Value::has_list_value() const { return kind_case() == kListValue; } @@ -901,9 +916,6 @@ inline void Value::clear_has_kind() { inline Value::KindCase Value::kind_case() const { return Value::KindCase(_oneof_case_[0]); } -inline const Value* Value::internal_default_instance() { - return &Value_default_instance_.get(); -} // ------------------------------------------------------------------- // ListValue @@ -938,17 +950,17 @@ ListValue::values() const { return values_; } -inline const ListValue* ListValue::internal_default_instance() { - return &ListValue_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 54dbafab..14655916 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc @@ -108,11 +108,17 @@ string VersionString(int version) { // =================================================================== // emulates google3/base/logging.cc +// If the minimum logging level is not set, we default to logging messages for +// all levels. +#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL +#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO +#endif + namespace internal { + #if defined(__ANDROID__) inline void DefaultLogHandler(LogLevel level, const char* filename, int line, const string& message) { -#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { return; } @@ -143,11 +149,14 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line, __android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native", "terminating.\n"); } -#endif } + #else void DefaultLogHandler(LogLevel level, const char* filename, int line, const string& message) { + if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { + return; + } static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" }; // We use fprintf() instead of cerr because we want this to work at static diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 43e88ff2..c595e205 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -98,6 +98,9 @@ namespace internal { // easier: major * 10^6 + minor * 10^3 + micro #define GOOGLE_PROTOBUF_VERSION 3001000 +// A suffix string for alpha, beta or rc releases. Empty for stable releases. +#define GOOGLE_PROTOBUF_VERSION_SUFFIX "" + // The minimum library version which works with the current version of the // headers. #define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3001000 diff --git a/src/google/protobuf/stubs/mathlimits.h b/src/google/protobuf/stubs/mathlimits.h index 70e47bff..275d9539 100644 --- a/src/google/protobuf/stubs/mathlimits.h +++ b/src/google/protobuf/stubs/mathlimits.h @@ -43,12 +43,18 @@ #ifndef UTIL_MATH_MATHLIMITS_H__ #define UTIL_MATH_MATHLIMITS_H__ -// <math.h> lacks a lot of prototypes. However, this file needs <math.h> to -// access old-fashioned isinf et al. Even worse more: this file must not -// include <cmath> because that breaks the definition of isinf with gcc 4.9. -// -// TODO(mec): after C++11 everywhere, use <cmath> and std::isinf in this file. +// GCC 4.9 has a bug that makes it impossible to use isinf and isnan when both +// <math.h> and <cmath> get pulled into the same translation unit. +// Unfortunately it is difficult to prevent this from happening, so to work +// around the problem we use std::isinf and std::isnan from <cmath> for C++11 +// builds and otherwise use the plain isinf and isnan functions from <math.h>. +// Note that for Windows we do something different because it does not support +// the plain isinf and isnan. +#if __cplusplus >= 201103L +#include <cmath> +#else #include <math.h> +#endif #include <string.h> #include <cfloat> @@ -220,6 +226,17 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int) #undef UNSIGNED_MAX_10_EXP #undef DECL_INT_LIMIT_FUNCS +// For non-Windows builds we use the std:: versions of isinf and isnan if they +// are available; see the comment about <cmath> at the top of this file for the +// details on why we need to do this. +#if __cplusplus >= 201103L +#define ISINF std::isinf +#define ISNAN std::isnan +#else +#define ISINF isinf +#define ISNAN isnan +#endif + // ========================================================================= // #ifdef WIN32 // Lacks built-in isnan() and isinf() #define DECL_FP_LIMIT_FUNCS \ @@ -230,11 +247,11 @@ DECL_UNSIGNED_INT_LIMITS(unsigned long long int) static bool IsNegInf(const Type x) { return _fpclass(x) == _FPCLASS_NINF; } #else #define DECL_FP_LIMIT_FUNCS \ - static bool IsFinite(const Type x) { return !isinf(x) && !isnan(x); } \ - static bool IsNaN(const Type x) { return isnan(x); } \ - static bool IsInf(const Type x) { return isinf(x); } \ - static bool IsPosInf(const Type x) { return isinf(x) && x > 0; } \ - static bool IsNegInf(const Type x) { return isinf(x) && x < 0; } + static bool IsFinite(const Type x) { return !ISINF(x) && !ISNAN(x); } \ + static bool IsNaN(const Type x) { return ISNAN(x); } \ + static bool IsInf(const Type x) { return ISINF(x); } \ + static bool IsPosInf(const Type x) { return ISINF(x) && x > 0; } \ + static bool IsNegInf(const Type x) { return ISINF(x) && x < 0; } #endif // We can't put floating-point constant values in the header here because @@ -269,6 +286,8 @@ DECL_FP_LIMITS(float, FLT) DECL_FP_LIMITS(double, DBL) DECL_FP_LIMITS(long double, LDBL) +#undef ISINF +#undef ISNAN #undef DECL_FP_LIMITS #undef DECL_FP_LIMIT_FUNCS diff --git a/src/google/protobuf/stubs/mathutil.h b/src/google/protobuf/stubs/mathutil.h index 27956a8e..8a9f69a0 100644 --- a/src/google/protobuf/stubs/mathutil.h +++ b/src/google/protobuf/stubs/mathutil.h @@ -41,27 +41,6 @@ namespace google { namespace protobuf { namespace internal { template<typename T> -bool IsNan(T value) { - return false; -} -template<> -inline bool IsNan(float value) { -#ifdef _MSC_VER - return _isnan(value); -#else - return isnan(value); -#endif -} -template<> -inline bool IsNan(double value) { -#ifdef _MSC_VER - return _isnan(value); -#else - return isnan(value); -#endif -} - -template<typename T> bool AlmostEquals(T a, T b) { return a == b; } @@ -80,7 +59,7 @@ class MathUtil { public: template<typename T> static T Sign(T value) { - if (value == T(0) || ::google::protobuf::internal::IsNan<T>(value)) { + if (value == T(0) || MathLimits<T>::IsNaN(value)) { return value; } return value > T(0) ? 1 : -1; diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index 376be5f7..d5ef166e 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -60,8 +60,12 @@ #endif #else #include <sys/param.h> // __BYTE_ORDER + #if defined(__OpenBSD__) + #include <endian.h> + #endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \ + (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \ + (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \ !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) #define PROTOBUF_LITTLE_ENDIAN 1 #endif diff --git a/src/google/protobuf/test_messages_proto3.proto b/src/google/protobuf/test_messages_proto3.proto new file mode 100644 index 00000000..79230334 --- /dev/null +++ b/src/google/protobuf/test_messages_proto3.proto @@ -0,0 +1,227 @@ +// 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. +// +// Test schema for proto3 messages. This test schema is used by: +// +// - benchmarks +// - fuzz tests +// - conformance tests +// + +syntax = "proto3"; + +package protobuf_test_messages.proto3; +option java_package = "com.google.protobuf_test_messages.proto3"; + +// This is the default, but we specify it here explicitly. +option optimize_for = SPEED; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option cc_enable_arenas = true; + +// This proto includes every type of field in both singular and repeated +// forms. +// +// Also, crucially, all messages and enums in this file are eventually +// submessages of this message. So for example, a fuzz test of TestAllTypes +// could trigger bugs that occur in any message type in this file. We verify +// this stays true in a unit test. +message TestAllTypes { + message NestedMessage { + int32 a = 1; + TestAllTypes corecursive = 2; + } + + enum NestedEnum { + FOO = 0; + BAR = 1; + BAZ = 2; + NEG = -1; // Intentionally negative. + } + + // Singular + int32 optional_int32 = 1; + int64 optional_int64 = 2; + uint32 optional_uint32 = 3; + uint64 optional_uint64 = 4; + sint32 optional_sint32 = 5; + sint64 optional_sint64 = 6; + fixed32 optional_fixed32 = 7; + fixed64 optional_fixed64 = 8; + sfixed32 optional_sfixed32 = 9; + sfixed64 optional_sfixed64 = 10; + float optional_float = 11; + double optional_double = 12; + bool optional_bool = 13; + string optional_string = 14; + bytes optional_bytes = 15; + + NestedMessage optional_nested_message = 18; + ForeignMessage optional_foreign_message = 19; + + NestedEnum optional_nested_enum = 21; + ForeignEnum optional_foreign_enum = 22; + + string optional_string_piece = 24 [ctype=STRING_PIECE]; + string optional_cord = 25 [ctype=CORD]; + + TestAllTypes recursive_message = 27; + + // Repeated + repeated int32 repeated_int32 = 31; + repeated int64 repeated_int64 = 32; + repeated uint32 repeated_uint32 = 33; + repeated uint64 repeated_uint64 = 34; + repeated sint32 repeated_sint32 = 35; + repeated sint64 repeated_sint64 = 36; + repeated fixed32 repeated_fixed32 = 37; + repeated fixed64 repeated_fixed64 = 38; + repeated sfixed32 repeated_sfixed32 = 39; + repeated sfixed64 repeated_sfixed64 = 40; + repeated float repeated_float = 41; + repeated double repeated_double = 42; + repeated bool repeated_bool = 43; + repeated string repeated_string = 44; + repeated bytes repeated_bytes = 45; + + repeated NestedMessage repeated_nested_message = 48; + repeated ForeignMessage repeated_foreign_message = 49; + + repeated NestedEnum repeated_nested_enum = 51; + repeated ForeignEnum repeated_foreign_enum = 52; + + repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; + repeated string repeated_cord = 55 [ctype=CORD]; + + // Map + map < int32, int32> map_int32_int32 = 56; + map < int64, int64> map_int64_int64 = 57; + map < uint32, uint32> map_uint32_uint32 = 58; + map < uint64, uint64> map_uint64_uint64 = 59; + map < sint32, sint32> map_sint32_sint32 = 60; + map < sint64, sint64> map_sint64_sint64 = 61; + map < fixed32, fixed32> map_fixed32_fixed32 = 62; + map < fixed64, fixed64> map_fixed64_fixed64 = 63; + map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; + map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; + map < int32, float> map_int32_float = 66; + map < int32, double> map_int32_double = 67; + map < bool, bool> map_bool_bool = 68; + map < string, string> map_string_string = 69; + map < string, bytes> map_string_bytes = 70; + map < string, NestedMessage> map_string_nested_message = 71; + map < string, ForeignMessage> map_string_foreign_message = 72; + map < string, NestedEnum> map_string_nested_enum = 73; + map < string, ForeignEnum> map_string_foreign_enum = 74; + + oneof oneof_field { + uint32 oneof_uint32 = 111; + NestedMessage oneof_nested_message = 112; + string oneof_string = 113; + bytes oneof_bytes = 114; + bool oneof_bool = 115; + uint64 oneof_uint64 = 116; + float oneof_float = 117; + double oneof_double = 118; + NestedEnum oneof_enum = 119; + } + + // Well-known types + google.protobuf.BoolValue optional_bool_wrapper = 201; + google.protobuf.Int32Value optional_int32_wrapper = 202; + google.protobuf.Int64Value optional_int64_wrapper = 203; + google.protobuf.UInt32Value optional_uint32_wrapper = 204; + google.protobuf.UInt64Value optional_uint64_wrapper = 205; + google.protobuf.FloatValue optional_float_wrapper = 206; + google.protobuf.DoubleValue optional_double_wrapper = 207; + google.protobuf.StringValue optional_string_wrapper = 208; + google.protobuf.BytesValue optional_bytes_wrapper = 209; + + repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; + repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; + repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; + repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; + repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; + repeated google.protobuf.FloatValue repeated_float_wrapper = 216; + repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; + repeated google.protobuf.StringValue repeated_string_wrapper = 218; + repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; + + google.protobuf.Duration optional_duration = 301; + google.protobuf.Timestamp optional_timestamp = 302; + google.protobuf.FieldMask optional_field_mask = 303; + google.protobuf.Struct optional_struct = 304; + google.protobuf.Any optional_any = 305; + google.protobuf.Value optional_value = 306; + + repeated google.protobuf.Duration repeated_duration = 311; + repeated google.protobuf.Timestamp repeated_timestamp = 312; + repeated google.protobuf.FieldMask repeated_fieldmask = 313; + repeated google.protobuf.Struct repeated_struct = 324; + repeated google.protobuf.Any repeated_any = 315; + repeated google.protobuf.Value repeated_value = 316; + + // Test field-name-to-JSON-name convention. + // (protobuf says names can be any valid C/C++ identifier.) + int32 fieldname1 = 401; + int32 field_name2 = 402; + int32 _field_name3 = 403; + int32 field__name4_ = 404; + int32 field0name5 = 405; + int32 field_0_name6 = 406; + int32 fieldName7 = 407; + int32 FieldName8 = 408; + int32 field_Name9 = 409; + int32 Field_Name10 = 410; + int32 FIELD_NAME11 = 411; + int32 FIELD_name12 = 412; + int32 __field_name13 = 413; + int32 __Field_name14 = 414; + int32 field__name15 = 415; + int32 field__Name16 = 416; + int32 field_name17__ = 417; + int32 Field_name18__ = 418; +} + +message ForeignMessage { + int32 c = 1; +} + +enum ForeignEnum { + FOREIGN_FOO = 0; + FOREIGN_BAR = 1; + FOREIGN_BAZ = 2; +} diff --git a/src/google/protobuf/test_util.cc b/src/google/protobuf/test_util.cc index 658c8ee2..4e02a85d 100644 --- a/src/google/protobuf/test_util.cc +++ b/src/google/protobuf/test_util.cc @@ -3230,7 +3230,7 @@ void TestUtil::ReflectionTester::RemoveLastRepeatedsViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3244,7 +3244,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection( Message* message, bool expect_extensions_notnull) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3263,7 +3263,7 @@ void TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection( void TestUtil::ReflectionTester::SwapRepeatedsViaReflection(Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> output; + std::vector<const FieldDescriptor*> output; reflection->ListFields(*message, &output); for (int i=0; i<output.size(); ++i) { const FieldDescriptor* field = output[i]; @@ -3278,7 +3278,7 @@ SetAllocatedOptionalMessageFieldsToNullViaReflection( Message* message) { const Reflection* reflection = message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(*message, &fields); for (int i = 0; i < fields.size(); ++i) { @@ -3298,7 +3298,7 @@ SetAllocatedOptionalMessageFieldsToMessageViaReflection( const Reflection* from_reflection = from_message->GetReflection(); const Reflection* to_reflection = to_message->GetReflection(); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; from_reflection->ListFields(*from_message, &fields); for (int i = 0; i < fields.size(); ++i) { diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 5192eca9..e3d908ec 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -154,7 +154,7 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested( const FieldDescriptor* field) { // Owned by us in the map. TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree(); - vector<TextFormat::ParseInfoTree*>* trees = &nested_[field]; + std::vector<TextFormat::ParseInfoTree*>* trees = &nested_[field]; GOOGLE_CHECK(trees); trees->push_back(instance); return instance; @@ -177,7 +177,7 @@ TextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation( CheckFieldIndex(field, index); if (index == -1) { index = 0; } - const vector<TextFormat::ParseLocation>* locations = + const std::vector<TextFormat::ParseLocation>* locations = FindOrNull(locations_, field); if (locations == NULL || index >= locations->size()) { return TextFormat::ParseLocation(); @@ -191,7 +191,8 @@ TextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested( CheckFieldIndex(field, index); if (index == -1) { index = 0; } - const vector<TextFormat::ParseInfoTree*>* trees = FindOrNull(nested_, field); + const std::vector<TextFormat::ParseInfoTree*>* trees = + FindOrNull(nested_, field); if (trees == NULL || index >= trees->size()) { return NULL; } @@ -518,7 +519,14 @@ class TextFormat::Parser::ParserImpl { // Perform special handling for embedded message types. if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { // ':' is optional here. - TryConsume(":"); + bool consumed_semicolon = TryConsume(":"); + if (consumed_semicolon && field->options().weak() && LookingAtType(io::Tokenizer::TYPE_STRING)) { + // we are getting a bytes string for a weak field. + string tmp; + DO(ConsumeString(&tmp)); + reflection->MutableMessage(message, field)->ParseFromString(tmp); + goto label_skip_parsing; + } } else { // ':' is required here. DO(Consume(":")); @@ -546,7 +554,7 @@ class TextFormat::Parser::ParserImpl { } else { DO(ConsumeFieldValue(message, reflection, field)); } - +label_skip_parsing: // For historical reasons, fields may optionally be separated by commas or // semicolons. TryConsume(";") || TryConsume(","); @@ -1336,7 +1344,7 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */, ParserImpl* parser_impl) { if (!parser_impl->Parse(output)) return false; if (!allow_partial_ && !output->IsInitialized()) { - vector<string> missing_fields; + std::vector<string> missing_fields; output->FindInitializationErrors(&missing_fields); parser_impl->ReportError(-1, 0, "Message missing required fields: " + Join(missing_fields, ", ")); @@ -1610,7 +1618,7 @@ void TextFormat::Printer::Print(const Message& message, PrintAny(message, generator)) { return; } - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; reflection->ListFields(message, &fields); if (print_message_fields_in_index_order_) { std::sort(fields.begin(), fields.end(), FieldIndexSorter()); diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 2f1bd455..e6441339 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -993,10 +993,14 @@ TEST_F(TextFormatTest, ParseExotic) { EXPECT_EQ(1.235E22 , message.repeated_double(4)); EXPECT_EQ(1.235E-18 , message.repeated_double(5)); EXPECT_EQ(123.456789, message.repeated_double(6)); - EXPECT_EQ(message.repeated_double(7), numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity()); - EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(7), + std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(8), + std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(9), + -std::numeric_limits<double>::infinity()); + EXPECT_EQ(message.repeated_double(10), + -std::numeric_limits<double>::infinity()); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11))); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12))); @@ -1500,7 +1504,7 @@ TEST_F(TextFormatParserTest, ExplicitDelimiters) { } TEST_F(TextFormatParserTest, PrintErrorsToStderr) { - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -1517,7 +1521,7 @@ TEST_F(TextFormatParserTest, PrintErrorsToStderr) { } TEST_F(TextFormatParserTest, FailsOnTokenizationError) { - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; @@ -1576,7 +1580,7 @@ TEST_F(TextFormatMessageSetTest, Deserialize) { protobuf_unittest::TestMessageSetExtension2::message_set_extension).str()); // Ensure that these are the only entries present. - vector<const FieldDescriptor*> descriptors; + std::vector<const FieldDescriptor*> descriptors; proto.message_set().GetReflection()->ListFields( proto.message_set(), &descriptors); EXPECT_EQ(2, descriptors.size()); diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index b4258ae4..482c0e39 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -19,85 +19,88 @@ namespace google { namespace protobuf { +class TimestampDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> {}; +TimestampDefaultTypeInternal _Timestamp_default_instance_; namespace { -const ::google::protobuf::Descriptor* Timestamp_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Timestamp_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[1]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/timestamp.proto"); - GOOGLE_CHECK(file != NULL); - Timestamp_descriptor_ = file->message_type(0); - static const int Timestamp_offsets_[2] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_), }; - Timestamp_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Timestamp_descriptor_, - Timestamp::internal_default_instance(), - Timestamp_offsets_, - -1, - -1, - -1, - sizeof(Timestamp), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_)); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Timestamp)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Timestamp_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/timestamp.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Timestamp_descriptor_, Timestamp::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() { - Timestamp_default_instance_.Shutdown(); - delete Timestamp_reflection_; + _Timestamp_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - Timestamp_default_instance_.DefaultConstruct(); - Timestamp_default_instance_.get_mutable()->InitAsDefaultInstance(); + ::google::protobuf::internal::InitProtobufDefaults(); + _Timestamp_default_instance_.DefaultConstruct(); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_); void protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + static const char descriptor[] = { + "\n\037google/protobuf/timestamp.proto\022\017googl" + "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" + "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" + "TimestampProtoP\001Z+github.com/golang/prot" + "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google." + "Protobuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\037google/protobuf/timestamp.proto\022\017googl" - "e.protobuf\"+\n\tTimestamp\022\017\n\007seconds\030\001 \001(\003" - "\022\r\n\005nanos\030\002 \001(\005B~\n\023com.google.protobufB\016" - "TimestampProtoP\001Z+github.com/golang/prot" - "obuf/ptypes/timestamp\370\001\001\242\002\003GPB\252\002\036Google." - "Protobuf.WellKnownTypesb\006proto3", 231); + descriptor, 231); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/timestamp.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto); @@ -115,16 +118,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -134,7 +127,9 @@ const int Timestamp::kNanosFieldNumber; Timestamp::Timestamp() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Timestamp) } @@ -148,15 +143,14 @@ Timestamp::Timestamp(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp) } - -void Timestamp::InitAsDefaultInstance() { -} - Timestamp::Timestamp(const Timestamp& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&seconds_, &from.seconds_, + reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp) } @@ -192,7 +186,7 @@ void Timestamp::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Timestamp::descriptor() { protobuf_AssignDescriptorsOnce(); - return Timestamp_descriptor_; + return file_level_metadata[0].descriptor; } const Timestamp& Timestamp::default_instance() { @@ -200,35 +194,14 @@ const Timestamp& Timestamp::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_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) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Timestamp, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Timestamp*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(seconds_, nanos_); - -#undef ZR_HELPER_ -#undef ZR_ - + ::memset(&seconds_, 0, reinterpret_cast<char*>(&nanos_) - + reinterpret_cast<char*>(&seconds_) + sizeof(nanos_)); } bool Timestamp::MergePartialFromCodedStream( @@ -237,13 +210,13 @@ bool Timestamp::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Timestamp) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 seconds = 1; + // int64 seconds = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -251,14 +224,12 @@ bool Timestamp::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_nanos; break; } - // optional int32 nanos = 2; + // int32 nanos = 2; case 2: { - if (tag == 16) { - parse_nanos: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -266,7 +237,6 @@ bool Timestamp::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -294,12 +264,12 @@ failure: void Timestamp::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Timestamp) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output); } @@ -311,12 +281,12 @@ void Timestamp::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp) - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target); } @@ -329,14 +299,14 @@ size_t Timestamp::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp) size_t total_size = 0; - // optional int64 seconds = 1; + // int64 seconds = 1; if (this->seconds() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( this->seconds()); } - // optional int32 nanos = 2; + // int32 nanos = 2; if (this->nanos() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -352,7 +322,7 @@ size_t Timestamp::ByteSizeLong() const { void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Timestamp* source = ::google::protobuf::internal::DynamicCastToGenerated<const Timestamp>( &from); @@ -361,21 +331,14 @@ void Timestamp::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Timestamp) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Timestamp::MergeFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Timestamp::UnsafeMergeFrom(const Timestamp& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.seconds() != 0) { set_seconds(from.seconds()); } @@ -395,11 +358,10 @@ void Timestamp::CopyFrom(const Timestamp& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Timestamp::IsInitialized() const { - return true; } @@ -408,10 +370,13 @@ void Timestamp::Swap(Timestamp* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Timestamp temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Timestamp* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Timestamp::UnsafeArenaSwap(Timestamp* other) { @@ -422,22 +387,18 @@ void Timestamp::UnsafeArenaSwap(Timestamp* other) { void Timestamp::InternalSwap(Timestamp* other) { std::swap(seconds_, other->seconds_); std::swap(nanos_, other->nanos_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Timestamp::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Timestamp_descriptor_; - metadata.reflection = Timestamp_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Timestamp -// optional int64 seconds = 1; +// int64 seconds = 1; void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -451,7 +412,7 @@ void Timestamp::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; void Timestamp::clear_nanos() { nanos_ = 0; } @@ -465,9 +426,6 @@ void Timestamp::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) } -inline const Timestamp* Timestamp::internal_default_instance() { - return &Timestamp_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 1abe8d0c..38ddb635 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -24,10 +24,17 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) +namespace google { +namespace protobuf { +class Timestamp; +class TimestampDefaultTypeInternal; +extern TimestampDefaultTypeInternal _Timestamp_default_instance_; +} // namespace protobuf +} // namespace google namespace google { namespace protobuf { @@ -35,10 +42,6 @@ namespace protobuf { // Internal implementation detail -- do not call these. void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto(); void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); - -class Timestamp; // =================================================================== @@ -54,47 +57,52 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Timestamp& default_instance(); - static const Timestamp* internal_default_instance(); + static inline const Timestamp* internal_default_instance() { + return reinterpret_cast<const Timestamp*>( + &_Timestamp_default_instance_); + } void UnsafeArenaSwap(Timestamp* other); void Swap(Timestamp* other); // implements Message ---------------------------------------------- - inline Timestamp* New() const { return New(NULL); } + inline Timestamp* New() const PROTOBUF_FINAL { return New(NULL); } - Timestamp* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Timestamp* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Timestamp& from); void MergeFrom(const Timestamp& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Timestamp* other); - void UnsafeMergeFrom(const Timestamp& from); protected: explicit Timestamp(::google::protobuf::Arena* arena); private: @@ -109,19 +117,19 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 seconds = 1; + // int64 seconds = 1; void clear_seconds(); static const int kSecondsFieldNumber = 1; ::google::protobuf::int64 seconds() const; void set_seconds(::google::protobuf::int64 value); - // optional int32 nanos = 2; + // int32 nanos = 2; void clear_nanos(); static const int kNanosFieldNumber = 2; ::google::protobuf::int32 nanos() const; @@ -139,13 +147,10 @@ class LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftimestamp_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftimestamp_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_default_instance_; - // =================================================================== @@ -154,7 +159,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Timestamp> Timestamp_ #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Timestamp -// optional int64 seconds = 1; +// int64 seconds = 1; inline void Timestamp::clear_seconds() { seconds_ = GOOGLE_LONGLONG(0); } @@ -168,7 +173,7 @@ inline void Timestamp::set_seconds(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds) } -// optional int32 nanos = 2; +// int32 nanos = 2; inline void Timestamp::clear_nanos() { nanos_ = 0; } @@ -182,13 +187,11 @@ inline void Timestamp::set_nanos(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos) } -inline const Timestamp* Timestamp::internal_default_instance() { - return &Timestamp_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index cc80dd92..6e41dde8 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -19,59 +19,42 @@ namespace google { namespace protobuf { +class TypeDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Type> {}; +TypeDefaultTypeInternal _Type_default_instance_; +class FieldDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Field> {}; +FieldDefaultTypeInternal _Field_default_instance_; +class EnumDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Enum> {}; +EnumDefaultTypeInternal _Enum_default_instance_; +class EnumValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> {}; +EnumValueDefaultTypeInternal _EnumValue_default_instance_; +class OptionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Option> {}; +OptionDefaultTypeInternal _Option_default_instance_; namespace { -const ::google::protobuf::Descriptor* Type_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Type_reflection_ = NULL; -const ::google::protobuf::Descriptor* Field_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Field_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Enum_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Enum_reflection_ = NULL; -const ::google::protobuf::Descriptor* EnumValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - EnumValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* Option_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Option_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Syntax_descriptor_ = NULL; +::google::protobuf::Metadata file_level_metadata[5]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[3]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/type.proto"); - GOOGLE_CHECK(file != NULL); - Type_descriptor_ = file->message_type(0); - static const int Type_offsets_[6] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_), - }; - Type_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Type_descriptor_, - Type::internal_default_instance(), - Type_offsets_, - -1, - -1, - -1, - sizeof(Type), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_)); - Field_descriptor_ = file->message_type(1); - static const int Field_offsets_[10] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_), @@ -82,107 +65,82 @@ void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_), - }; - Field_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Field_descriptor_, - Field::internal_default_instance(), - Field_offsets_, - -1, - -1, - -1, - sizeof(Field), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_)); - Field_Kind_descriptor_ = Field_descriptor_->enum_type(0); - Field_Cardinality_descriptor_ = Field_descriptor_->enum_type(1); - Enum_descriptor_ = file->message_type(2); - static const int Enum_offsets_[5] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_), - }; - Enum_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Enum_descriptor_, - Enum::internal_default_instance(), - Enum_offsets_, - -1, - -1, - -1, - sizeof(Enum), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_)); - EnumValue_descriptor_ = file->message_type(3); - static const int EnumValue_offsets_[3] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_), - }; - EnumValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - EnumValue_descriptor_, - EnumValue::internal_default_instance(), - EnumValue_offsets_, - -1, - -1, - -1, - sizeof(EnumValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_)); - Option_descriptor_ = file->message_type(4); - static const int Option_offsets_[2] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_), }; - Option_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Option_descriptor_, - Option::internal_default_instance(), - Option_offsets_, - -1, - -1, - -1, - sizeof(Option), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_)); - Syntax_descriptor_ = file->enum_type(0); + return offsets; } +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(Type)}, + { 10, -1, sizeof(Field)}, + { 24, -1, sizeof(Enum)}, + { 33, -1, sizeof(EnumValue)}, + { 40, -1, sizeof(Option)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_Type_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Field_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Enum_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_EnumValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Option_default_instance_), NULL}, +}; + namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/type.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(), factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Type_descriptor_, Type::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Field_descriptor_, Field::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Enum_descriptor_, Enum::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - EnumValue_descriptor_, EnumValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Option_descriptor_, Option::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 5); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() { - Type_default_instance_.Shutdown(); - delete Type_reflection_; - Field_default_instance_.Shutdown(); - delete Field_reflection_; - Enum_default_instance_.Shutdown(); - delete Enum_reflection_; - EnumValue_default_instance_.Shutdown(); - delete EnumValue_reflection_; - Option_default_instance_.Shutdown(); - delete Option_reflection_; + _Type_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _Field_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Enum_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _EnumValue_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _Option_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { @@ -190,72 +148,70 @@ void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl() { ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fany_2eproto(); ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fsource_5fcontext_2eproto(); - ::google::protobuf::internal::GetEmptyString(); - Type_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Field_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Enum_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - EnumValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - Option_default_instance_.DefaultConstruct(); - Type_default_instance_.get_mutable()->InitAsDefaultInstance(); - Field_default_instance_.get_mutable()->InitAsDefaultInstance(); - Enum_default_instance_.get_mutable()->InitAsDefaultInstance(); - EnumValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - Option_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_); + ::google::protobuf::internal::InitProtobufDefaults(); + _Type_default_instance_.DefaultConstruct(); + _Field_default_instance_.DefaultConstruct(); + _Enum_default_instance_.DefaultConstruct(); + _EnumValue_default_instance_.DefaultConstruct(); + _Option_default_instance_.DefaultConstruct(); + _Type_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); + _Enum_default_instance_.get_mutable()->source_context_ = const_cast< ::google::protobuf::SourceContext*>( + ::google::protobuf::SourceContext::internal_default_instance()); + _Option_default_instance_.get_mutable()->value_ = const_cast< ::google::protobuf::Any*>( + ::google::protobuf::Any::internal_default_instance()); +} + void protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + static const char descriptor[] = { + "\n\032google/protobuf/type.proto\022\017google.pro" + "tobuf\032\031google/protobuf/any.proto\032$google" + "/protobuf/source_context.proto\"\327\001\n\004Type\022" + "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p" + "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options" + "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc" + "e_context\030\005 \001(\0132\036.google.protobuf.Source" + "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu" + "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl" + "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001" + "(\0162\".google.protobuf.Field.Cardinality\022\016" + "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url" + "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 " + "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O" + "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu" + "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY" + "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6" + "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014" + "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE" + "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n" + "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY" + "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE" + "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020" + "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR" + "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION" + "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN" + "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022" + "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu" + "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu" + "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl" + "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016" + "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014" + "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030" + "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option" + "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p" + "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000" + "\022\021\n\rSYNTAX_PROTO3\020\001B}\n\023com.google.protob" + "ufB\tTypeProtoP\001Z/google.golang.org/genpr" + "oto/protobuf/ptype;ptype\370\001\001\242\002\003GPB\252\002\036Goog" + "le.Protobuf.WellKnownTypesb\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\032google/protobuf/type.proto\022\017google.pro" - "tobuf\032\031google/protobuf/any.proto\032$google" - "/protobuf/source_context.proto\"\327\001\n\004Type\022" - "\014\n\004name\030\001 \001(\t\022&\n\006fields\030\002 \003(\0132\026.google.p" - "rotobuf.Field\022\016\n\006oneofs\030\003 \003(\t\022(\n\007options" - "\030\004 \003(\0132\027.google.protobuf.Option\0226\n\016sourc" - "e_context\030\005 \001(\0132\036.google.protobuf.Source" - "Context\022\'\n\006syntax\030\006 \001(\0162\027.google.protobu" - "f.Syntax\"\325\005\n\005Field\022)\n\004kind\030\001 \001(\0162\033.googl" - "e.protobuf.Field.Kind\0227\n\013cardinality\030\002 \001" - "(\0162\".google.protobuf.Field.Cardinality\022\016" - "\n\006number\030\003 \001(\005\022\014\n\004name\030\004 \001(\t\022\020\n\010type_url" - "\030\006 \001(\t\022\023\n\013oneof_index\030\007 \001(\005\022\016\n\006packed\030\010 " - "\001(\010\022(\n\007options\030\t \003(\0132\027.google.protobuf.O" - "ption\022\021\n\tjson_name\030\n \001(\t\022\025\n\rdefault_valu" - "e\030\013 \001(\t\"\310\002\n\004Kind\022\020\n\014TYPE_UNKNOWN\020\000\022\017\n\013TY" - "PE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\nTYPE_INT6" - "4\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_INT32\020\005\022\020\n\014" - "TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020\007\022\r\n\tTYPE" - "_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYPE_GROUP\020\n" - "\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTES\020\014\022\017\n\013TY" - "PE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rTYPE_SFIXE" - "D32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYPE_SINT32\020" - "\021\022\017\n\013TYPE_SINT64\020\022\"t\n\013Cardinality\022\027\n\023CAR" - "DINALITY_UNKNOWN\020\000\022\030\n\024CARDINALITY_OPTION" - "AL\020\001\022\030\n\024CARDINALITY_REQUIRED\020\002\022\030\n\024CARDIN" - "ALITY_REPEATED\020\003\"\316\001\n\004Enum\022\014\n\004name\030\001 \001(\t\022" - "-\n\tenumvalue\030\002 \003(\0132\032.google.protobuf.Enu" - "mValue\022(\n\007options\030\003 \003(\0132\027.google.protobu" - "f.Option\0226\n\016source_context\030\004 \001(\0132\036.googl" - "e.protobuf.SourceContext\022\'\n\006syntax\030\005 \001(\016" - "2\027.google.protobuf.Syntax\"S\n\tEnumValue\022\014" - "\n\004name\030\001 \001(\t\022\016\n\006number\030\002 \001(\005\022(\n\007options\030" - "\003 \003(\0132\027.google.protobuf.Option\";\n\006Option" - "\022\014\n\004name\030\001 \001(\t\022#\n\005value\030\002 \001(\0132\024.google.p" - "rotobuf.Any*.\n\006Syntax\022\021\n\rSYNTAX_PROTO2\020\000" - "\022\021\n\rSYNTAX_PROTO3\020\001BL\n\023com.google.protob" - "ufB\tTypeProtoP\001\370\001\001\242\002\003GPB\252\002\036Google.Protob" - "uf.WellKnownTypesb\006proto3", 1545); + descriptor, 1594); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/type.proto", &protobuf_RegisterTypes); ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto(); @@ -274,29 +230,99 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto { protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); } } static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_; -const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { +const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { protobuf_AssignDescriptorsOnce(); - return Syntax_descriptor_; + return file_level_enum_descriptors[0]; } -bool Syntax_IsValid(int value) { +bool Field_Kind_IsValid(int value) { switch (value) { case 0: case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: return true; default: return false; } } - -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const Field_Kind Field::TYPE_UNKNOWN; +const Field_Kind Field::TYPE_DOUBLE; +const Field_Kind Field::TYPE_FLOAT; +const Field_Kind Field::TYPE_INT64; +const Field_Kind Field::TYPE_UINT64; +const Field_Kind Field::TYPE_INT32; +const Field_Kind Field::TYPE_FIXED64; +const Field_Kind Field::TYPE_FIXED32; +const Field_Kind Field::TYPE_BOOL; +const Field_Kind Field::TYPE_STRING; +const Field_Kind Field::TYPE_GROUP; +const Field_Kind Field::TYPE_MESSAGE; +const Field_Kind Field::TYPE_BYTES; +const Field_Kind Field::TYPE_UINT32; +const Field_Kind Field::TYPE_ENUM; +const Field_Kind Field::TYPE_SFIXED32; +const Field_Kind Field::TYPE_SFIXED64; +const Field_Kind Field::TYPE_SINT32; +const Field_Kind Field::TYPE_SINT64; +const Field_Kind Field::Kind_MIN; +const Field_Kind Field::Kind_MAX; +const int Field::Kind_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[1]; +} +bool Field_Cardinality_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + return true; + default: + return false; + } } -} // namespace +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const Field_Cardinality Field::CARDINALITY_UNKNOWN; +const Field_Cardinality Field::CARDINALITY_OPTIONAL; +const Field_Cardinality Field::CARDINALITY_REQUIRED; +const Field_Cardinality Field::CARDINALITY_REPEATED; +const Field_Cardinality Field::Cardinality_MIN; +const Field_Cardinality Field::Cardinality_MAX; +const int Field::Cardinality_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 +const ::google::protobuf::EnumDescriptor* Syntax_descriptor() { + protobuf_AssignDescriptorsOnce(); + return file_level_enum_descriptors[2]; +} +bool Syntax_IsValid(int value) { + switch (value) { + case 0: + case 1: + return true; + default: + return false; + } +} // =================================================================== @@ -345,7 +371,9 @@ const int Type::kSyntaxFieldNumber; Type::Type() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Type) } @@ -362,24 +390,32 @@ Type::Type(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Type) } - -void Type::InitAsDefaultInstance() { - source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); -} - Type::Type(const Type& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + fields_(from.fields_), + oneofs_(from.oneofs_), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Type) } void Type::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -395,7 +431,7 @@ void Type::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Type_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -413,7 +449,7 @@ void Type::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Type::descriptor() { protobuf_AssignDescriptorsOnce(); - return Type_descriptor_; + return file_level_metadata[0].descriptor; } const Type& Type::default_instance() { @@ -421,21 +457,21 @@ const Type& Type::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Type> Type_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) - name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; - source_context_ = NULL; - syntax_ = 0; fields_.Clear(); oneofs_.Clear(); options_.Clear(); + name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } + source_context_ = NULL; + syntax_ = 0; } bool Type::MergePartialFromCodedStream( @@ -444,13 +480,13 @@ bool Type::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Type) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -460,31 +496,25 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_fields; break; } // repeated .google.protobuf.Field fields = 2; case 2: { - if (tag == 18) { - parse_fields: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_fields: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_fields())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_fields; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(26)) goto parse_oneofs; break; } // repeated string oneofs = 3; case 3: { - if (tag == 26) { - parse_oneofs: + if (tag == 26u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->add_oneofs())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -495,45 +525,36 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_oneofs; - if (input->ExpectTag(34)) goto parse_options; break; } // repeated .google.protobuf.Option options = 4; case 4: { - if (tag == 34) { - parse_options: + if (tag == 34u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(42)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; case 5: { - if (tag == 42) { - parse_source_context: + if (tag == 42u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(48)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; case 6: { - if (tag == 48) { - parse_syntax: + if (tag == 48u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -542,7 +563,6 @@ bool Type::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -570,7 +590,7 @@ failure: void Type::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Type) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -602,13 +622,13 @@ void Type::SerializeWithCachedSizes( 4, this->options(i), output); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 5, *this->source_context_, output); } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 6, this->syntax(), output); @@ -621,7 +641,7 @@ void Type::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -656,14 +676,14 @@ void Type::SerializeWithCachedSizes( 4, this->options(i), false, target); } - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 5, *this->source_context_, false, target); } - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 6, this->syntax(), target); @@ -677,26 +697,6 @@ size_t Type::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.SourceContext source_context = 5; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 6; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.Field fields = 2; { unsigned int count = this->fields_size(); @@ -727,6 +727,26 @@ size_t Type::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // .google.protobuf.SourceContext source_context = 5; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 6; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -736,7 +756,7 @@ size_t Type::ByteSizeLong() const { void Type::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Type* source = ::google::protobuf::internal::DynamicCastToGenerated<const Type>( &from); @@ -745,23 +765,16 @@ void Type::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Type) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Type::MergeFrom(const Type& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Type::UnsafeMergeFrom(const Type& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); fields_.MergeFrom(from.fields_); - oneofs_.UnsafeMergeFrom(from.oneofs_); + oneofs_.MergeFrom(from.oneofs_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { set_name(from.name()); @@ -785,11 +798,10 @@ void Type::CopyFrom(const Type& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Type::IsInitialized() const { - return true; } @@ -798,10 +810,13 @@ void Type::Swap(Type* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Type temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Type* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Type::UnsafeArenaSwap(Type* other) { @@ -810,34 +825,30 @@ void Type::UnsafeArenaSwap(Type* other) { InternalSwap(other); } void Type::InternalSwap(Type* other) { - name_.Swap(&other->name_); fields_.UnsafeArenaSwap(&other->fields_); oneofs_.UnsafeArenaSwap(&other->oneofs_); options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); std::swap(source_context_, other->source_context_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Type::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Type_descriptor_; - metadata.reflection = Type_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Type -// optional string name = 1; +// string name = 1; void Type::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Type::set_name(const ::std::string& value) { @@ -1012,7 +1023,7 @@ Type::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; bool Type::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1063,7 +1074,7 @@ const ::google::protobuf::SourceContext& Type::source_context() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } -// optional .google.protobuf.Syntax syntax = 6; +// .google.protobuf.Syntax syntax = 6; void Type::clear_syntax() { syntax_ = 0; } @@ -1077,93 +1088,10 @@ void Type::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) } -inline const Type* Type::internal_default_instance() { - return &Type_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== -const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Field_Kind_descriptor_; -} -bool Field_Kind_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const Field_Kind Field::TYPE_UNKNOWN; -const Field_Kind Field::TYPE_DOUBLE; -const Field_Kind Field::TYPE_FLOAT; -const Field_Kind Field::TYPE_INT64; -const Field_Kind Field::TYPE_UINT64; -const Field_Kind Field::TYPE_INT32; -const Field_Kind Field::TYPE_FIXED64; -const Field_Kind Field::TYPE_FIXED32; -const Field_Kind Field::TYPE_BOOL; -const Field_Kind Field::TYPE_STRING; -const Field_Kind Field::TYPE_GROUP; -const Field_Kind Field::TYPE_MESSAGE; -const Field_Kind Field::TYPE_BYTES; -const Field_Kind Field::TYPE_UINT32; -const Field_Kind Field::TYPE_ENUM; -const Field_Kind Field::TYPE_SFIXED32; -const Field_Kind Field::TYPE_SFIXED64; -const Field_Kind Field::TYPE_SINT32; -const Field_Kind Field::TYPE_SINT64; -const Field_Kind Field::Kind_MIN; -const Field_Kind Field::Kind_MAX; -const int Field::Kind_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 -const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Field_Cardinality_descriptor_; -} -bool Field_Cardinality_IsValid(int value) { - switch (value) { - case 0: - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#if !defined(_MSC_VER) || _MSC_VER >= 1900 -const Field_Cardinality Field::CARDINALITY_UNKNOWN; -const Field_Cardinality Field::CARDINALITY_OPTIONAL; -const Field_Cardinality Field::CARDINALITY_REQUIRED; -const Field_Cardinality Field::CARDINALITY_REPEATED; -const Field_Cardinality Field::Cardinality_MIN; -const Field_Cardinality Field::Cardinality_MAX; -const int Field::Cardinality_ARRAYSIZE; -#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Field::kKindFieldNumber; const int Field::kCardinalityFieldNumber; @@ -1179,7 +1107,9 @@ const int Field::kDefaultValueFieldNumber; Field::Field() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Field) } @@ -1194,15 +1124,35 @@ Field::Field(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Field) } - -void Field::InitAsDefaultInstance() { -} - Field::Field(const Field& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.type_url().size() > 0) { + type_url_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url(), + GetArenaNoVirtual()); + } + json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.json_name().size() > 0) { + json_name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name(), + GetArenaNoVirtual()); + } + default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.default_value().size() > 0) { + default_value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value(), + GetArenaNoVirtual()); + } + ::memcpy(&kind_, &from.kind_, + reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_) + sizeof(packed_)); // @@protoc_insertion_point(copy_constructor:google.protobuf.Field) } @@ -1246,7 +1196,7 @@ void Field::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Field::descriptor() { protobuf_AssignDescriptorsOnce(); - return Field_descriptor_; + return file_level_metadata[1].descriptor; } const Field& Field::default_instance() { @@ -1254,40 +1204,19 @@ const Field& Field::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Field> Field_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) -#if defined(__clang__) -#define ZR_HELPER_(f) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(Field, f) \ - _Pragma("clang diagnostic pop") -#else -#define ZR_HELPER_(f) reinterpret_cast<char*>(\ - &reinterpret_cast<Field*>(16)->f) -#endif - -#define ZR_(first, last) do {\ - ::memset(&(first), 0,\ - ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ -} while (0) - - ZR_(kind_, packed_); + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - -#undef ZR_HELPER_ -#undef ZR_ - - options_.Clear(); + ::memset(&kind_, 0, reinterpret_cast<char*>(&packed_) - + reinterpret_cast<char*>(&kind_) + sizeof(packed_)); } bool Field::MergePartialFromCodedStream( @@ -1296,13 +1225,13 @@ bool Field::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Field) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1311,14 +1240,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_cardinality; break; } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; case 2: { - if (tag == 16) { - parse_cardinality: + if (tag == 16u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -1327,14 +1254,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(24)) goto parse_number; break; } - // optional int32 number = 3; + // int32 number = 3; case 3: { - if (tag == 24) { - parse_number: + if (tag == 24u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1342,14 +1267,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(34)) goto parse_name; break; } - // optional string name = 4; + // string name = 4; case 4: { - if (tag == 34) { - parse_name: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1359,14 +1282,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(50)) goto parse_type_url; break; } - // optional string type_url = 6; + // string type_url = 6; case 6: { - if (tag == 50) { - parse_type_url: + if (tag == 50u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_type_url())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1376,14 +1297,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(56)) goto parse_oneof_index; break; } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; case 7: { - if (tag == 56) { - parse_oneof_index: + if (tag == 56u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1391,14 +1310,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(64)) goto parse_packed; break; } - // optional bool packed = 8; + // bool packed = 8; case 8: { - if (tag == 64) { - parse_packed: + if (tag == 64u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -1406,31 +1323,25 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_options; break; } // repeated .google.protobuf.Option options = 9; case 9: { - if (tag == 74) { - parse_options: + if (tag == 74u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(74)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(82)) goto parse_json_name; break; } - // optional string json_name = 10; + // string json_name = 10; case 10: { - if (tag == 82) { - parse_json_name: + if (tag == 82u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_json_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1440,14 +1351,12 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(90)) goto parse_default_value; break; } - // optional string default_value = 11; + // string default_value = 11; case 11: { - if (tag == 90) { - parse_default_value: + if (tag == 90u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_default_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -1457,7 +1366,6 @@ bool Field::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1485,24 +1393,24 @@ failure: void Field::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Field) - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 1, this->kind(), output); } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; if (this->cardinality() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 2, this->cardinality(), output); } - // optional int32 number = 3; + // int32 number = 3; if (this->number() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output); } - // optional string name = 4; + // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1512,7 +1420,7 @@ void Field::SerializeWithCachedSizes( 4, this->name(), output); } - // optional string type_url = 6; + // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -1522,12 +1430,12 @@ void Field::SerializeWithCachedSizes( 6, this->type_url(), output); } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; if (this->oneof_index() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->oneof_index(), output); } - // optional bool packed = 8; + // bool packed = 8; if (this->packed() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->packed(), output); } @@ -1538,7 +1446,7 @@ void Field::SerializeWithCachedSizes( 9, this->options(i), output); } - // optional string json_name = 10; + // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->json_name().data(), this->json_name().length(), @@ -1548,7 +1456,7 @@ void Field::SerializeWithCachedSizes( 10, this->json_name(), output); } - // optional string default_value = 11; + // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->default_value().data(), this->default_value().length(), @@ -1565,24 +1473,24 @@ void Field::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field) - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; if (this->kind() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 1, this->kind(), target); } - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; if (this->cardinality() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 2, this->cardinality(), target); } - // optional int32 number = 3; + // int32 number = 3; if (this->number() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target); } - // optional string name = 4; + // string name = 4; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -1593,7 +1501,7 @@ void Field::SerializeWithCachedSizes( 4, this->name(), target); } - // optional string type_url = 6; + // string type_url = 6; if (this->type_url().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->type_url().data(), this->type_url().length(), @@ -1604,12 +1512,12 @@ void Field::SerializeWithCachedSizes( 6, this->type_url(), target); } - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; if (this->oneof_index() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->oneof_index(), target); } - // optional bool packed = 8; + // bool packed = 8; if (this->packed() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->packed(), target); } @@ -1621,7 +1529,7 @@ void Field::SerializeWithCachedSizes( 9, this->options(i), false, target); } - // optional string json_name = 10; + // string json_name = 10; if (this->json_name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->json_name().data(), this->json_name().length(), @@ -1632,7 +1540,7 @@ void Field::SerializeWithCachedSizes( 10, this->json_name(), target); } - // optional string default_value = 11; + // string default_value = 11; if (this->default_value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->default_value().data(), this->default_value().length(), @@ -1651,74 +1559,74 @@ size_t Field::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field) size_t total_size = 0; - // optional .google.protobuf.Field.Kind kind = 1; - if (this->kind() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind()); + // repeated .google.protobuf.Option options = 9; + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } } - // optional .google.protobuf.Field.Cardinality cardinality = 2; - if (this->cardinality() != 0) { + // string name = 4; + if (this->name().size() > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality()); + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); } - // optional int32 number = 3; - if (this->number() != 0) { + // string type_url = 6; + if (this->type_url().size() > 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->number()); + ::google::protobuf::internal::WireFormatLite::StringSize( + this->type_url()); } - // optional string name = 4; - if (this->name().size() > 0) { + // string json_name = 10; + if (this->json_name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); + this->json_name()); } - // optional string type_url = 6; - if (this->type_url().size() > 0) { + // string default_value = 11; + if (this->default_value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( - this->type_url()); + this->default_value()); } - // optional int32 oneof_index = 7; - if (this->oneof_index() != 0) { + // .google.protobuf.Field.Kind kind = 1; + if (this->kind() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->oneof_index()); + ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind()); } - // optional bool packed = 8; - if (this->packed() != 0) { - total_size += 1 + 1; + // .google.protobuf.Field.Cardinality cardinality = 2; + if (this->cardinality() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality()); } - // optional string json_name = 10; - if (this->json_name().size() > 0) { + // int32 number = 3; + if (this->number() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->json_name()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->number()); } - // optional string default_value = 11; - if (this->default_value().size() > 0) { + // int32 oneof_index = 7; + if (this->oneof_index() != 0) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->default_value()); + ::google::protobuf::internal::WireFormatLite::Int32Size( + this->oneof_index()); } - // repeated .google.protobuf.Option options = 9; - { - unsigned int count = this->options_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); - } + // bool packed = 8; + if (this->packed() != 0) { + total_size += 1 + 1; } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); @@ -1730,7 +1638,7 @@ size_t Field::ByteSizeLong() const { void Field::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Field* source = ::google::protobuf::internal::DynamicCastToGenerated<const Field>( &from); @@ -1739,22 +1647,27 @@ void Field::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Field) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Field::MergeFrom(const Field& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Field::UnsafeMergeFrom(const Field& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); + if (from.name().size() > 0) { + set_name(from.name()); + } + if (from.type_url().size() > 0) { + set_type_url(from.type_url()); + } + if (from.json_name().size() > 0) { + set_json_name(from.json_name()); + } + if (from.default_value().size() > 0) { + set_default_value(from.default_value()); + } if (from.kind() != 0) { set_kind(from.kind()); } @@ -1764,24 +1677,12 @@ void Field::UnsafeMergeFrom(const Field& from) { if (from.number() != 0) { set_number(from.number()); } - if (from.name().size() > 0) { - set_name(from.name()); - } - if (from.type_url().size() > 0) { - set_type_url(from.type_url()); - } if (from.oneof_index() != 0) { set_oneof_index(from.oneof_index()); } if (from.packed() != 0) { set_packed(from.packed()); } - if (from.json_name().size() > 0) { - set_json_name(from.json_name()); - } - if (from.default_value().size() > 0) { - set_default_value(from.default_value()); - } } void Field::CopyFrom(const ::google::protobuf::Message& from) { @@ -1795,11 +1696,10 @@ void Field::CopyFrom(const Field& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Field::IsInitialized() const { - return true; } @@ -1808,10 +1708,13 @@ void Field::Swap(Field* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Field temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Field* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Field::UnsafeArenaSwap(Field* other) { @@ -1820,32 +1723,28 @@ void Field::UnsafeArenaSwap(Field* other) { InternalSwap(other); } void Field::InternalSwap(Field* other) { + options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); + type_url_.Swap(&other->type_url_); + json_name_.Swap(&other->json_name_); + default_value_.Swap(&other->default_value_); std::swap(kind_, other->kind_); std::swap(cardinality_, other->cardinality_); std::swap(number_, other->number_); - name_.Swap(&other->name_); - type_url_.Swap(&other->type_url_); std::swap(oneof_index_, other->oneof_index_); std::swap(packed_, other->packed_); - options_.UnsafeArenaSwap(&other->options_); - json_name_.Swap(&other->json_name_); - default_value_.Swap(&other->default_value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Field::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Field_descriptor_; - metadata.reflection = Field_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Field -// optional .google.protobuf.Field.Kind kind = 1; +// .google.protobuf.Field.Kind kind = 1; void Field::clear_kind() { kind_ = 0; } @@ -1859,7 +1758,7 @@ void Field::set_kind(::google::protobuf::Field_Kind value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) } -// optional .google.protobuf.Field.Cardinality cardinality = 2; +// .google.protobuf.Field.Cardinality cardinality = 2; void Field::clear_cardinality() { cardinality_ = 0; } @@ -1873,7 +1772,7 @@ void Field::set_cardinality(::google::protobuf::Field_Cardinality value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) } -// optional int32 number = 3; +// int32 number = 3; void Field::clear_number() { number_ = 0; } @@ -1887,13 +1786,13 @@ void Field::set_number(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.number) } -// optional string name = 4; +// string name = 4; void Field::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Field::set_name(const ::std::string& value) { @@ -1953,13 +1852,13 @@ void Field::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) } -// optional string type_url = 6; +// string type_url = 6; void Field::clear_type_url() { type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(); } void Field::set_type_url(const ::std::string& value) { @@ -2019,7 +1918,7 @@ void Field::unsafe_arena_set_allocated_type_url( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) } -// optional int32 oneof_index = 7; +// int32 oneof_index = 7; void Field::clear_oneof_index() { oneof_index_ = 0; } @@ -2033,7 +1932,7 @@ void Field::set_oneof_index(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) } -// optional bool packed = 8; +// bool packed = 8; void Field::clear_packed() { packed_ = false; } @@ -2077,13 +1976,13 @@ Field::options() const { return options_; } -// optional string json_name = 10; +// string json_name = 10; void Field::clear_json_name() { json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(); } void Field::set_json_name(const ::std::string& value) { @@ -2143,13 +2042,13 @@ void Field::unsafe_arena_set_allocated_json_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) } -// optional string default_value = 11; +// string default_value = 11; void Field::clear_default_value() { default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(); } void Field::set_default_value(const ::std::string& value) { @@ -2209,9 +2108,6 @@ void Field::unsafe_arena_set_allocated_default_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) } -inline const Field* Field::internal_default_instance() { - return &Field_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2259,7 +2155,9 @@ const int Enum::kSyntaxFieldNumber; Enum::Enum() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Enum) } @@ -2275,24 +2173,31 @@ Enum::Enum(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Enum) } - -void Enum::InitAsDefaultInstance() { - source_context_ = const_cast< ::google::protobuf::SourceContext*>( - ::google::protobuf::SourceContext::internal_default_instance()); -} - Enum::Enum(const Enum& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + enumvalue_(from.enumvalue_), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_source_context()) { + source_context_ = new ::google::protobuf::SourceContext(*from.source_context_); + } else { + source_context_ = NULL; + } + syntax_ = from.syntax_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum) } void Enum::SharedCtor() { name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); - source_context_ = NULL; - syntax_ = 0; + ::memset(&source_context_, 0, reinterpret_cast<char*>(&syntax_) - + reinterpret_cast<char*>(&source_context_) + sizeof(syntax_)); _cached_size_ = 0; } @@ -2308,7 +2213,7 @@ void Enum::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Enum_default_instance_.get()) { + if (this != internal_default_instance()) { delete source_context_; } } @@ -2326,7 +2231,7 @@ void Enum::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Enum::descriptor() { protobuf_AssignDescriptorsOnce(); - return Enum_descriptor_; + return file_level_metadata[2].descriptor; } const Enum& Enum::default_instance() { @@ -2334,20 +2239,20 @@ const Enum& Enum::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_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) + enumvalue_.Clear(); + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_; + if (GetArenaNoVirtual() == NULL && source_context_ != NULL) { + delete source_context_; + } source_context_ = NULL; syntax_ = 0; - enumvalue_.Clear(); - options_.Clear(); } bool Enum::MergePartialFromCodedStream( @@ -2356,13 +2261,13 @@ bool Enum::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Enum) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2372,60 +2277,49 @@ bool Enum::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_enumvalue; break; } // repeated .google.protobuf.EnumValue enumvalue = 2; case 2: { - if (tag == 18) { - parse_enumvalue: + if (tag == 18u) { DO_(input->IncrementRecursionDepth()); - parse_loop_enumvalue: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_enumvalue())); } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_loop_enumvalue; - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectTag(34)) goto parse_source_context; break; } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; case 4: { - if (tag == 34) { - parse_source_context: + if (tag == 34u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_source_context())); } else { goto handle_unusual; } - if (input->ExpectTag(40)) goto parse_syntax; break; } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; case 5: { - if (tag == 40) { - parse_syntax: + if (tag == 40u) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -2434,7 +2328,6 @@ bool Enum::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2462,7 +2355,7 @@ failure: void Enum::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Enum) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -2484,13 +2377,13 @@ void Enum::SerializeWithCachedSizes( 3, this->options(i), output); } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 4, *this->source_context_, output); } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; if (this->syntax() != 0) { ::google::protobuf::internal::WireFormatLite::WriteEnum( 5, this->syntax(), output); @@ -2503,7 +2396,7 @@ void Enum::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -2528,14 +2421,14 @@ void Enum::SerializeWithCachedSizes( 3, this->options(i), false, target); } - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; if (this->has_source_context()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( 4, *this->source_context_, false, target); } - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; if (this->syntax() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( 5, this->syntax(), target); @@ -2549,26 +2442,6 @@ size_t Enum::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum) size_t total_size = 0; - // optional string name = 1; - if (this->name().size() > 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional .google.protobuf.SourceContext source_context = 4; - if (this->has_source_context()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - *this->source_context_); - } - - // optional .google.protobuf.Syntax syntax = 5; - if (this->syntax() != 0) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); - } - // repeated .google.protobuf.EnumValue enumvalue = 2; { unsigned int count = this->enumvalue_size(); @@ -2591,6 +2464,26 @@ size_t Enum::ByteSizeLong() const { } } + // string name = 1; + if (this->name().size() > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->name()); + } + + // .google.protobuf.SourceContext source_context = 4; + if (this->has_source_context()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + *this->source_context_); + } + + // .google.protobuf.Syntax syntax = 5; + if (this->syntax() != 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax()); + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -2600,7 +2493,7 @@ size_t Enum::ByteSizeLong() const { void Enum::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Enum* source = ::google::protobuf::internal::DynamicCastToGenerated<const Enum>( &from); @@ -2609,21 +2502,14 @@ void Enum::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Enum) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Enum::MergeFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Enum::UnsafeMergeFrom(const Enum& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { @@ -2648,11 +2534,10 @@ void Enum::CopyFrom(const Enum& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Enum::IsInitialized() const { - return true; } @@ -2661,10 +2546,13 @@ void Enum::Swap(Enum* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Enum temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Enum* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Enum::UnsafeArenaSwap(Enum* other) { @@ -2673,33 +2561,29 @@ void Enum::UnsafeArenaSwap(Enum* other) { InternalSwap(other); } void Enum::InternalSwap(Enum* other) { - name_.Swap(&other->name_); enumvalue_.UnsafeArenaSwap(&other->enumvalue_); options_.UnsafeArenaSwap(&other->options_); + name_.Swap(&other->name_); std::swap(source_context_, other->source_context_); std::swap(syntax_, other->syntax_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Enum::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Enum_descriptor_; - metadata.reflection = Enum_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Enum -// optional string name = 1; +// string name = 1; void Enum::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Enum::set_name(const ::std::string& value) { @@ -2819,7 +2703,7 @@ Enum::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 4; +// .google.protobuf.SourceContext source_context = 4; bool Enum::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -2870,7 +2754,7 @@ const ::google::protobuf::SourceContext& Enum::source_context() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } -// optional .google.protobuf.Syntax syntax = 5; +// .google.protobuf.Syntax syntax = 5; void Enum::clear_syntax() { syntax_ = 0; } @@ -2884,9 +2768,6 @@ void Enum::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) } -inline const Enum* Enum::internal_default_instance() { - return &Enum_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2899,7 +2780,9 @@ const int EnumValue::kOptionsFieldNumber; EnumValue::EnumValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.EnumValue) } @@ -2914,15 +2797,18 @@ EnumValue::EnumValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.EnumValue) } - -void EnumValue::InitAsDefaultInstance() { -} - EnumValue::EnumValue(const EnumValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + options_(from.options_), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + number_ = from.number_; // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue) } @@ -2959,7 +2845,7 @@ void EnumValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* EnumValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return EnumValue_descriptor_; + return file_level_metadata[3].descriptor; } const EnumValue& EnumValue::default_instance() { @@ -2967,17 +2853,15 @@ const EnumValue& EnumValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_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) + options_.Clear(); name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); number_ = 0; - options_.Clear(); } bool EnumValue::MergePartialFromCodedStream( @@ -2986,13 +2870,13 @@ bool EnumValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.EnumValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3002,14 +2886,12 @@ bool EnumValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(16)) goto parse_number; break; } - // optional int32 number = 2; + // int32 number = 2; case 2: { - if (tag == 16) { - parse_number: + if (tag == 16u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -3017,24 +2899,19 @@ bool EnumValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_options; break; } // repeated .google.protobuf.Option options = 3; case 3: { - if (tag == 26) { - parse_options: + if (tag == 26u) { DO_(input->IncrementRecursionDepth()); - parse_loop_options: DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( input, add_options())); } else { goto handle_unusual; } - if (input->ExpectTag(26)) goto parse_loop_options; input->UnsafeDecrementRecursionDepth(); - if (input->ExpectAtEnd()) goto success; break; } @@ -3062,7 +2939,7 @@ failure: void EnumValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.EnumValue) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3072,7 +2949,7 @@ void EnumValue::SerializeWithCachedSizes( 1, this->name(), output); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output); } @@ -3090,7 +2967,7 @@ void EnumValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3101,7 +2978,7 @@ void EnumValue::SerializeWithCachedSizes( 1, this->name(), target); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target); } @@ -3121,31 +2998,31 @@ size_t EnumValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue) size_t total_size = 0; - // optional string name = 1; + // repeated .google.protobuf.Option options = 3; + { + unsigned int count = this->options_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->options(i)); + } + } + + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional int32 number = 2; + // int32 number = 2; if (this->number() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->number()); } - // repeated .google.protobuf.Option options = 3; - { - unsigned int count = this->options_size(); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->options(i)); - } - } - int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; @@ -3155,7 +3032,7 @@ size_t EnumValue::ByteSizeLong() const { void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const EnumValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const EnumValue>( &from); @@ -3164,21 +3041,14 @@ void EnumValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void EnumValue::MergeFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void EnumValue::UnsafeMergeFrom(const EnumValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { set_name(from.name()); @@ -3199,11 +3069,10 @@ void EnumValue::CopyFrom(const EnumValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool EnumValue::IsInitialized() const { - return true; } @@ -3212,10 +3081,13 @@ void EnumValue::Swap(EnumValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - EnumValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + EnumValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void EnumValue::UnsafeArenaSwap(EnumValue* other) { @@ -3224,31 +3096,27 @@ void EnumValue::UnsafeArenaSwap(EnumValue* other) { InternalSwap(other); } void EnumValue::InternalSwap(EnumValue* other) { + options_.UnsafeArenaSwap(&other->options_); name_.Swap(&other->name_); std::swap(number_, other->number_); - options_.UnsafeArenaSwap(&other->options_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata EnumValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = EnumValue_descriptor_; - metadata.reflection = EnumValue_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // EnumValue -// optional string name = 1; +// string name = 1; void EnumValue::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void EnumValue::set_name(const ::std::string& value) { @@ -3308,7 +3176,7 @@ void EnumValue::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) } -// optional int32 number = 2; +// int32 number = 2; void EnumValue::clear_number() { number_ = 0; } @@ -3352,9 +3220,6 @@ EnumValue::options() const { return options_; } -inline const EnumValue* EnumValue::internal_default_instance() { - return &EnumValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -3399,7 +3264,9 @@ const int Option::kValueFieldNumber; Option::Option() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Option) } @@ -3413,17 +3280,21 @@ Option::Option(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Option) } - -void Option::InitAsDefaultInstance() { - value_ = const_cast< ::google::protobuf::Any*>( - ::google::protobuf::Any::internal_default_instance()); -} - Option::Option(const Option& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.name().size() > 0) { + name_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name(), + GetArenaNoVirtual()); + } + if (from.has_value()) { + value_ = new ::google::protobuf::Any(*from.value_); + } else { + value_ = NULL; + } // @@protoc_insertion_point(copy_constructor:google.protobuf.Option) } @@ -3445,7 +3316,7 @@ void Option::SharedDtor() { } name_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), arena); - if (this != &Option_default_instance_.get()) { + if (this != internal_default_instance()) { delete value_; } } @@ -3463,7 +3334,7 @@ void Option::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Option::descriptor() { protobuf_AssignDescriptorsOnce(); - return Option_descriptor_; + return file_level_metadata[4].descriptor; } const Option& Option::default_instance() { @@ -3471,8 +3342,6 @@ const Option& Option::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_; - Option* Option::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Option>(arena); } @@ -3480,7 +3349,9 @@ Option* Option::New(::google::protobuf::Arena* arena) const { void Option::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.Option) name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_; + if (GetArenaNoVirtual() == NULL && value_ != NULL) { + delete value_; + } value_ = NULL; } @@ -3490,13 +3361,13 @@ bool Option::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Option) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string name = 1; + // string name = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -3506,20 +3377,17 @@ bool Option::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectTag(18)) goto parse_value; break; } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; case 2: { - if (tag == 18) { - parse_value: + if (tag == 18u) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -3547,7 +3415,7 @@ failure: void Option::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Option) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3557,7 +3425,7 @@ void Option::SerializeWithCachedSizes( 1, this->name(), output); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( 2, *this->value_, output); @@ -3570,7 +3438,7 @@ void Option::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option) - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->name().data(), this->name().length(), @@ -3581,7 +3449,7 @@ void Option::SerializeWithCachedSizes( 1, this->name(), target); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( @@ -3596,14 +3464,14 @@ size_t Option::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option) size_t total_size = 0; - // optional string name = 1; + // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->name()); } - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; if (this->has_value()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( @@ -3619,7 +3487,7 @@ size_t Option::ByteSizeLong() const { void Option::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Option* source = ::google::protobuf::internal::DynamicCastToGenerated<const Option>( &from); @@ -3628,21 +3496,14 @@ void Option::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Option) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Option::MergeFrom(const Option& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Option::UnsafeMergeFrom(const Option& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.name().size() > 0) { set_name(from.name()); } @@ -3662,11 +3523,10 @@ void Option::CopyFrom(const Option& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Option) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Option::IsInitialized() const { - return true; } @@ -3675,10 +3535,13 @@ void Option::Swap(Option* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Option temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Option* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Option::UnsafeArenaSwap(Option* other) { @@ -3689,28 +3552,24 @@ void Option::UnsafeArenaSwap(Option* other) { void Option::InternalSwap(Option* other) { name_.Swap(&other->name_); std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Option::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Option_descriptor_; - metadata.reflection = Option_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Option -// optional string name = 1; +// string name = 1; void Option::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } void Option::set_name(const ::std::string& value) { @@ -3770,7 +3629,7 @@ void Option::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) } -// optional .google.protobuf.Any value = 2; +// .google.protobuf.Any value = 2; bool Option::has_value() const { return this != internal_default_instance() && value_ != NULL; } @@ -3821,9 +3680,6 @@ const ::google::protobuf::Any& Option::value() const { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } -inline const Option* Option::internal_default_instance() { - return &Option_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 1b6d3410..6f29ab61 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -24,28 +24,45 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/generated_enum_reflection.h> #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.pb.h> #include <google/protobuf/source_context.pb.h> // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { - -// Internal implementation detail -- do not call these. -void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); -void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - +class Any; +class AnyDefaultTypeInternal; +extern AnyDefaultTypeInternal _Any_default_instance_; class Enum; +class EnumDefaultTypeInternal; +extern EnumDefaultTypeInternal _Enum_default_instance_; class EnumValue; +class EnumValueDefaultTypeInternal; +extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; class Field; +class FieldDefaultTypeInternal; +extern FieldDefaultTypeInternal _Field_default_instance_; class Option; +class OptionDefaultTypeInternal; +extern OptionDefaultTypeInternal _Option_default_instance_; +class SourceContext; +class SourceContextDefaultTypeInternal; +extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; class Type; +class TypeDefaultTypeInternal; +extern TypeDefaultTypeInternal _Type_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +// Internal implementation detail -- do not call these. +void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto(); enum Field_Kind { Field_Kind_TYPE_UNKNOWN = 0, @@ -143,47 +160,52 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Type& default_instance(); - static const Type* internal_default_instance(); + static inline const Type* internal_default_instance() { + return reinterpret_cast<const Type*>( + &_Type_default_instance_); + } void UnsafeArenaSwap(Type* other); void Swap(Type* other); // implements Message ---------------------------------------------- - inline Type* New() const { return New(NULL); } + inline Type* New() const PROTOBUF_FINAL { return New(NULL); } - Type* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Type* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Type& from); void MergeFrom(const Type& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Type* other); - void UnsafeMergeFrom(const Type& from); protected: explicit Type(::google::protobuf::Arena* arena); private: @@ -198,13 +220,13 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -258,7 +280,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.SourceContext source_context = 5; + // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 5; @@ -274,7 +296,7 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); - // optional .google.protobuf.Syntax syntax = 6; + // .google.protobuf.Syntax syntax = 6; void clear_syntax(); static const int kSyntaxFieldNumber = 6; ::google::protobuf::Syntax syntax() const; @@ -296,13 +318,10 @@ class LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_i mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Type> Type_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ { @@ -317,47 +336,52 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Field& default_instance(); - static const Field* internal_default_instance(); + static inline const Field* internal_default_instance() { + return reinterpret_cast<const Field*>( + &_Field_default_instance_); + } void UnsafeArenaSwap(Field* other); void Swap(Field* other); // implements Message ---------------------------------------------- - inline Field* New() const { return New(NULL); } + inline Field* New() const PROTOBUF_FINAL { return New(NULL); } - Field* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Field* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Field& from); void MergeFrom(const Field& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Field* other); - void UnsafeMergeFrom(const Field& from); protected: explicit Field(::google::protobuf::Arena* arena); private: @@ -372,7 +396,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- @@ -468,25 +492,25 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ // accessors ------------------------------------------------------- - // optional .google.protobuf.Field.Kind kind = 1; + // .google.protobuf.Field.Kind kind = 1; void clear_kind(); static const int kKindFieldNumber = 1; ::google::protobuf::Field_Kind kind() const; void set_kind(::google::protobuf::Field_Kind value); - // optional .google.protobuf.Field.Cardinality cardinality = 2; + // .google.protobuf.Field.Cardinality cardinality = 2; void clear_cardinality(); static const int kCardinalityFieldNumber = 2; ::google::protobuf::Field_Cardinality cardinality() const; void set_cardinality(::google::protobuf::Field_Cardinality value); - // optional int32 number = 3; + // int32 number = 3; void clear_number(); static const int kNumberFieldNumber = 3; ::google::protobuf::int32 number() const; void set_number(::google::protobuf::int32 value); - // optional string name = 4; + // string name = 4; void clear_name(); static const int kNameFieldNumber = 4; const ::std::string& name() const; @@ -500,7 +524,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_name( ::std::string* name); - // optional string type_url = 6; + // string type_url = 6; void clear_type_url(); static const int kTypeUrlFieldNumber = 6; const ::std::string& type_url() const; @@ -514,13 +538,13 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_type_url( ::std::string* type_url); - // optional int32 oneof_index = 7; + // int32 oneof_index = 7; void clear_oneof_index(); static const int kOneofIndexFieldNumber = 7; ::google::protobuf::int32 oneof_index() const; void set_oneof_index(::google::protobuf::int32 value); - // optional bool packed = 8; + // bool packed = 8; void clear_packed(); static const int kPackedFieldNumber = 8; bool packed() const; @@ -538,7 +562,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional string json_name = 10; + // string json_name = 10; void clear_json_name(); static const int kJsonNameFieldNumber = 10; const ::std::string& json_name() const; @@ -552,7 +576,7 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ void unsafe_arena_set_allocated_json_name( ::std::string* json_name); - // optional string default_value = 11; + // string default_value = 11; void clear_default_value(); static const int kDefaultValueFieldNumber = 11; const ::std::string& default_value() const; @@ -586,13 +610,10 @@ class LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_ mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Field> Field_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ { @@ -607,47 +628,52 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Enum& default_instance(); - static const Enum* internal_default_instance(); + static inline const Enum* internal_default_instance() { + return reinterpret_cast<const Enum*>( + &_Enum_default_instance_); + } void UnsafeArenaSwap(Enum* other); void Swap(Enum* other); // implements Message ---------------------------------------------- - inline Enum* New() const { return New(NULL); } + inline Enum* New() const PROTOBUF_FINAL { return New(NULL); } - Enum* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Enum* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Enum& from); void MergeFrom(const Enum& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Enum* other); - void UnsafeMergeFrom(const Enum& from); protected: explicit Enum(::google::protobuf::Arena* arena); private: @@ -662,13 +688,13 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -706,7 +732,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >& options() const; - // optional .google.protobuf.SourceContext source_context = 4; + // .google.protobuf.SourceContext source_context = 4; bool has_source_context() const; void clear_source_context(); static const int kSourceContextFieldNumber = 4; @@ -722,7 +748,7 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i void unsafe_arena_set_allocated_source_context( ::google::protobuf::SourceContext* source_context); - // optional .google.protobuf.Syntax syntax = 5; + // .google.protobuf.Syntax syntax = 5; void clear_syntax(); static const int kSyntaxFieldNumber = 5; ::google::protobuf::Syntax syntax() const; @@ -743,13 +769,10 @@ class LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_i mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Enum> Enum_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ { @@ -764,47 +787,52 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const EnumValue& default_instance(); - static const EnumValue* internal_default_instance(); + static inline const EnumValue* internal_default_instance() { + return reinterpret_cast<const EnumValue*>( + &_EnumValue_default_instance_); + } void UnsafeArenaSwap(EnumValue* other); void Swap(EnumValue* other); // implements Message ---------------------------------------------- - inline EnumValue* New() const { return New(NULL); } + inline EnumValue* New() const PROTOBUF_FINAL { return New(NULL); } - EnumValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + EnumValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const EnumValue& from); void MergeFrom(const EnumValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(EnumValue* other); - void UnsafeMergeFrom(const EnumValue& from); protected: explicit EnumValue(::google::protobuf::Arena* arena); private: @@ -819,13 +847,13 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -839,7 +867,7 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro void unsafe_arena_set_allocated_name( ::std::string* name); - // optional int32 number = 2; + // int32 number = 2; void clear_number(); static const int kNumberFieldNumber = 2; ::google::protobuf::int32 number() const; @@ -870,13 +898,10 @@ class LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<EnumValue> EnumValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ { @@ -891,47 +916,52 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Option& default_instance(); - static const Option* internal_default_instance(); + static inline const Option* internal_default_instance() { + return reinterpret_cast<const Option*>( + &_Option_default_instance_); + } void UnsafeArenaSwap(Option* other); void Swap(Option* other); // implements Message ---------------------------------------------- - inline Option* New() const { return New(NULL); } + inline Option* New() const PROTOBUF_FINAL { return New(NULL); } - Option* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Option* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Option& from); void MergeFrom(const Option& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Option* other); - void UnsafeMergeFrom(const Option& from); protected: explicit Option(::google::protobuf::Arena* arena); private: @@ -946,13 +976,13 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string name = 1; + // string name = 1; void clear_name(); static const int kNameFieldNumber = 1; const ::std::string& name() const; @@ -966,7 +996,7 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc void unsafe_arena_set_allocated_name( ::std::string* name); - // optional .google.protobuf.Any value = 2; + // .google.protobuf.Any value = 2; bool has_value() const; void clear_value(); static const int kValueFieldNumber = 2; @@ -994,13 +1024,10 @@ class LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2ftype_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2ftype_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_default_instance_; - // =================================================================== @@ -1009,13 +1036,13 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<Option> Option_defaul #if !PROTOBUF_INLINE_NOT_IN_HEADERS // Type -// optional string name = 1; +// string name = 1; inline void Type::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Type::set_name(const ::std::string& value) { @@ -1190,7 +1217,7 @@ Type::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 5; +// .google.protobuf.SourceContext source_context = 5; inline bool Type::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1241,7 +1268,7 @@ inline void Type::set_allocated_source_context(::google::protobuf::SourceContex // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context) } -// optional .google.protobuf.Syntax syntax = 6; +// .google.protobuf.Syntax syntax = 6; inline void Type::clear_syntax() { syntax_ = 0; } @@ -1255,14 +1282,11 @@ inline void Type::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax) } -inline const Type* Type::internal_default_instance() { - return &Type_default_instance_.get(); -} // ------------------------------------------------------------------- // Field -// optional .google.protobuf.Field.Kind kind = 1; +// .google.protobuf.Field.Kind kind = 1; inline void Field::clear_kind() { kind_ = 0; } @@ -1276,7 +1300,7 @@ inline void Field::set_kind(::google::protobuf::Field_Kind value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.kind) } -// optional .google.protobuf.Field.Cardinality cardinality = 2; +// .google.protobuf.Field.Cardinality cardinality = 2; inline void Field::clear_cardinality() { cardinality_ = 0; } @@ -1290,7 +1314,7 @@ inline void Field::set_cardinality(::google::protobuf::Field_Cardinality value) // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality) } -// optional int32 number = 3; +// int32 number = 3; inline void Field::clear_number() { number_ = 0; } @@ -1304,13 +1328,13 @@ inline void Field::set_number(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.number) } -// optional string name = 4; +// string name = 4; inline void Field::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Field::set_name(const ::std::string& value) { @@ -1370,13 +1394,13 @@ inline void Field::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.name) } -// optional string type_url = 6; +// string type_url = 6; inline void Field::clear_type_url() { type_url_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return type_url_.Get(); } inline void Field::set_type_url(const ::std::string& value) { @@ -1436,7 +1460,7 @@ inline void Field::unsafe_arena_set_allocated_type_url( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.type_url) } -// optional int32 oneof_index = 7; +// int32 oneof_index = 7; inline void Field::clear_oneof_index() { oneof_index_ = 0; } @@ -1450,7 +1474,7 @@ inline void Field::set_oneof_index(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index) } -// optional bool packed = 8; +// bool packed = 8; inline void Field::clear_packed() { packed_ = false; } @@ -1494,13 +1518,13 @@ Field::options() const { return options_; } -// optional string json_name = 10; +// string json_name = 10; inline void Field::clear_json_name() { json_name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return json_name_.Get(); } inline void Field::set_json_name(const ::std::string& value) { @@ -1560,13 +1584,13 @@ inline void Field::unsafe_arena_set_allocated_json_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.json_name) } -// optional string default_value = 11; +// string default_value = 11; inline void Field::clear_default_value() { default_value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return default_value_.Get(); } inline void Field::set_default_value(const ::std::string& value) { @@ -1626,20 +1650,17 @@ inline void Field::unsafe_arena_set_allocated_default_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Field.default_value) } -inline const Field* Field::internal_default_instance() { - return &Field_default_instance_.get(); -} // ------------------------------------------------------------------- // Enum -// optional string name = 1; +// string name = 1; inline void Enum::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Enum::set_name(const ::std::string& value) { @@ -1759,7 +1780,7 @@ Enum::options() const { return options_; } -// optional .google.protobuf.SourceContext source_context = 4; +// .google.protobuf.SourceContext source_context = 4; inline bool Enum::has_source_context() const { return this != internal_default_instance() && source_context_ != NULL; } @@ -1810,7 +1831,7 @@ inline void Enum::set_allocated_source_context(::google::protobuf::SourceContex // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context) } -// optional .google.protobuf.Syntax syntax = 5; +// .google.protobuf.Syntax syntax = 5; inline void Enum::clear_syntax() { syntax_ = 0; } @@ -1824,20 +1845,17 @@ inline void Enum::set_syntax(::google::protobuf::Syntax value) { // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax) } -inline const Enum* Enum::internal_default_instance() { - return &Enum_default_instance_.get(); -} // ------------------------------------------------------------------- // EnumValue -// optional string name = 1; +// string name = 1; inline void EnumValue::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void EnumValue::set_name(const ::std::string& value) { @@ -1897,7 +1915,7 @@ inline void EnumValue::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.EnumValue.name) } -// optional int32 number = 2; +// int32 number = 2; inline void EnumValue::clear_number() { number_ = 0; } @@ -1941,20 +1959,17 @@ EnumValue::options() const { return options_; } -inline const EnumValue* EnumValue::internal_default_instance() { - return &EnumValue_default_instance_.get(); -} // ------------------------------------------------------------------- // Option -// optional string name = 1; +// string name = 1; inline void Option::clear_name() { name_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return name_.Get(); } inline void Option::set_name(const ::std::string& value) { @@ -2014,7 +2029,7 @@ inline void Option::unsafe_arena_set_allocated_name( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.name) } -// optional .google.protobuf.Any value = 2; +// .google.protobuf.Any value = 2; inline bool Option::has_value() const { return this != internal_default_instance() && value_ != NULL; } @@ -2065,9 +2080,6 @@ inline void Option::set_allocated_value(::google::protobuf::Any* value) { // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value) } -inline const Option* Option::internal_default_instance() { - return &Option_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -2080,6 +2092,7 @@ inline const Option* Option::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/type.proto b/src/google/protobuf/type.proto index 504cd25d..c1e696d6 100644 --- a/src/google/protobuf/type.proto +++ b/src/google/protobuf/type.proto @@ -41,6 +41,7 @@ option java_package = "com.google.protobuf"; option java_outer_classname = "TypeProto"; option java_multiple_files = true; option objc_class_prefix = "GPB"; +option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; // A protocol buffer message type. message Type { diff --git a/src/google/protobuf/unittest.proto b/src/google/protobuf/unittest.proto index cc2f4b34..96289cc5 100644 --- a/src/google/protobuf/unittest.proto +++ b/src/google/protobuf/unittest.proto @@ -886,3 +886,34 @@ message TestJsonName { optional int32 FIELD_NAME5 = 5; optional int32 field_name6 = 6 [json_name = "@type"]; } + +message TestHugeFieldNumbers { + optional int32 optional_int32 = 536870000; + optional int32 fixed_32 = 536870001; + repeated int32 repeated_int32 = 536870002 [packed = false]; + repeated int32 packed_int32 = 536870003 [packed = true]; + + optional ForeignEnum optional_enum = 536870004; + optional string optional_string = 536870005; + optional bytes optional_bytes = 536870006; + optional ForeignMessage optional_message = 536870007; + + optional group OptionalGroup = 536870008 { + optional int32 group_a = 536870009; + } + + map<string, string> string_string_map = 536870010; + + oneof oneof_field { + uint32 oneof_uint32 = 536870011; + TestAllTypes oneof_test_all_types = 536870012; + string oneof_string = 536870013; + bytes oneof_bytes = 536870014; + } + + extensions 536860000 to 536869999; +} + +extend TestHugeFieldNumbers { + optional TestAllTypes test_all_types = 536860000; +} diff --git a/src/google/protobuf/unittest_lite.proto b/src/google/protobuf/unittest_lite.proto index 878ec7c1..c39ac6b0 100644 --- a/src/google/protobuf/unittest_lite.proto +++ b/src/google/protobuf/unittest_lite.proto @@ -163,6 +163,9 @@ message TestAllTypesLite { bytes oneof_bytes = 114; NestedMessage oneof_lazy_nested_message = 115 [lazy = true]; } + + // Tests toString for non-repeated fields with a list suffix + optional int32 deceptively_named_list = 116; } message ForeignMessageLite { @@ -405,3 +408,34 @@ message V2MessageLite { required int32 int_field = 1; optional V2EnumLite enum_field = 2 [ default = V2_FIRST ]; } + +message TestHugeFieldNumbersLite { + optional int32 optional_int32 = 536870000; + optional int32 fixed_32 = 536870001; + repeated int32 repeated_int32 = 536870002 [packed = false]; + repeated int32 packed_int32 = 536870003 [packed = true]; + + optional ForeignEnumLite optional_enum = 536870004; + optional string optional_string = 536870005; + optional bytes optional_bytes = 536870006; + optional ForeignMessageLite optional_message = 536870007; + + optional group OptionalGroup = 536870008 { + optional int32 group_a = 536870009; + } + + map<string, string> string_string_map = 536870010; + + oneof oneof_field { + uint32 oneof_uint32 = 536870011; + TestAllTypesLite oneof_test_all_types = 536870012; + string oneof_string = 536870013; + bytes oneof_bytes = 536870014; + } + + extensions 536860000 to 536869999; +} + +extend TestHugeFieldNumbersLite { + optional TestAllTypesLite test_all_types_lite = 536860000; +} diff --git a/src/google/protobuf/unknown_field_set.cc b/src/google/protobuf/unknown_field_set.cc index bca3fbf8..9472c4fa 100644 --- a/src/google/protobuf/unknown_field_set.cc +++ b/src/google/protobuf/unknown_field_set.cc @@ -83,7 +83,7 @@ void UnknownFieldSet::ClearFallback() { void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) { int other_field_count = other.field_count(); if (other_field_count > 0) { - fields_ = new vector<UnknownField>(); + fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other.fields_)[i]); fields_->back().DeepCopy((*other.fields_)[i]); @@ -94,7 +94,7 @@ void UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) { void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) { int other_field_count = other.field_count(); if (other_field_count > 0) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other.fields_)[i]); fields_->back().DeepCopy((*other.fields_)[i]); @@ -107,7 +107,7 @@ void UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) { void UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) { int other_field_count = other->field_count(); if (other_field_count > 0) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); for (int i = 0; i < other_field_count; i++) { fields_->push_back((*other->fields_)[i]); (*other->fields_)[i].Reset(); @@ -155,7 +155,7 @@ void UnknownFieldSet::AddVarint(int number, uint64 value) { field.number_ = number; field.SetType(UnknownField::TYPE_VARINT); field.varint_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -164,7 +164,7 @@ void UnknownFieldSet::AddFixed32(int number, uint32 value) { field.number_ = number; field.SetType(UnknownField::TYPE_FIXED32); field.fixed32_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -173,7 +173,7 @@ void UnknownFieldSet::AddFixed64(int number, uint64 value) { field.number_ = number; field.SetType(UnknownField::TYPE_FIXED64); field.fixed64_ = value; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); } @@ -182,7 +182,7 @@ string* UnknownFieldSet::AddLengthDelimited(int number) { field.number_ = number; field.SetType(UnknownField::TYPE_LENGTH_DELIMITED); field.length_delimited_.string_value_ = new string; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); return field.length_delimited_.string_value_; } @@ -193,13 +193,13 @@ UnknownFieldSet* UnknownFieldSet::AddGroup(int number) { field.number_ = number; field.SetType(UnknownField::TYPE_GROUP); field.group_ = new UnknownFieldSet; - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); return field.group_; } void UnknownFieldSet::AddField(const UnknownField& field) { - if (fields_ == NULL) fields_ = new vector<UnknownField>(); + if (fields_ == NULL) fields_ = new std::vector<UnknownField>(); fields_->push_back(field); fields_->back().DeepCopy(field); } diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc index 5de72630..e55bb012 100644 --- a/src/google/protobuf/unknown_field_set_unittest.cc +++ b/src/google/protobuf/unknown_field_set_unittest.cc @@ -488,7 +488,7 @@ TEST_F(UnknownFieldSetTest, UnknownEnumValue) { TEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) { UnknownFieldSet empty; empty.AddVarint(1, 0); - EXPECT_EQ(sizeof(vector<UnknownField>) + sizeof(UnknownField), + EXPECT_EQ(sizeof(std::vector<UnknownField>) + sizeof(UnknownField), empty.SpaceUsedExcludingSelf()); } @@ -559,8 +559,9 @@ TEST_F(UnknownFieldSetTest, DeleteSubrange) { } } -void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number, - const vector<int>& expected_field_nubmers) { +void CheckDeleteByNumber(const std::vector<int>& field_numbers, + int deleted_number, + const std::vector<int>& expected_field_nubmers) { UnknownFieldSet unknown_fields; for (int i = 0; i < field_numbers.size(); ++i) { unknown_fields.AddFixed32(field_numbers[i], i); @@ -573,9 +574,9 @@ void CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number, } } -#define MAKE_VECTOR(x) vector<int>(x, x + GOOGLE_ARRAYSIZE(x)) +#define MAKE_VECTOR(x) std::vector<int>(x, x + GOOGLE_ARRAYSIZE(x)) TEST_F(UnknownFieldSetTest, DeleteByNumber) { - CheckDeleteByNumber(vector<int>(), 1, vector<int>()); + CheckDeleteByNumber(std::vector<int>(), 1, std::vector<int>()); static const int kTestFieldNumbers1[] = {1, 2, 3}; static const int kFieldNumberToDelete1 = 1; static const int kExpectedFieldNumbers1[] = {2, 3}; diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h index 3c70a314..ad560ebc 100644 --- a/src/google/protobuf/util/field_comparator.h +++ b/src/google/protobuf/util/field_comparator.h @@ -30,8 +30,6 @@ // Defines classes for field comparison. -// Author: ksroka@google.com (Krzysztof Sroka) - #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ diff --git a/src/google/protobuf/util/field_comparator_test.cc b/src/google/protobuf/util/field_comparator_test.cc index 6fd631d8..249b8d54 100644 --- a/src/google/protobuf/util/field_comparator_test.cc +++ b/src/google/protobuf/util/field_comparator_test.cc @@ -365,10 +365,10 @@ TEST_F(DefaultFieldComparatorTest, // +inf should be equal even though they are not technically within margin or // fraction. - message_1_.set_optional_float(numeric_limits<float>::infinity()); - message_2_.set_optional_float(numeric_limits<float>::infinity()); - message_1_.set_optional_double(numeric_limits<double>::infinity()); - message_2_.set_optional_double(numeric_limits<double>::infinity()); + message_1_.set_optional_float(std::numeric_limits<float>::infinity()); + message_2_.set_optional_float(std::numeric_limits<float>::infinity()); + message_1_.set_optional_double(std::numeric_limits<double>::infinity()); + message_2_.set_optional_double(std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); EXPECT_EQ(FieldComparator::SAME, @@ -380,10 +380,10 @@ TEST_F(DefaultFieldComparatorTest, // -inf should be equal even though they are not technically within margin or // fraction. - message_1_.set_optional_float(-numeric_limits<float>::infinity()); - message_2_.set_optional_float(-numeric_limits<float>::infinity()); - message_1_.set_optional_double(-numeric_limits<double>::infinity()); - message_2_.set_optional_double(-numeric_limits<double>::infinity()); + message_1_.set_optional_float(-std::numeric_limits<float>::infinity()); + message_2_.set_optional_float(-std::numeric_limits<float>::infinity()); + message_1_.set_optional_double(-std::numeric_limits<double>::infinity()); + message_2_.set_optional_double(-std::numeric_limits<double>::infinity()); comparator_.SetFractionAndMargin(field_float, 0.0, 0.0); comparator_.SetFractionAndMargin(field_double, 0.0, 0.0); EXPECT_EQ(FieldComparator::SAME, diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index 9dfcbd72..07550e6d 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -45,7 +45,7 @@ string FieldMaskUtil::ToString(const FieldMask& mask) { void FieldMaskUtil::FromString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; out->add_paths(paths[i]); @@ -116,7 +116,7 @@ bool FieldMaskUtil::ToJsonString(const FieldMask& mask, string* out) { bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { out->Clear(); - vector<string> paths = Split(str, ","); + std::vector<string> paths = Split(str, ","); for (int i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; string snakecase_path; @@ -128,9 +128,13 @@ bool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) { return true; } -bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, - StringPiece path) { - vector<string> parts = Split(path, "."); +bool FieldMaskUtil::GetFieldDescriptors( + const Descriptor* descriptor, StringPiece path, + std::vector<const FieldDescriptor*>* field_descriptors) { + if (field_descriptors != NULL) { + field_descriptors->clear(); + } + std::vector<string> parts = Split(path, "."); for (int i = 0; i < parts.size(); ++i) { const string& field_name = parts[i]; if (descriptor == NULL) { @@ -140,6 +144,9 @@ bool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor, if (field == NULL) { return false; } + if (field_descriptors != NULL) { + field_descriptors->push_back(field); + } if (!field->is_repeated() && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { descriptor = field->message_type(); @@ -216,14 +223,14 @@ class FieldMaskTree { ~Node() { ClearChildren(); } void ClearChildren() { - for (map<string, Node*>::iterator it = children.begin(); + for (std::map<string, Node*>::iterator it = children.begin(); it != children.end(); ++it) { delete it->second; } children.clear(); } - map<string, Node*> children; + std::map<string, Node*> children; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node); @@ -274,7 +281,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, out->add_paths(prefix); return; } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeToFieldMask(current_path, it->second, out); @@ -282,7 +289,7 @@ void FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node, } void FieldMaskTree::AddPath(const string& path) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -309,7 +316,7 @@ void FieldMaskTree::AddPath(const string& path) { } void FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) { - vector<string> parts = Split(path, "."); + std::vector<string> parts = Split(path, "."); if (parts.empty()) { return; } @@ -339,7 +346,7 @@ void FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node, if (node->children.empty()) { out->AddPath(prefix); } - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { string current_path = prefix.empty() ? it->first : prefix + "." + it->first; MergeLeafNodesToTree(current_path, it->second, out); @@ -353,7 +360,7 @@ void FieldMaskTree::MergeMessage(const Node* node, const Message& source, const Reflection* source_reflection = source.GetReflection(); const Reflection* destination_reflection = destination->GetReflection(); const Descriptor* descriptor = source.GetDescriptor(); - for (map<string, Node*>::const_iterator it = node->children.begin(); + for (std::map<string, Node*>::const_iterator it = node->children.begin(); it != node->children.end(); ++it) { const string& field_name = it->first; const Node* child = it->second; diff --git a/src/google/protobuf/util/field_mask_util.h b/src/google/protobuf/util/field_mask_util.h index 396c9aea..ab1f2e94 100644 --- a/src/google/protobuf/util/field_mask_util.h +++ b/src/google/protobuf/util/field_mask_util.h @@ -59,17 +59,26 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { static bool ToJsonString(const FieldMask& mask, string* out); static bool FromJsonString(StringPiece str, FieldMask* out); + // Get the descriptors of the fields which the given path from the message + // descriptor traverses, if field_descriptors is not null. + // Return false if the path is not valid, and the content of field_descriptors + // is unspecified. + static bool GetFieldDescriptors( + const Descriptor* descriptor, StringPiece path, + std::vector<const FieldDescriptor*>* field_descriptors); + // Checks whether the given path is valid for type T. template <typename T> static bool IsValidPath(StringPiece path) { - return InternalIsValidPath(T::descriptor(), path); + return GetFieldDescriptors(T::descriptor(), path, NULL); } // Checks whether the given FieldMask is valid for type T. template <typename T> static bool IsValidFieldMask(const FieldMask& mask) { for (int i = 0; i < mask.paths_size(); ++i) { - if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false; + if (!GetFieldDescriptors(T::descriptor(), mask.paths(i), NULL)) + return false; } return true; } @@ -149,9 +158,6 @@ class LIBPROTOBUF_EXPORT FieldMaskUtil { // successfully. static bool CamelCaseToSnakeCase(StringPiece input, string* output); - static bool InternalIsValidPath(const Descriptor* descriptor, - StringPiece path); - static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor, FieldMask* out); }; diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc index 43fb7905..f952786f 100644 --- a/src/google/protobuf/util/field_mask_util_test.cc +++ b/src/google/protobuf/util/field_mask_util_test.cc @@ -159,6 +159,27 @@ TEST(FieldMaskUtilTest, JsonStringFormat) { EXPECT_EQ("baz_quz", mask.paths(1)); } +TEST(FieldMaskUtilTest, GetFieldDescriptors) { + std::vector<const FieldDescriptor*> field_descriptors; + EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_int32", &field_descriptors)); + EXPECT_EQ(1, field_descriptors.size()); + EXPECT_EQ("optional_int32", field_descriptors[0]->name()); + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_nonexist", NULL)); + EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(TestAllTypes::descriptor(), + "optional_nested_message.bb", + &field_descriptors)); + EXPECT_EQ(2, field_descriptors.size()); + EXPECT_EQ("optional_nested_message", field_descriptors[0]->name()); + EXPECT_EQ("bb", field_descriptors[1]->name()); + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "optional_nested_message.nonexist", NULL)); + // FieldMask cannot be used to specify sub-fields of a repeated message. + EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors( + TestAllTypes::descriptor(), "repeated_nested_message.bb", NULL)); +} + TEST(FieldMaskUtilTest, TestIsVaildPath) { EXPECT_TRUE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_int32")); EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_nonexist")); diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index eeb55c6b..213c2c40 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -94,19 +94,24 @@ StatusOr<To> FloatingPointToIntConvertAndCheck(From before) { } // For conversion between double and float only. -template <typename To, typename From> -StatusOr<To> FloatingPointConvertAndCheck(From before) { - if (MathLimits<From>::IsNaN(before)) { - return std::numeric_limits<To>::quiet_NaN(); - } +StatusOr<double> FloatToDouble(float before) { + // Casting float to double should just work as double has more precision + // than float. + return static_cast<double>(before); +} - To after = static_cast<To>(before); - if (MathUtil::AlmostEquals<To>(after, before)) { - return after; +StatusOr<float> DoubleToFloat(double before) { + if (MathLimits<double>::IsNaN(before)) { + return std::numeric_limits<float>::quiet_NaN(); + } else if (!MathLimits<double>::IsFinite(before)) { + // Converting a double +inf/-inf to float should just work. + return static_cast<float>(before); + } else if (before > std::numeric_limits<float>::max() || + before < -std::numeric_limits<float>::max()) { + // Double value outside of the range of float. + return InvalidArgument(DoubleAsString(before)); } else { - return InvalidArgument(::google::protobuf::internal::is_same<From, double>::value - ? DoubleAsString(before) - : FloatAsString(before)); + return static_cast<float>(before); } } @@ -162,20 +167,27 @@ StatusOr<uint64> DataPiece::ToUint64() const { StatusOr<double> DataPiece::ToDouble() const { if (type_ == TYPE_FLOAT) { - return FloatingPointConvertAndCheck<double, float>(float_); + return FloatToDouble(float_); } if (type_ == TYPE_STRING) { if (str_ == "Infinity") return std::numeric_limits<double>::infinity(); if (str_ == "-Infinity") return -std::numeric_limits<double>::infinity(); if (str_ == "NaN") return std::numeric_limits<double>::quiet_NaN(); - return StringToNumber<double>(safe_strtod); + StatusOr<double> value = StringToNumber<double>(safe_strtod); + if (value.ok() && !MathLimits<double>::IsFinite(value.ValueOrDie())) { + // safe_strtod converts out-of-range values to +inf/-inf, but we want + // to report them as errors. + return InvalidArgument(StrCat("\"", str_, "\"")); + } else { + return value; + } } return GenericConvert<double>(); } StatusOr<float> DataPiece::ToFloat() const { if (type_ == TYPE_DOUBLE) { - return FloatingPointConvertAndCheck<float, double>(double_); + return DoubleToFloat(double_); } if (type_ == TYPE_STRING) { if (str_ == "Infinity") return std::numeric_limits<float>::infinity(); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index ac1ed9ab..1772219a 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -190,7 +190,7 @@ void DefaultValueObjectWriter::RegisterFieldScrubCallBack( DefaultValueObjectWriter::Node::Node( const string& name, const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, const vector<string>& path, + const DataPiece& data, bool is_placeholder, const std::vector<string>& path, bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback) : name_(name), type_(type), @@ -310,7 +310,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren( // This code is checking if the field to be added to the tree should be // scrubbed or not by calling the field_scrub_callback_ callback function. - vector<string> path; + std::vector<string> path; if (!path_.empty()) { path.insert(path.begin(), path_.begin(), path_.end()); } @@ -466,7 +466,7 @@ DataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField( DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( StringPiece name) { if (current_ == NULL) { - vector<string> path; + std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, OBJECT, DataPiece::NullData(), false, path, suppress_empty_list_, field_scrub_callback_.get())); @@ -514,7 +514,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::EndObject() { DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( StringPiece name) { if (current_ == NULL) { - vector<string> path; + std::vector<string> path; root_.reset(new Node(name.ToString(), &type_, LIST, DataPiece::NullData(), false, path, suppress_empty_list_, field_scrub_callback_.get())); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index 5f3b25f3..dc4551c9 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -139,8 +139,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { class LIBPROTOBUF_EXPORT Node { public: Node(const string& name, const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, const vector<string>& path, - bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback); + const DataPiece& data, bool is_placeholder, + const std::vector<string>& path, bool suppress_empty_list, + FieldScrubCallBack* field_scrub_callback); virtual ~Node() { for (int i = 0; i < children_.size(); ++i) { delete children_[i]; @@ -166,7 +167,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Accessors const string& name() const { return name_; } - const vector<string>& path() const { return path_; } + const std::vector<string>& path() const { return path_; } const google::protobuf::Type* type() const { return type_; } @@ -255,7 +256,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // google::protobuf::Type of the root message type. const google::protobuf::Type& type_; // Holds copies of strings passed to RenderString. - vector<string*> string_values_; + std::vector<string*> string_values_; // The current Node. Owned by its parents. Node* current_; diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index f0e8fc88..53b90fb0 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc @@ -112,7 +112,7 @@ string ConvertFieldMaskPath(const StringPiece path, util::Status DecodeCompactFieldMaskPaths(StringPiece paths, PathSinkCallback path_sink) { - stack<string> prefix; + std::stack<string> prefix; int length = paths.length(); int previous_position = 0; bool in_map_key = false; diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index a8d48eff..2af4ad90 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -45,6 +45,8 @@ #include <google/protobuf/util/internal/object_writer.h> #include <google/protobuf/util/internal/json_escaping.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> + namespace google { namespace protobuf { @@ -108,7 +110,8 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow) string_open_(0), chunk_storage_(), coerce_to_utf8_(false), - allow_empty_null_(false) { + allow_empty_null_(false), + loose_float_number_conversion_(false) { // Initialize the stack with a single value to be parsed. stack_.push(VALUE); } @@ -532,6 +535,10 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { if (!safe_strtod(number, &result->double_val)) { return ReportFailure("Unable to parse number."); } + if (!loose_float_number_conversion_ && + !MathLimits<double>::IsFinite(result->double_val)) { + return ReportFailure("Number exceeds the range of double."); + } result->type = NumberResult::DOUBLE; p_.remove_prefix(index); return util::Status::OK; diff --git a/src/google/protobuf/util/internal/json_stream_parser.h b/src/google/protobuf/util/internal/json_stream_parser.h index 78b35cc2..6b9d46ee 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.h +++ b/src/google/protobuf/util/internal/json_stream_parser.h @@ -255,6 +255,9 @@ class LIBPROTOBUF_EXPORT JsonStreamParser { // value. bool allow_empty_null_; + // Whether allows out-of-range floating point numbers or reject them. + bool loose_float_number_conversion_; + GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser); }; diff --git a/src/google/protobuf/util/internal/json_stream_parser_test.cc b/src/google/protobuf/util/internal/json_stream_parser_test.cc index eaa7e045..ca71ff24 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -89,7 +89,8 @@ class JsonStreamParserTest : public ::testing::Test { virtual ~JsonStreamParserTest() {} util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false, - bool allow_empty_null = false) { + bool allow_empty_null = false, + bool loose_float_number_conversion = false) { JsonStreamParser parser(&mock_); // Special case for split == length, test parsing one character at a time. @@ -120,9 +121,10 @@ class JsonStreamParserTest : public ::testing::Test { } void DoTest(StringPiece json, int split, bool coerce_utf8 = false, - bool allow_empty_null = false) { - util::Status result = - RunTest(json, split, coerce_utf8, allow_empty_null); + bool allow_empty_null = false, + bool loose_float_number_conversion = false) { + util::Status result = RunTest(json, split, coerce_utf8, allow_empty_null, + loose_float_number_conversion); if (!result.ok()) { GOOGLE_LOG(WARNING) << result; } @@ -142,7 +144,7 @@ class JsonStreamParserTest : public ::testing::Test { #ifndef _MSC_VER // TODO(xiaofeng): We have to disable InSequence check for MSVC because it // causes stack overflow due to its use of a linked list that is desctructed - // recursively. + // recursively. ::testing::InSequence in_sequence_; #endif // !_MSC_VER MockObjectWriter mock_; @@ -322,8 +324,7 @@ TEST_F(JsonStreamParserTest, ObjectKeyTypes) { // - array containing primitive values (true, false, null, num, string) TEST_F(JsonStreamParserTest, ArrayPrimitiveValues) { - StringPiece str = - "[true, false, null, 'one', \"two\"]"; + StringPiece str = "[true, false, null, 'one', \"two\"]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList("") ->RenderBool("", true) @@ -710,17 +711,19 @@ TEST_F(JsonStreamParserTest, NegativeNumberTooBig) { } } -/* -TODO(sven): Fail parsing when parsing a double that is too large. - TEST_F(JsonStreamParserTest, DoubleTooBig) { - StringPiece str = "[184464073709551232321616.45]"; + StringPiece str = "[1.89769e+308]"; for (int i = 0; i <= str.length(); ++i) { ow_.StartList(""); - DoErrorTest(str, i, "Unable to parse number"); + DoErrorTest(str, i, "Number exceeds the range of double."); + } + str = "[-1.89769e+308]"; + for (int i = 0; i <= str.length(); ++i) { + ow_.StartList(""); + DoErrorTest(str, i, "Number exceeds the range of double."); } } -*/ + // invalid bare backslash. TEST_F(JsonStreamParserTest, UnfinishedEscape) { diff --git a/src/google/protobuf/util/internal/proto_writer.cc b/src/google/protobuf/util/internal/proto_writer.cc index 4dcf4c3b..8bebf2ab 100644 --- a/src/google/protobuf/util/internal/proto_writer.cc +++ b/src/google/protobuf/util/internal/proto_writer.cc @@ -354,7 +354,7 @@ ProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() { if (!proto3_) { // Calls the registered error listener for any required field(s) not yet // seen. - for (set<const google::protobuf::Field*>::iterator it = + for (std::set<const google::protobuf::Field*>::iterator it = required_fields_.begin(); it != required_fields_.end(); ++it) { ow_->MissingField((*it)->name()); diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index df0dbe1b..a970dc12 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -85,7 +85,7 @@ const google::protobuf::EnumValue* FindEnumValueByNumber( const google::protobuf::Enum& tech_enum, int number); // Utility function to format nanos. -const string FormatNanos(uint32 nanos); +const string FormatNanos(uint32 nanos, bool with_trailing_zeros); StatusOr<string> MapKeyDefaultValueAsString( const google::protobuf::Field& field) { @@ -122,7 +122,8 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( use_lower_camel_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), - render_unknown_fields_(false) { + render_unknown_fields_(false), + add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -136,7 +137,8 @@ ProtoStreamObjectSource::ProtoStreamObjectSource( use_lower_camel_for_enums_(false), recursion_depth_(0), max_recursion_depth_(kDefaultMaxRecursionDepth), - render_unknown_fields_(false) { + render_unknown_fields_(false), + add_trailing_zeros_for_timestamp_and_duration_(false) { GOOGLE_LOG_IF(DFATAL, stream == NULL) << "Input stream is NULL."; } @@ -318,7 +320,7 @@ Status ProtoStreamObjectSource::RenderPacked( Status ProtoStreamObjectSource::RenderTimestamp( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - pair<int64, int32> p = os->ReadSecondsAndNanos(type); + std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); int64 seconds = p.first; int32 nanos = p.second; if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) { @@ -342,7 +344,7 @@ Status ProtoStreamObjectSource::RenderTimestamp( Status ProtoStreamObjectSource::RenderDuration( const ProtoStreamObjectSource* os, const google::protobuf::Type& type, StringPiece field_name, ObjectWriter* ow) { - pair<int64, int32> p = os->ReadSecondsAndNanos(type); + std::pair<int64, int32> p = os->ReadSecondsAndNanos(type); int64 seconds = p.first; int32 nanos = p.second; if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) { @@ -372,8 +374,10 @@ Status ProtoStreamObjectSource::RenderDuration( sign = "-"; nanos = -nanos; } - string formatted_duration = StringPrintf("%s%lld%ss", sign.c_str(), seconds, - FormatNanos(nanos).c_str()); + string formatted_duration = StringPrintf( + "%s%lld%ss", sign.c_str(), seconds, + FormatNanos(nanos, os->add_trailing_zeros_for_timestamp_and_duration_) + .c_str()); ow->RenderString(field_name, formatted_duration); return Status::OK; } @@ -1106,8 +1110,10 @@ const google::protobuf::EnumValue* FindEnumValueByNumber( // TODO(skarvaje): Look into optimizing this by not doing computation on // double. -const string FormatNanos(uint32 nanos) { - if (nanos == 0) return ""; +const string FormatNanos(uint32 nanos, bool with_trailing_zeros) { + if (nanos == 0) { + return with_trailing_zeros ? ".000" : ""; + } const char* format = (nanos % 1000 != 0) ? "%.9f" : (nanos % 1000000 != 0) ? "%.6f" : "%.3f"; diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h index adecfbd3..88ca652b 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.h +++ b/src/google/protobuf/util/internal/protostream_objectsource.h @@ -294,6 +294,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource { // Whether to render unknown fields. bool render_unknown_fields_; + // Whether to add trailing zeros for timestamp and duration. + bool add_trailing_zeros_for_timestamp_and_duration_; + GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectSource); }; diff --git a/src/google/protobuf/util/internal/protostream_objectsource_test.cc b/src/google/protobuf/util/internal/protostream_objectsource_test.cc index cac28a06..bf29c17a 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource_test.cc @@ -101,7 +101,8 @@ class ProtostreamObjectSourceTest : helper_(GetParam()), mock_(), ow_(&mock_), - use_lower_camel_for_enums_(false) { + use_lower_camel_for_enums_(false), + add_trailing_zeros_(false) { helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); } @@ -269,11 +270,14 @@ class ProtostreamObjectSourceTest void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; } + void AddTrailingZeros() { add_trailing_zeros_ = true; } + testing::TypeInfoTestHelper helper_; ::testing::NiceMock<MockObjectWriter> mock_; ExpectingObjectWriter ow_; bool use_lower_camel_for_enums_; + bool add_trailing_zeros_; }; INSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest, @@ -1023,6 +1027,7 @@ TEST_P(ProtostreamObjectSourceTimestampTest, TimestampDurationDefaultValue) { DoTest(out, TimestampDuration::descriptor()); } + } // namespace converter } // namespace util } // namespace protobuf diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index e7b38520..a9b15e68 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc @@ -113,13 +113,13 @@ class BaseProtoStreamObjectWriterTest listener_(), output_(new GrowingArrayByteSink(1000)), ow_() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } explicit BaseProtoStreamObjectWriterTest( - vector<const Descriptor*> descriptors) + std::vector<const Descriptor*> descriptors) : helper_(GetParam()), listener_(), output_(new GrowingArrayByteSink(1000)), @@ -127,7 +127,7 @@ class BaseProtoStreamObjectWriterTest ResetTypeInfo(descriptors); } - void ResetTypeInfo(vector<const Descriptor*> descriptors) { + void ResetTypeInfo(std::vector<const Descriptor*> descriptors) { GOOGLE_CHECK(!descriptors.empty()) << "Must have at least one descriptor!"; helper_.ResetTypeInfo(descriptors); ow_.reset(helper_.NewProtoWriter(GetTypeUrl(descriptors[0]), output_.get(), @@ -135,7 +135,7 @@ class BaseProtoStreamObjectWriterTest } void ResetTypeInfo(const Descriptor* descriptor) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } @@ -1078,7 +1078,7 @@ class ProtoStreamObjectWriterTimestampDurationTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterTimestampDurationTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(TimestampDuration::descriptor()); descriptors.push_back(google::protobuf::Timestamp::descriptor()); descriptors.push_back(google::protobuf::Duration::descriptor()); @@ -1473,7 +1473,7 @@ class ProtoStreamObjectWriterStructTest // Resets ProtoWriter with current set of options and other state. void ResetProtoWriter() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(StructType::descriptor()); descriptors.push_back(google::protobuf::Struct::descriptor()); ResetTypeInfo(descriptors); @@ -1664,7 +1664,7 @@ TEST_P(ProtoStreamObjectWriterMapTest, RepeatedMapKeyTest) { class ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterAnyTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(AnyOut::descriptor()); descriptors.push_back(Book::descriptor()); descriptors.push_back(google::protobuf::Any::descriptor()); @@ -2308,7 +2308,7 @@ class ProtoStreamObjectWriterFieldMaskTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterFieldMaskTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(FieldMaskTest::descriptor()); descriptors.push_back(google::protobuf::FieldMask::descriptor()); ResetTypeInfo(descriptors); @@ -2560,7 +2560,7 @@ class ProtoStreamObjectWriterWrappersTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterWrappersTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(Int32Wrapper::descriptor()); descriptors.push_back(google::protobuf::Int32Value::descriptor()); ResetTypeInfo(descriptors); @@ -2583,7 +2583,7 @@ class ProtoStreamObjectWriterOneOfsTest : public BaseProtoStreamObjectWriterTest { protected: ProtoStreamObjectWriterOneOfsTest() { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(OneOfsRequest::descriptor()); descriptors.push_back(google::protobuf::Struct::descriptor()); ResetTypeInfo(descriptors); diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc index 00a8ee7a..17d58475 100644 --- a/src/google/protobuf/util/internal/type_info.cc +++ b/src/google/protobuf/util/internal/type_info.cc @@ -60,7 +60,8 @@ class TypeInfoForTypeResolver : public TypeInfo { virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl( StringPiece type_url) const { - map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url); + std::map<StringPiece, StatusOrType>::iterator it = + cached_types_.find(type_url); if (it != cached_types_.end()) { return it->second; } @@ -85,7 +86,8 @@ class TypeInfoForTypeResolver : public TypeInfo { virtual const google::protobuf::Enum* GetEnumByTypeUrl( StringPiece type_url) const { - map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url); + std::map<StringPiece, StatusOrEnum>::iterator it = + cached_enums_.find(type_url); if (it != cached_enums_.end()) { return it->second.ok() ? it->second.ValueOrDie() : NULL; } @@ -123,8 +125,8 @@ class TypeInfoForTypeResolver : public TypeInfo { typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum; template <typename T> - static void DeleteCachedTypes(map<StringPiece, T>* cached_types) { - for (typename map<StringPiece, T>::iterator it = cached_types->begin(); + static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) { + for (typename std::map<StringPiece, T>::iterator it = cached_types->begin(); it != cached_types->end(); ++it) { if (it->second.ok()) { delete it->second.ValueOrDie(); @@ -151,13 +153,13 @@ class TypeInfoForTypeResolver : public TypeInfo { // Stores string values that will be referenced by StringPieces in // cached_types_, cached_enums_ and camel_case_name_table_. - mutable set<string> string_storage_; + mutable std::set<string> string_storage_; - mutable map<StringPiece, StatusOrType> cached_types_; - mutable map<StringPiece, StatusOrEnum> cached_enums_; + mutable std::map<StringPiece, StatusOrType> cached_types_; + mutable std::map<StringPiece, StatusOrEnum> cached_enums_; - mutable set<const google::protobuf::Type*> indexed_types_; - mutable map<StringPiece, StringPiece> camel_case_name_table_; + mutable std::set<const google::protobuf::Type*> indexed_types_; + mutable std::map<StringPiece, StringPiece> camel_case_name_table_; }; } // namespace diff --git a/src/google/protobuf/util/internal/type_info_test_helper.cc b/src/google/protobuf/util/internal/type_info_test_helper.cc index 49e18ed0..737ba9e4 100644 --- a/src/google/protobuf/util/internal/type_info_test_helper.cc +++ b/src/google/protobuf/util/internal/type_info_test_helper.cc @@ -55,7 +55,7 @@ namespace testing { void TypeInfoTestHelper::ResetTypeInfo( - const vector<const Descriptor*>& descriptors) { + const std::vector<const Descriptor*>& descriptors) { switch (type_) { case USE_TYPE_RESOLVER: { const DescriptorPool* pool = descriptors[0]->file()->pool(); @@ -73,14 +73,14 @@ void TypeInfoTestHelper::ResetTypeInfo( } void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor); ResetTypeInfo(descriptors); } void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1, const Descriptor* descriptor2) { - vector<const Descriptor*> descriptors; + std::vector<const Descriptor*> descriptors; descriptors.push_back(descriptor1); descriptors.push_back(descriptor2); ResetTypeInfo(descriptors); diff --git a/src/google/protobuf/util/internal/type_info_test_helper.h b/src/google/protobuf/util/internal/type_info_test_helper.h index 1a279849..1a196715 100644 --- a/src/google/protobuf/util/internal/type_info_test_helper.h +++ b/src/google/protobuf/util/internal/type_info_test_helper.h @@ -64,7 +64,7 @@ class TypeInfoTestHelper { explicit TypeInfoTestHelper(TypeInfoSource type) : type_(type) {} // Creates a TypeInfo object for the given set of descriptors. - void ResetTypeInfo(const vector<const Descriptor*>& descriptors); + void ResetTypeInfo(const std::vector<const Descriptor*>& descriptors); // Convinent overloads. void ResetTypeInfo(const Descriptor* descriptor); diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index 05328255..05759e85 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -30,6 +30,8 @@ #include <google/protobuf/util/internal/utility.h> +#include <algorithm> + #include <google/protobuf/stubs/callback.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/logging.h> @@ -41,8 +43,6 @@ #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/mathlimits.h> -#include <algorithm> - namespace google { namespace protobuf { namespace util { @@ -324,7 +324,7 @@ string ToSnakeCase(StringPiece input) { return result; } -set<string>* well_known_types_ = NULL; +std::set<string>* well_known_types_ = NULL; GOOGLE_PROTOBUF_DECLARE_ONCE(well_known_types_init_); const char* well_known_types_name_array_[] = { "google.protobuf.Timestamp", "google.protobuf.Duration", @@ -337,7 +337,7 @@ const char* well_known_types_name_array_[] = { void DeleteWellKnownTypes() { delete well_known_types_; } void InitWellKnownTypes() { - well_known_types_ = new set<string>; + well_known_types_ = new std::set<string>; for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) { well_known_types_->insert(well_known_types_name_array_[i]); } diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 24ff5fd6..3ce779c9 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -251,11 +251,11 @@ TEST_F(JsonUtilTest, TestDynamicMessage) { EXPECT_EQ(ToJson(generated, options), ToJson(*message, options)); } -typedef pair<char*, int> Segment; +typedef std::pair<char*, int> Segment; // A ZeroCopyOutputStream that writes to multiple buffers. class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { public: - explicit SegmentedZeroCopyOutputStream(list<Segment> segments) + explicit SegmentedZeroCopyOutputStream(std::list<Segment> segments) : segments_(segments), last_segment_(static_cast<char*>(NULL), 0), byte_count_(0) {} virtual bool Next(void** buffer, int* length) { @@ -281,7 +281,7 @@ class SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream { virtual int64 ByteCount() const { return byte_count_; } private: - list<Segment> segments_; + std::list<Segment> segments_; Segment last_segment_; int64 byte_count_; }; @@ -299,7 +299,7 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) { for (int split_pattern = 0; split_pattern < (1 << (kOutputBufferLength - 1)); split_pattern += kSkippedPatternCount) { // Split the buffer into small segments according to the split_pattern. - list<Segment> segments; + std::list<Segment> segments; int segment_start = 0; for (int i = 0; i < kOutputBufferLength - 1; ++i) { if (split_pattern & (1 << i)) { diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 328b40d8..203d8388 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -73,7 +73,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator public: MultipleFieldsMapKeyComparator( MessageDifferencer* message_differencer, - const vector<vector<const FieldDescriptor*> >& key_field_paths) + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) : message_differencer_(message_differencer), key_field_paths_(key_field_paths) { GOOGLE_CHECK(!key_field_paths_.empty()); @@ -85,14 +85,14 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator MessageDifferencer* message_differencer, const FieldDescriptor* key) : message_differencer_(message_differencer) { - vector<const FieldDescriptor*> key_field_path; + std::vector<const FieldDescriptor*> key_field_path; key_field_path.push_back(key); key_field_paths_.push_back(key_field_path); } virtual bool IsMatch( const Message& message1, const Message& message2, - const vector<SpecificField>& parent_fields) const { + const std::vector<SpecificField>& parent_fields) const { for (int i = 0; i < key_field_paths_.size(); ++i) { if (!IsMatchInternal(message1, message2, parent_fields, key_field_paths_[i], 0)) { @@ -105,11 +105,11 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator bool IsMatchInternal( const Message& message1, const Message& message2, - const vector<SpecificField>& parent_fields, - const vector<const FieldDescriptor*>& key_field_path, + const std::vector<SpecificField>& parent_fields, + const std::vector<const FieldDescriptor*>& key_field_path, int path_index) const { const FieldDescriptor* field = key_field_path[path_index]; - vector<SpecificField> current_parent_fields(parent_fields); + std::vector<SpecificField> current_parent_fields(parent_fields); if (path_index == key_field_path.size() - 1) { if (field->is_repeated()) { if (!message_differencer_->CompareRepeatedField( @@ -146,7 +146,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator } } MessageDifferencer* message_differencer_; - vector<vector<const FieldDescriptor*> > key_field_paths_; + std::vector<std::vector<const FieldDescriptor*> > key_field_paths_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator); }; @@ -283,10 +283,10 @@ void MessageDifferencer::TreatAsMap(const FieldDescriptor* field, void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey( const FieldDescriptor* field, - const vector<const FieldDescriptor*>& key_fields) { - vector<vector<const FieldDescriptor*> > key_field_paths; + const std::vector<const FieldDescriptor*>& key_fields) { + std::vector<std::vector<const FieldDescriptor*> > key_field_paths; for (int i = 0; i < key_fields.size(); ++i) { - vector<const FieldDescriptor*> key_field_path; + std::vector<const FieldDescriptor*> key_field_path; key_field_path.push_back(key_fields[i]); key_field_paths.push_back(key_field_path); } @@ -295,14 +295,15 @@ void MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey( void MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey( const FieldDescriptor* field, - const vector<vector<const FieldDescriptor*> >& key_field_paths) { + const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths) { 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(); for (int i = 0; i < key_field_paths.size(); ++i) { - const vector<const FieldDescriptor*>& key_field_path = key_field_paths[i]; + const std::vector<const FieldDescriptor*>& key_field_path = + key_field_paths[i]; for (int j = 0; j < key_field_path.size(); ++j) { const FieldDescriptor* parent_field = j == 0 ? field : key_field_path[j - 1]; @@ -390,7 +391,7 @@ bool MessageDifferencer::FieldBefore(const FieldDescriptor* field1, bool MessageDifferencer::Compare(const Message& message1, const Message& message2) { - vector<SpecificField> parent_fields; + std::vector<SpecificField> parent_fields; bool result = false; @@ -411,20 +412,20 @@ bool MessageDifferencer::Compare(const Message& message1, bool MessageDifferencer::CompareWithFields( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields_arg, - const vector<const FieldDescriptor*>& message2_fields_arg) { + const std::vector<const FieldDescriptor*>& message1_fields_arg, + const std::vector<const FieldDescriptor*>& message2_fields_arg) { if (message1.GetDescriptor() != message2.GetDescriptor()) { GOOGLE_LOG(DFATAL) << "Comparison between two messages with different " << "descriptors."; return false; } - vector<SpecificField> parent_fields; + std::vector<SpecificField> parent_fields; bool result = false; - vector<const FieldDescriptor*> message1_fields(message1_fields_arg); - vector<const FieldDescriptor*> message2_fields(message2_fields_arg); + std::vector<const FieldDescriptor*> message1_fields(message1_fields_arg); + std::vector<const FieldDescriptor*> message2_fields(message2_fields_arg); std::sort(message1_fields.begin(), message1_fields.end(), FieldBefore); std::sort(message2_fields.begin(), message2_fields.end(), FieldBefore); @@ -451,7 +452,7 @@ bool MessageDifferencer::CompareWithFields( bool MessageDifferencer::Compare( const Message& message1, const Message& message2, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { const Descriptor* descriptor1 = message1.GetDescriptor(); const Descriptor* descriptor2 = message2.GetDescriptor(); if (descriptor1 != descriptor2) { @@ -473,10 +474,10 @@ bool MessageDifferencer::Compare( const Reflection* reflection2 = message2.GetReflection(); // Retrieve all the set fields, including extensions. - vector<const FieldDescriptor*> message1_fields; + std::vector<const FieldDescriptor*> message1_fields; message1_fields.reserve(1 + message1.GetDescriptor()->field_count()); - vector<const FieldDescriptor*> message2_fields; + std::vector<const FieldDescriptor*> message2_fields; message2_fields.reserve(1 + message2.GetDescriptor()->field_count()); reflection1->ListFields(message1, &message1_fields); @@ -514,15 +515,15 @@ bool MessageDifferencer::Compare( bool MessageDifferencer::CompareRequestedFieldsUsingSettings( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields, - const vector<const FieldDescriptor*>& message2_fields, - vector<SpecificField>* parent_fields) { + const std::vector<const FieldDescriptor*>& message1_fields, + const std::vector<const FieldDescriptor*>& message2_fields, + std::vector<SpecificField>* parent_fields) { if (scope_ == FULL) { if (message_field_comparison_ == EQUIVALENT) { // We need to merge the field lists of both messages (i.e. // we are merely checking for a difference in field values, // rather than the addition or deletion of fields). - vector<const FieldDescriptor*> fields_union; + std::vector<const FieldDescriptor*> fields_union; CombineFields(message1_fields, FULL, message2_fields, FULL, &fields_union); return CompareWithFieldsInternal(message1, message2, fields_union, @@ -544,7 +545,7 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings( // but only the intersection for message2. This way, any fields // only present in message2 will be ignored, but any fields only // present in message1 will be marked as a difference. - vector<const FieldDescriptor*> fields_intersection; + std::vector<const FieldDescriptor*> fields_intersection; CombineFields(message1_fields, PARTIAL, message2_fields, PARTIAL, &fields_intersection); return CompareWithFieldsInternal(message1, message2, message1_fields, @@ -554,11 +555,11 @@ bool MessageDifferencer::CompareRequestedFieldsUsingSettings( } void MessageDifferencer::CombineFields( - const vector<const FieldDescriptor*>& fields1, + const std::vector<const FieldDescriptor*>& fields1, Scope fields1_scope, - const vector<const FieldDescriptor*>& fields2, + const std::vector<const FieldDescriptor*>& fields2, Scope fields2_scope, - vector<const FieldDescriptor*>* combined_fields) { + std::vector<const FieldDescriptor*>* combined_fields) { int index1 = 0; int index2 = 0; @@ -588,9 +589,9 @@ void MessageDifferencer::CombineFields( bool MessageDifferencer::CompareWithFieldsInternal( const Message& message1, const Message& message2, - const vector<const FieldDescriptor*>& message1_fields, - const vector<const FieldDescriptor*>& message2_fields, - vector<SpecificField>* parent_fields) { + const std::vector<const FieldDescriptor*>& message1_fields, + const std::vector<const FieldDescriptor*>& message2_fields, + std::vector<SpecificField>* parent_fields) { bool isDifferent = false; int field_index1 = 0; int field_index2 = 0; @@ -746,13 +747,12 @@ bool MessageDifferencer::CompareWithFieldsInternal( return !isDifferent; } -bool MessageDifferencer::IsMatch(const FieldDescriptor* repeated_field, - const MapKeyComparator* key_comparator, - const Message* message1, - const Message* message2, - const vector<SpecificField>& parent_fields, - int index1, int index2) { - vector<SpecificField> current_parent_fields(parent_fields); +bool MessageDifferencer::IsMatch( + const FieldDescriptor* repeated_field, + const MapKeyComparator* key_comparator, const Message* message1, + const Message* message2, const std::vector<SpecificField>& parent_fields, + int index1, int index2) { + std::vector<SpecificField> current_parent_fields(parent_fields); if (repeated_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) { return CompareFieldValueUsingParentFields( *message1, *message2, repeated_field, index1, index2, @@ -792,7 +792,7 @@ bool MessageDifferencer::CompareRepeatedField( const Message& message1, const Message& message2, const FieldDescriptor* repeated_field, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { // the input FieldDescriptor is guaranteed to be repeated field. const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); @@ -813,8 +813,8 @@ bool MessageDifferencer::CompareRepeatedField( // These two list are used for store the index of the correspondent // element in peer repeated field. - vector<int> match_list1; - vector<int> match_list2; + std::vector<int> match_list1; + std::vector<int> match_list2; // Try to match indices of the repeated fields. Return false if match fails // and there's no detailed report needed. @@ -899,7 +899,7 @@ bool MessageDifferencer::CompareFieldValue(const Message& message1, bool MessageDifferencer::CompareFieldValueUsingParentFields( const Message& message1, const Message& message2, const FieldDescriptor* field, int index1, int index2, - vector<SpecificField>* parent_fields) { + std::vector<SpecificField>* parent_fields) { FieldContext field_context(parent_fields); FieldComparator::ComparisonResult result = GetFieldComparisonResult( message1, message2, field, index1, index2, &field_context); @@ -938,7 +938,7 @@ bool MessageDifferencer::CompareFieldValueUsingParentFields( } bool MessageDifferencer::CheckPathChanged( - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { for (int i = 0; i < field_path.size(); ++i) { if (field_path[i].index != field_path[i].new_index) return true; } @@ -962,7 +962,7 @@ bool MessageDifferencer::IsIgnored( const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<SpecificField>& parent_fields) { + const std::vector<SpecificField>& parent_fields) { if (ignored_fields_.find(field) != ignored_fields_.end()) { return true; } @@ -977,7 +977,8 @@ bool MessageDifferencer::IsIgnored( bool MessageDifferencer::IsUnknownFieldIgnored( const Message& message1, const Message& message2, - const SpecificField& field, const vector<SpecificField>& parent_fields) { + const SpecificField& field, + const std::vector<SpecificField>& parent_fields) { for (int i = 0; i < ignore_criteria_.size(); ++i) { if (ignore_criteria_[i]->IsUnknownFieldIgnored(message1, message2, field, parent_fields)) { @@ -999,7 +1000,7 @@ const MessageDifferencer::MapKeyComparator* MessageDifferencer namespace { -typedef pair<int, const UnknownField*> IndexUnknownFieldPair; +typedef std::pair<int, const UnknownField*> IndexUnknownFieldPair; struct UnknownFieldOrdering { inline bool operator()(const IndexUnknownFieldPair& a, @@ -1050,7 +1051,7 @@ bool MessageDifferencer::CompareUnknownFields( const Message& message1, const Message& message2, const google::protobuf::UnknownFieldSet& unknown_field_set1, const google::protobuf::UnknownFieldSet& unknown_field_set2, - vector<SpecificField>* parent_field) { + std::vector<SpecificField>* parent_field) { // Ignore unknown fields in EQUIVALENT mode. if (message_field_comparison_ == EQUIVALENT) return true; @@ -1066,8 +1067,8 @@ bool MessageDifferencer::CompareUnknownFields( // two sets -- that is, differing values for the same tag. We use // IndexUnknownFieldPairs to keep track of the field's original index for // reporting purposes. - vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted - vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted + std::vector<IndexUnknownFieldPair> fields1; // unknown_field_set1, sorted + std::vector<IndexUnknownFieldPair> fields2; // unknown_field_set2, sorted fields1.reserve(unknown_field_set1.field_count()); fields2.reserve(unknown_field_set2.field_count()); @@ -1270,7 +1271,7 @@ class MaximumMatcher { // the x-th node on the right side is matched to y-th node on the left side. // match_list1[i] == -1 means the node is not matched. Same with match_list2. MaximumMatcher(int count1, int count2, NodeMatchCallback* callback, - vector<int>* match_list1, vector<int>* match_list2); + std::vector<int>* match_list1, std::vector<int>* match_list2); // Find a maximum match and return the number of matched node pairs. // If early_return is true, this method will return 0 immediately when it // finds that not all nodes on the left side can be matched. @@ -1282,21 +1283,21 @@ class MaximumMatcher { // Find an argumenting path starting from the node v on the left side. If a // path can be found, update match_list2_ to reflect the path and return // true. - bool FindArgumentPathDFS(int v, vector<bool>* visited); + bool FindArgumentPathDFS(int v, std::vector<bool>* visited); int count1_; int count2_; google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_; - map<pair<int, int>, bool> cached_match_results_; - vector<int>* match_list1_; - vector<int>* match_list2_; + std::map<std::pair<int, int>, bool> cached_match_results_; + std::vector<int>* match_list1_; + std::vector<int>* match_list2_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher); }; MaximumMatcher::MaximumMatcher(int count1, int count2, NodeMatchCallback* callback, - vector<int>* match_list1, - vector<int>* match_list2) + std::vector<int>* match_list1, + std::vector<int>* match_list2) : count1_(count1), count2_(count2), match_callback_(callback), match_list1_(match_list1), match_list2_(match_list2) { match_list1_->assign(count1, -1); @@ -1306,7 +1307,7 @@ MaximumMatcher::MaximumMatcher(int count1, int count2, int MaximumMatcher::FindMaximumMatch(bool early_return) { int result = 0; for (int i = 0; i < count1_; ++i) { - vector<bool> visited(count1_); + std::vector<bool> visited(count1_); if (FindArgumentPathDFS(i, &visited)) { ++result; } else if (early_return) { @@ -1324,8 +1325,9 @@ int MaximumMatcher::FindMaximumMatch(bool early_return) { } bool MaximumMatcher::Match(int left, int right) { - pair<int, int> p(left, right); - map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p); + std::pair<int, int> p(left, right); + std::map<std::pair<int, int>, bool>::iterator it = + cached_match_results_.find(p); if (it != cached_match_results_.end()) { return it->second; } @@ -1333,7 +1335,7 @@ bool MaximumMatcher::Match(int left, int right) { return cached_match_results_[p]; } -bool MaximumMatcher::FindArgumentPathDFS(int v, vector<bool>* visited) { +bool MaximumMatcher::FindArgumentPathDFS(int v, std::vector<bool>* visited) { (*visited)[v] = true; // We try to match those un-matched nodes on the right side first. This is // the step that the navie greedy matching algorithm uses. In the best cases @@ -1369,9 +1371,9 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( const Message& message1, const Message& message2, const FieldDescriptor* repeated_field, - const vector<SpecificField>& parent_fields, - vector<int>* match_list1, - vector<int>* match_list2) { + const std::vector<SpecificField>& parent_fields, + std::vector<int>* match_list1, + std::vector<int>* match_list2) { const int count1 = message1.GetReflection()->FieldSize(message1, repeated_field); const int count2 = @@ -1392,7 +1394,8 @@ bool MessageDifferencer::MatchRepeatedFieldIndices( // doesn't necessarily imply Compare(b, c). Therefore a naive greedy // algorithm will fail to find a maximum matching. // Here we use the argumenting path algorithm. - MaximumMatcher::NodeMatchCallback* callback = NewPermanentCallback( + MaximumMatcher::NodeMatchCallback* callback = + NewPermanentCallback( this, &MessageDifferencer::IsMatch, repeated_field, key_comparator, &message1, &message2, parent_fields); @@ -1485,7 +1488,7 @@ MessageDifferencer::StreamReporter::~StreamReporter() { } void MessageDifferencer::StreamReporter::PrintPath( - const vector<SpecificField>& field_path, bool left_side) { + const std::vector<SpecificField>& field_path, bool left_side) { for (int i = 0; i < field_path.size(); ++i) { if (i > 0) { printer_->Print("."); @@ -1514,7 +1517,7 @@ void MessageDifferencer::StreamReporter::PrintPath( void MessageDifferencer:: StreamReporter::PrintValue(const Message& message, - const vector<SpecificField>& field_path, + const std::vector<SpecificField>& field_path, bool left_side) { const SpecificField& specific_field = field_path.back(); const FieldDescriptor* field = specific_field.field; @@ -1587,7 +1590,7 @@ void MessageDifferencer::StreamReporter::Print(const string& str) { void MessageDifferencer::StreamReporter::ReportAdded( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("added: "); PrintPath(field_path, false); printer_->Print(": "); @@ -1598,7 +1601,7 @@ void MessageDifferencer::StreamReporter::ReportAdded( void MessageDifferencer::StreamReporter::ReportDeleted( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("deleted: "); PrintPath(field_path, true); printer_->Print(": "); @@ -1609,7 +1612,7 @@ void MessageDifferencer::StreamReporter::ReportDeleted( void MessageDifferencer::StreamReporter::ReportModified( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { if (!report_modified_aggregates_ && field_path.back().field == NULL) { if (field_path.back().unknown_field_type == UnknownField::TYPE_GROUP) { // Any changes to the subfields have already been printed. @@ -1639,7 +1642,7 @@ void MessageDifferencer::StreamReporter::ReportModified( void MessageDifferencer::StreamReporter::ReportMoved( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("moved: "); PrintPath(field_path, true); printer_->Print(" -> "); @@ -1652,7 +1655,7 @@ void MessageDifferencer::StreamReporter::ReportMoved( void MessageDifferencer::StreamReporter::ReportMatched( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("matched: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { @@ -1667,7 +1670,7 @@ void MessageDifferencer::StreamReporter::ReportMatched( void MessageDifferencer::StreamReporter::ReportIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { @@ -1679,7 +1682,7 @@ void MessageDifferencer::StreamReporter::ReportIgnored( void MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored( const Message& message1, const Message& message2, - const vector<SpecificField>& field_path) { + const std::vector<SpecificField>& field_path) { printer_->Print("ignored: "); PrintPath(field_path, true); if (CheckPathChanged(field_path)) { diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index fde37cf9..d99223cb 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -821,7 +821,6 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { FieldSet ignored_fields_; - bool compare_unknown_fields_; bool report_matches_; string* output_string_; diff --git a/src/google/protobuf/util/message_differencer_unittest.cc b/src/google/protobuf/util/message_differencer_unittest.cc index ed43c512..30b27dba 100755 --- a/src/google/protobuf/util/message_differencer_unittest.cc +++ b/src/google/protobuf/util/message_differencer_unittest.cc @@ -66,7 +66,7 @@ namespace { const FieldDescriptor* GetFieldDescriptor( const Message& message, const string& field_name) { - vector<string> field_path = + std::vector<string> field_path = Split(field_name, ".", true); const Descriptor* descriptor = message.GetDescriptor(); const FieldDescriptor* field = NULL; @@ -790,8 +790,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -805,8 +805,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsInequalityAllTest) { TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -820,7 +820,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEmptyListAlwaysSucceeds) { TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> empty_fields; + std::vector<const FieldDescriptor*> empty_fields; util::MessageDifferencer differencer; EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, @@ -835,7 +835,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { unittest::TestAllTypes msg1; TestUtil::SetAllFields(&msg1); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; msg1.GetReflection()->ListFields(msg1, &fields); util::MessageDifferencer differencer; @@ -843,7 +843,7 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { { // Compare with a subset of fields. - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; for (int i = 0; i < fields.size(); ++i) { if (i % 2 == 0) { compare_fields.push_back(fields[i]); @@ -856,8 +856,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) { // Specify a different set of fields to compare, even though we're using the // same message. This should fail, since we are explicitly saying that the // set of fields are different. - vector<const FieldDescriptor*> compare_fields1; - vector<const FieldDescriptor*> compare_fields2; + std::vector<const FieldDescriptor*> compare_fields1; + std::vector<const FieldDescriptor*> compare_fields2; for (int i = 0; i < fields.size(); ++i) { if (i % 2 == 0) { compare_fields1.push_back(fields[i]); @@ -880,8 +880,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllShuffledTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -899,10 +899,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsSubsetEqualityTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; msg1.GetReflection()->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the field descriptors with even indices. for (int i = 0; i < fields1.size(); ++i) { if (i % 2 == 0) { @@ -925,11 +925,11 @@ TEST(MessageDifferencerTest, TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; const Reflection* reflection = msg1.GetReflection(); reflection->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the field descriptors with even indices. for (int i = 0; i < fields1.size(); ++i) { if (i % 2 == 0) { @@ -954,10 +954,10 @@ TEST(MessageDifferencerTest, SpecifiedFieldsDetectsDifferencesTest) { TestUtil::SetAllFields(&msg2); TestUtil::ModifyRepeatedFields(&msg2); - vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields1; msg1.GetReflection()->ListFields(msg1, &fields1); - vector<const FieldDescriptor*> compare_fields; + std::vector<const FieldDescriptor*> compare_fields; // Only compare the repeated field descriptors. for (int i = 0; i < fields1.size(); ++i) { if (fields1[i]->is_repeated()) { @@ -977,8 +977,8 @@ TEST(MessageDifferencerTest, SpecifiedFieldsEquivalenceAllTest) { TestUtil::SetAllFields(&msg1); TestUtil::SetAllFields(&msg2); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; msg1.GetReflection()->ListFields(msg1, &fields1); msg2.GetReflection()->ListFields(msg2, &fields2); @@ -1011,8 +1011,8 @@ TEST(MessageDifferencerTest, // actually doing something. msg2.set_optional_uint64(23); - vector<const FieldDescriptor*> fields1; - vector<const FieldDescriptor*> fields2; + std::vector<const FieldDescriptor*> fields1; + std::vector<const FieldDescriptor*> fields2; fields1.push_back(optional_int32_desc); fields1.push_back(default_int64_desc); @@ -1286,7 +1286,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldsAsKey) { util::MessageDifferencer differencer; differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.ra")); EXPECT_FALSE(differencer.Compare(msg1, msg2)); - vector<const FieldDescriptor*> key_fields; + std::vector<const FieldDescriptor*> key_fields; key_fields.push_back(GetFieldDescriptor(msg1, "item.a")); key_fields.push_back(GetFieldDescriptor(msg1, "item.ra")); differencer.TreatAsMapWithMultipleFieldsAsKey( @@ -1363,11 +1363,11 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldPathsAsKey) { util::MessageDifferencer differencer; differencer.TreatAsSet(GetFieldDescriptor(msg1, "item.m.rc")); EXPECT_FALSE(differencer.Compare(msg1, msg2)); - vector<vector<const FieldDescriptor*> > key_field_paths; - vector<const FieldDescriptor*> key_field_path1; + std::vector<std::vector<const FieldDescriptor*> > key_field_paths; + std::vector<const FieldDescriptor*> key_field_path1; key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m")); key_field_path1.push_back(GetFieldDescriptor(msg1, "item.m.a")); - vector<const FieldDescriptor*> key_field_path2; + std::vector<const FieldDescriptor*> key_field_path2; key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m")); key_field_path2.push_back(GetFieldDescriptor(msg1, "item.m.rc")); key_field_paths.push_back(key_field_path1); @@ -1413,7 +1413,7 @@ TEST(MessageDifferencerTest, RepeatedFieldMapTest_IgnoredKeyFields) { item->set_b("world"); // Compare util::MessageDifferencer differencer; - vector<const FieldDescriptor*> key_fields; + std::vector<const FieldDescriptor*> key_fields; key_fields.push_back(GetFieldDescriptor(msg1, "item.a")); key_fields.push_back(GetFieldDescriptor(msg1, "item.ra")); differencer.TreatAsMapWithMultipleFieldsAsKey( @@ -1457,7 +1457,8 @@ class TestIgnorer : public util::MessageDifferencer::IgnoreCriteria { virtual bool IsIgnored( const Message& message1, const Message& message2, const FieldDescriptor* field, - const vector<util::MessageDifferencer::SpecificField>& parent_fields) { + const std::vector<util::MessageDifferencer::SpecificField>& + parent_fields) { string name = ""; for (int i = 0; i < parent_fields.size(); ++i) { name += parent_fields[i].field->name() + "."; @@ -1502,7 +1503,7 @@ class ValueProductMapKeyComparator typedef util::MessageDifferencer::SpecificField SpecificField; virtual bool IsMatch( const Message &message1, const Message &message2, - const vector<SpecificField>& parent_fields) const { + const std::vector<SpecificField>& parent_fields) const { const Reflection* reflection1 = message1.GetReflection(); const Reflection* reflection2 = message2.GetReflection(); // FieldDescriptor for item.ra @@ -1863,7 +1864,7 @@ TEST(MessageDifferencerTest, IgnoreField_TrumpsCompareWithFields) { const FieldDescriptor* c = GetFieldDescriptor(msg1, "c"); const FieldDescriptor* rc = GetFieldDescriptor(msg1, "rc"); - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; fields.push_back(c); fields.push_back(rc); @@ -1899,12 +1900,12 @@ class ParentSavingFieldComparator : public util::FieldComparator { } } - vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() { + std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() { return parent_fields_; } private: - vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_; + std::vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_; }; // Tests if MessageDifferencer sends the parent fields in the FieldContext diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index 96393903..febaa41f 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc @@ -54,17 +54,6 @@ using util::Status; using util::error::INVALID_ARGUMENT; using util::error::NOT_FOUND; -bool SplitTypeUrl(const string& type_url, string* url_prefix, - string* message_name) { - size_t pos = type_url.find_last_of("/"); - if (pos == string::npos) { - return false; - } - *url_prefix = type_url.substr(0, pos); - *message_name = type_url.substr(pos + 1); - return true; -} - class DescriptorPoolTypeResolver : public TypeResolver { public: DescriptorPoolTypeResolver(const string& url_prefix, @@ -72,38 +61,27 @@ class DescriptorPoolTypeResolver : public TypeResolver { : url_prefix_(url_prefix), pool_(pool) {} Status ResolveMessageType(const string& type_url, Type* type) { - string url_prefix, message_name; - if (!SplitTypeUrl(type_url, &url_prefix, &message_name) || - url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - StrCat("Invalid type URL, type URLs must be of the form '", - url_prefix_, "/<typename>', got: ", type_url)); + string type_name; + Status status = ParseTypeUrl(type_url, &type_name); + if (!status.ok()) { + return status; } - if (url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - "Cannot resolve types from URL: " + url_prefix); - } - const Descriptor* descriptor = pool_->FindMessageTypeByName(message_name); + + const Descriptor* descriptor = pool_->FindMessageTypeByName(type_name); if (descriptor == NULL) { - return Status(NOT_FOUND, - "Invalid type URL, unknown type: " + message_name); + return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name); } ConvertDescriptor(descriptor, type); return Status(); } Status ResolveEnumType(const string& type_url, Enum* enum_type) { - string url_prefix, type_name; - if (!SplitTypeUrl(type_url, &url_prefix, &type_name) || - url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - StrCat("Invalid type URL, type URLs must be of the form '", - url_prefix_, "/<typename>', got: ", type_url)); - } - if (url_prefix != url_prefix_) { - return Status(INVALID_ARGUMENT, - "Cannot resolve types from URL: " + url_prefix); + string type_name; + Status status = ParseTypeUrl(type_url, &type_name); + if (!status.ok()) { + return status; } + const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name); if (descriptor == NULL) { return Status(NOT_FOUND, "Invalid type URL, unknown type: " + type_name); @@ -203,6 +181,16 @@ class DescriptorPoolTypeResolver : public TypeResolver { return url_prefix_ + "/" + descriptor->full_name(); } + Status ParseTypeUrl(const string& type_url, string* type_name) { + if (type_url.substr(0, url_prefix_.size() + 1) != url_prefix_ + "/") { + return Status(INVALID_ARGUMENT, + StrCat("Invalid type URL, type URLs must be of the form '", + url_prefix_, "/<typename>', got: ", type_url)); + } + *type_name = type_url.substr(url_prefix_.size() + 1); + return Status(); + } + string DefaultValueAsString(const FieldDescriptor* descriptor) { switch (descriptor->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc index 147478be..88a1a234 100644 --- a/src/google/protobuf/wire_format.cc +++ b/src/google/protobuf/wire_format.cc @@ -792,7 +792,7 @@ void WireFormat::SerializeWithCachedSizes( const Reflection* message_reflection = message.GetReflection(); int expected_endpoint = output->ByteCount() + size; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; message_reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { SerializeFieldWithCachedSizes(fields[i], message, output); @@ -970,7 +970,7 @@ size_t WireFormat::ByteSize(const Message& message) { size_t our_size = 0; - vector<const FieldDescriptor*> fields; + std::vector<const FieldDescriptor*> fields; message_reflection->ListFields(message, &fields); for (int i = 0; i < fields.size(); i++) { our_size += FieldByteSize(fields[i], message); diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index 5bed7af4..5a8857ed 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -467,7 +467,7 @@ void WireFormatLite::WriteGroupMaybeToArray(int field_number, uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); if (target != NULL) { uint8* end = value.InternalSerializeWithCachedSizesToArray( - output->IsSerializationDeterminstic(), target); + output->IsSerializationDeterministic(), target); GOOGLE_DCHECK_EQ(end - target, size); } else { value.SerializeWithCachedSizes(output); @@ -484,7 +484,7 @@ void WireFormatLite::WriteMessageMaybeToArray(int field_number, uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); if (target != NULL) { uint8* end = value.InternalSerializeWithCachedSizesToArray( - output->IsSerializationDeterminstic(), target); + output->IsSerializationDeterministic(), target); GOOGLE_DCHECK_EQ(end - target, size); } else { value.SerializeWithCachedSizes(output); diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index eeb3650f..cfd1688c 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -243,7 +243,15 @@ class LIBPROTOBUF_EXPORT WireFormatLite { #define input io::CodedInputStream* input_arg #define output io::CodedOutputStream* output_arg #define field_number int field_number_arg +#ifdef NDEBUG #define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE +#else +// Avoid excessive inlining in non-optimized builds. Without other optimizations +// the inlining is not going to provide benefits anyway and the huge resulting +// functions, especially in the proto-generated serialization functions, produce +// stack frames so large that many tests run into stack overflows (b/32192897). +#define INL +#endif // Read fields, not including tags. The assumption is that you already // read the tag to determine what field to read. diff --git a/src/google/protobuf/wire_format_lite_inl.h b/src/google/protobuf/wire_format_lite_inl.h index 1963fac8..0e46e994 100644 --- a/src/google/protobuf/wire_format_lite_inl.h +++ b/src/google/protobuf/wire_format_lite_inl.h @@ -274,8 +274,9 @@ inline bool WireFormatLite::ReadRepeatedFixedSizePrimitive( // The number of bytes each type occupies on the wire. const int per_value_size = tag_size + sizeof(value); + // parentheses around (std::min) prevents macro expansion of min(...) int elements_available = - std::min(values->Capacity() - values->size(), size / per_value_size); + (std::min)(values->Capacity() - values->size(), size / per_value_size); int num_read = 0; while (num_read < elements_available && (buffer = io::CodedInputStream::ExpectTagFromArray( @@ -366,8 +367,9 @@ inline bool WireFormatLite::ReadPackedFixedSizePrimitive( if (bytes_limit == -1) { bytes_limit = input->BytesUntilLimit(); } else { + // parentheses around (std::min) prevents macro expansion of min(...) bytes_limit = - std::min(bytes_limit, static_cast<int64>(input->BytesUntilLimit())); + (std::min)(bytes_limit, static_cast<int64>(input->BytesUntilLimit())); } if (bytes_limit >= new_bytes) { // Fast-path that pre-allocates *values to the final size. @@ -862,7 +864,12 @@ inline size_t WireFormatLite::MessageSizeNoVirtual( } inline size_t WireFormatLite::LengthDelimitedSize(size_t length) { - return io::CodedOutputStream::VarintSize32(length) + length; + // The static_cast here prevents an error in certain compiler configurations + // but is not technically correct--if length is too large to fit in a uint32 + // then it will be silently truncated. We will need to fix this if we ever + // decide to start supporting serialized messages greater than 2 GiB in size. + return length + io::CodedOutputStream::VarintSize32( + static_cast<uint32>(length)); } } // namespace internal diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc index 4e4add66..faf27b62 100644 --- a/src/google/protobuf/wire_format_unittest.cc +++ b/src/google/protobuf/wire_format_unittest.cc @@ -1138,7 +1138,7 @@ class Utf8ValidationTest : public ::testing::Test { TEST_F(Utf8ValidationTest, WriteInvalidUTF8String) { string wire_buffer; protobuf_unittest::OneString input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); @@ -1162,7 +1162,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) { protobuf_unittest::OneString input; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); protobuf_unittest::OneString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1185,7 +1185,7 @@ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) { TEST_F(Utf8ValidationTest, WriteValidUTF8String) { string wire_buffer; protobuf_unittest::OneString input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kValidUTF8String, &input, &wire_buffer); @@ -1199,7 +1199,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { protobuf_unittest::OneString input; WriteMessage(kValidUTF8String, &input, &wire_buffer); protobuf_unittest::OneString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1213,7 +1213,7 @@ TEST_F(Utf8ValidationTest, ReadValidUTF8String) { TEST_F(Utf8ValidationTest, WriteArbitraryBytes) { string wire_buffer; protobuf_unittest::OneBytes input; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); @@ -1227,7 +1227,7 @@ TEST_F(Utf8ValidationTest, ReadArbitraryBytes) { protobuf_unittest::OneBytes input; WriteMessage(kInvalidUTF8String, &input, &wire_buffer); protobuf_unittest::OneBytes output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1245,7 +1245,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { string wire_buffer = input.SerializeAsString(); protobuf_unittest::MoreString output; - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; ReadMessage(wire_buffer, &output); @@ -1264,7 +1264,7 @@ TEST_F(Utf8ValidationTest, ParseRepeatedString) { TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { string data(kInvalidUTF8String); - vector<string> errors; + std::vector<string> errors; { ScopedMemoryLog log; WireFormat::VerifyUTF8String(data.data(), data.size(), diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 35364066..82a8d9e2 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -19,276 +19,189 @@ namespace google { namespace protobuf { +class DoubleValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> {}; +DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; +class FloatValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> {}; +FloatValueDefaultTypeInternal _FloatValue_default_instance_; +class Int64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> {}; +Int64ValueDefaultTypeInternal _Int64Value_default_instance_; +class UInt64ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> {}; +UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +class Int32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> {}; +Int32ValueDefaultTypeInternal _Int32Value_default_instance_; +class UInt32ValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> {}; +UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; +class BoolValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> {}; +BoolValueDefaultTypeInternal _BoolValue_default_instance_; +class StringValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<StringValue> {}; +StringValueDefaultTypeInternal _StringValue_default_instance_; +class BytesValueDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> {}; +BytesValueDefaultTypeInternal _BytesValue_default_instance_; namespace { -const ::google::protobuf::Descriptor* DoubleValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - DoubleValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* FloatValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - FloatValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* Int64Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Int64Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* UInt64Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UInt64Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* Int32Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Int32Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* UInt32Value_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - UInt32Value_reflection_ = NULL; -const ::google::protobuf::Descriptor* BoolValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - BoolValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* StringValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - StringValue_reflection_ = NULL; -const ::google::protobuf::Descriptor* BytesValue_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - BytesValue_reflection_ = NULL; +::google::protobuf::Metadata file_level_metadata[9]; } // namespace -void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD; -void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "google/protobuf/wrappers.proto"); - GOOGLE_CHECK(file != NULL); - DoubleValue_descriptor_ = file->message_type(0); - static const int DoubleValue_offsets_[1] = { +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD; +const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto() { + static const ::google::protobuf::uint32 offsets[] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_), - }; - DoubleValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - DoubleValue_descriptor_, - DoubleValue::internal_default_instance(), - DoubleValue_offsets_, - -1, - -1, - -1, - sizeof(DoubleValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_)); - FloatValue_descriptor_ = file->message_type(1); - static const int FloatValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_), - }; - FloatValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - FloatValue_descriptor_, - FloatValue::internal_default_instance(), - FloatValue_offsets_, - -1, - -1, - -1, - sizeof(FloatValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_)); - Int64Value_descriptor_ = file->message_type(2); - static const int Int64Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_), - }; - Int64Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Int64Value_descriptor_, - Int64Value::internal_default_instance(), - Int64Value_offsets_, - -1, - -1, - -1, - sizeof(Int64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_)); - UInt64Value_descriptor_ = file->message_type(3); - static const int UInt64Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_), - }; - UInt64Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UInt64Value_descriptor_, - UInt64Value::internal_default_instance(), - UInt64Value_offsets_, - -1, - -1, - -1, - sizeof(UInt64Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_)); - Int32Value_descriptor_ = file->message_type(4); - static const int Int32Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_), - }; - Int32Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - Int32Value_descriptor_, - Int32Value::internal_default_instance(), - Int32Value_offsets_, - -1, - -1, - -1, - sizeof(Int32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_)); - UInt32Value_descriptor_ = file->message_type(5); - static const int UInt32Value_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_), - }; - UInt32Value_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - UInt32Value_descriptor_, - UInt32Value::internal_default_instance(), - UInt32Value_offsets_, - -1, - -1, - -1, - sizeof(UInt32Value), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_)); - BoolValue_descriptor_ = file->message_type(6); - static const int BoolValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_), - }; - BoolValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - BoolValue_descriptor_, - BoolValue::internal_default_instance(), - BoolValue_offsets_, - -1, - -1, - -1, - sizeof(BoolValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_)); - StringValue_descriptor_ = file->message_type(7); - static const int StringValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_), - }; - StringValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - StringValue_descriptor_, - StringValue::internal_default_instance(), - StringValue_offsets_, - -1, - -1, - -1, - sizeof(StringValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_)); - BytesValue_descriptor_ = file->message_type(8); - static const int BytesValue_offsets_[1] = { + ~0u, // no _has_bits_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_), }; - BytesValue_reflection_ = - ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection( - BytesValue_descriptor_, - BytesValue::internal_default_instance(), - BytesValue_offsets_, - -1, - -1, - -1, - sizeof(BytesValue), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_)); -} + return offsets; +} + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, -1, sizeof(DoubleValue)}, + { 5, -1, sizeof(FloatValue)}, + { 10, -1, sizeof(Int64Value)}, + { 15, -1, sizeof(UInt64Value)}, + { 20, -1, sizeof(Int32Value)}, + { 25, -1, sizeof(UInt32Value)}, + { 30, -1, sizeof(BoolValue)}, + { 35, -1, sizeof(StringValue)}, + { 40, -1, sizeof(BytesValue)}, +}; + +static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { + {reinterpret_cast<const ::google::protobuf::Message*>(&_DoubleValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_FloatValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Int64Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UInt64Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_Int32Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_UInt32Value_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_BoolValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_StringValue_default_instance_), NULL}, + {reinterpret_cast<const ::google::protobuf::Message*>(&_BytesValue_default_instance_), NULL}, +}; namespace { -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +void protobuf_AssignDescriptors() { + protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "google/protobuf/wrappers.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(), factory, + file_level_metadata, NULL, NULL); +} + void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - DoubleValue_descriptor_, DoubleValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - FloatValue_descriptor_, FloatValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int64Value_descriptor_, Int64Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt64Value_descriptor_, UInt64Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Int32Value_descriptor_, Int32Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - UInt32Value_descriptor_, UInt32Value::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BoolValue_descriptor_, BoolValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - StringValue_descriptor_, StringValue::internal_default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - BytesValue_descriptor_, BytesValue::internal_default_instance()); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 9); } } // namespace void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto() { - DoubleValue_default_instance_.Shutdown(); - delete DoubleValue_reflection_; - FloatValue_default_instance_.Shutdown(); - delete FloatValue_reflection_; - Int64Value_default_instance_.Shutdown(); - delete Int64Value_reflection_; - UInt64Value_default_instance_.Shutdown(); - delete UInt64Value_reflection_; - Int32Value_default_instance_.Shutdown(); - delete Int32Value_reflection_; - UInt32Value_default_instance_.Shutdown(); - delete UInt32Value_reflection_; - BoolValue_default_instance_.Shutdown(); - delete BoolValue_reflection_; - StringValue_default_instance_.Shutdown(); - delete StringValue_reflection_; - BytesValue_default_instance_.Shutdown(); - delete BytesValue_reflection_; + _DoubleValue_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _FloatValue_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; + _Int64Value_default_instance_.Shutdown(); + delete file_level_metadata[2].reflection; + _UInt64Value_default_instance_.Shutdown(); + delete file_level_metadata[3].reflection; + _Int32Value_default_instance_.Shutdown(); + delete file_level_metadata[4].reflection; + _UInt32Value_default_instance_.Shutdown(); + delete file_level_metadata[5].reflection; + _BoolValue_default_instance_.Shutdown(); + delete file_level_metadata[6].reflection; + _StringValue_default_instance_.Shutdown(); + delete file_level_metadata[7].reflection; + _BytesValue_default_instance_.Shutdown(); + delete file_level_metadata[8].reflection; } void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - DoubleValue_default_instance_.DefaultConstruct(); - FloatValue_default_instance_.DefaultConstruct(); - Int64Value_default_instance_.DefaultConstruct(); - UInt64Value_default_instance_.DefaultConstruct(); - Int32Value_default_instance_.DefaultConstruct(); - UInt32Value_default_instance_.DefaultConstruct(); - BoolValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - StringValue_default_instance_.DefaultConstruct(); - ::google::protobuf::internal::GetEmptyString(); - BytesValue_default_instance_.DefaultConstruct(); - DoubleValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - FloatValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - Int64Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - UInt64Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - Int32Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - UInt32Value_default_instance_.get_mutable()->InitAsDefaultInstance(); - BoolValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - StringValue_default_instance_.get_mutable()->InitAsDefaultInstance(); - BytesValue_default_instance_.get_mutable()->InitAsDefaultInstance(); -} - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_); + ::google::protobuf::internal::InitProtobufDefaults(); + _DoubleValue_default_instance_.DefaultConstruct(); + _FloatValue_default_instance_.DefaultConstruct(); + _Int64Value_default_instance_.DefaultConstruct(); + _UInt64Value_default_instance_.DefaultConstruct(); + _Int32Value_default_instance_.DefaultConstruct(); + _UInt32Value_default_instance_.DefaultConstruct(); + _BoolValue_default_instance_.DefaultConstruct(); + _StringValue_default_instance_.DefaultConstruct(); + _BytesValue_default_instance_.DefaultConstruct(); +} + void protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_once_, - &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl); + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl); } void protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl() { - GOOGLE_PROTOBUF_VERIFY_VERSION; - protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + static const char descriptor[] = { + "\n\036google/protobuf/wrappers.proto\022\017google" + ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" + "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val" + "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu" + "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013" + "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022" + "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001" + " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com" + ".google.protobufB\rWrappersProtoP\001Z*githu" + "b.com/golang/protobuf/ptypes/wrappers\370\001\001" + "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" + "\006proto3" + }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\036google/protobuf/wrappers.proto\022\017google" - ".protobuf\"\034\n\013DoubleValue\022\r\n\005value\030\001 \001(\001\"" - "\033\n\nFloatValue\022\r\n\005value\030\001 \001(\002\"\033\n\nInt64Val" - "ue\022\r\n\005value\030\001 \001(\003\"\034\n\013UInt64Value\022\r\n\005valu" - "e\030\001 \001(\004\"\033\n\nInt32Value\022\r\n\005value\030\001 \001(\005\"\034\n\013" - "UInt32Value\022\r\n\005value\030\001 \001(\r\"\032\n\tBoolValue\022" - "\r\n\005value\030\001 \001(\010\"\034\n\013StringValue\022\r\n\005value\030\001" - " \001(\t\"\033\n\nBytesValue\022\r\n\005value\030\001 \001(\014B|\n\023com" - ".google.protobufB\rWrappersProtoP\001Z*githu" - "b.com/golang/protobuf/ptypes/wrappers\370\001\001" - "\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypesb" - "\006proto3", 447); + descriptor, 447); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/wrappers.proto", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto); @@ -306,16 +219,6 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto { } } static_descriptor_initializer_google_2fprotobuf_2fwrappers_2eproto_; -namespace { - -static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN; -static void MergeFromFail(int line) { - ::google::protobuf::internal::MergeFromFail(__FILE__, line); -} - -} // namespace - - // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 @@ -324,7 +227,9 @@ const int DoubleValue::kValueFieldNumber; DoubleValue::DoubleValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue) } @@ -338,15 +243,12 @@ DoubleValue::DoubleValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue) } - -void DoubleValue::InitAsDefaultInstance() { -} - DoubleValue::DoubleValue(const DoubleValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue) } @@ -381,7 +283,7 @@ void DoubleValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* DoubleValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return DoubleValue_descriptor_; + return file_level_metadata[0].descriptor; } const DoubleValue& DoubleValue::default_instance() { @@ -389,8 +291,6 @@ const DoubleValue& DoubleValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_; - DoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena); } @@ -406,13 +306,13 @@ bool DoubleValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional double value = 1; + // double value = 1; case 1: { - if (tag == 9) { + if (tag == 9u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( @@ -420,7 +320,6 @@ bool DoubleValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -448,7 +347,7 @@ failure: void DoubleValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.DoubleValue) - // optional double value = 1; + // double value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output); } @@ -460,7 +359,7 @@ void DoubleValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue) - // optional double value = 1; + // double value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target); } @@ -473,7 +372,7 @@ size_t DoubleValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue) size_t total_size = 0; - // optional double value = 1; + // double value = 1; if (this->value() != 0) { total_size += 1 + 8; } @@ -487,7 +386,7 @@ size_t DoubleValue::ByteSizeLong() const { void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const DoubleValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>( &from); @@ -496,21 +395,14 @@ void DoubleValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DoubleValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void DoubleValue::MergeFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void DoubleValue::UnsafeMergeFrom(const DoubleValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -527,11 +419,10 @@ void DoubleValue::CopyFrom(const DoubleValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool DoubleValue::IsInitialized() const { - return true; } @@ -540,10 +431,13 @@ void DoubleValue::Swap(DoubleValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - DoubleValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + DoubleValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { @@ -553,22 +447,18 @@ void DoubleValue::UnsafeArenaSwap(DoubleValue* other) { } void DoubleValue::InternalSwap(DoubleValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata DoubleValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = DoubleValue_descriptor_; - metadata.reflection = DoubleValue_reflection_; - return metadata; + return file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // DoubleValue -// optional double value = 1; +// double value = 1; void DoubleValue::clear_value() { value_ = 0; } @@ -582,9 +472,6 @@ void DoubleValue::set_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) } -inline const DoubleValue* DoubleValue::internal_default_instance() { - return &DoubleValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -595,7 +482,9 @@ const int FloatValue::kValueFieldNumber; FloatValue::FloatValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.FloatValue) } @@ -609,15 +498,12 @@ FloatValue::FloatValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue) } - -void FloatValue::InitAsDefaultInstance() { -} - FloatValue::FloatValue(const FloatValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue) } @@ -652,7 +538,7 @@ void FloatValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* FloatValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return FloatValue_descriptor_; + return file_level_metadata[1].descriptor; } const FloatValue& FloatValue::default_instance() { @@ -660,8 +546,6 @@ const FloatValue& FloatValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_; - FloatValue* FloatValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena); } @@ -677,13 +561,13 @@ bool FloatValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.FloatValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional float value = 1; + // float value = 1; case 1: { - if (tag == 13) { + if (tag == 13u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>( @@ -691,7 +575,6 @@ bool FloatValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -719,7 +602,7 @@ failure: void FloatValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.FloatValue) - // optional float value = 1; + // float value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output); } @@ -731,7 +614,7 @@ void FloatValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue) - // optional float value = 1; + // float value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target); } @@ -744,7 +627,7 @@ size_t FloatValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue) size_t total_size = 0; - // optional float value = 1; + // float value = 1; if (this->value() != 0) { total_size += 1 + 4; } @@ -758,7 +641,7 @@ size_t FloatValue::ByteSizeLong() const { void FloatValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const FloatValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>( &from); @@ -767,21 +650,14 @@ void FloatValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FloatValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void FloatValue::MergeFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void FloatValue::UnsafeMergeFrom(const FloatValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -798,11 +674,10 @@ void FloatValue::CopyFrom(const FloatValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool FloatValue::IsInitialized() const { - return true; } @@ -811,10 +686,13 @@ void FloatValue::Swap(FloatValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - FloatValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + FloatValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void FloatValue::UnsafeArenaSwap(FloatValue* other) { @@ -824,22 +702,18 @@ void FloatValue::UnsafeArenaSwap(FloatValue* other) { } void FloatValue::InternalSwap(FloatValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata FloatValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = FloatValue_descriptor_; - metadata.reflection = FloatValue_reflection_; - return metadata; + return file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // FloatValue -// optional float value = 1; +// float value = 1; void FloatValue::clear_value() { value_ = 0; } @@ -853,9 +727,6 @@ void FloatValue::set_value(float value) { // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) } -inline const FloatValue* FloatValue::internal_default_instance() { - return &FloatValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -866,7 +737,9 @@ const int Int64Value::kValueFieldNumber; Int64Value::Int64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int64Value) } @@ -880,15 +753,12 @@ Int64Value::Int64Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value) } - -void Int64Value::InitAsDefaultInstance() { -} - Int64Value::Int64Value(const Int64Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value) } @@ -923,7 +793,7 @@ void Int64Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Int64Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Int64Value_descriptor_; + return file_level_metadata[2].descriptor; } const Int64Value& Int64Value::default_instance() { @@ -931,8 +801,6 @@ const Int64Value& Int64Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_; - Int64Value* Int64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena); } @@ -948,13 +816,13 @@ bool Int64Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Int64Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int64 value = 1; + // int64 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( @@ -962,7 +830,6 @@ bool Int64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -990,7 +857,7 @@ failure: void Int64Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Int64Value) - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output); } @@ -1002,7 +869,7 @@ void Int64Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value) - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target); } @@ -1015,7 +882,7 @@ size_t Int64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value) size_t total_size = 0; - // optional int64 value = 1; + // int64 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int64Size( @@ -1031,7 +898,7 @@ size_t Int64Value::ByteSizeLong() const { void Int64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Int64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>( &from); @@ -1040,21 +907,14 @@ void Int64Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int64Value) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Int64Value::MergeFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Int64Value::UnsafeMergeFrom(const Int64Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1071,11 +931,10 @@ void Int64Value::CopyFrom(const Int64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Int64Value::IsInitialized() const { - return true; } @@ -1084,10 +943,13 @@ void Int64Value::Swap(Int64Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Int64Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Int64Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Int64Value::UnsafeArenaSwap(Int64Value* other) { @@ -1097,22 +959,18 @@ void Int64Value::UnsafeArenaSwap(Int64Value* other) { } void Int64Value::InternalSwap(Int64Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int64Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Int64Value_descriptor_; - metadata.reflection = Int64Value_reflection_; - return metadata; + return file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Int64Value -// optional int64 value = 1; +// int64 value = 1; void Int64Value::clear_value() { value_ = GOOGLE_LONGLONG(0); } @@ -1126,9 +984,6 @@ void Int64Value::set_value(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) } -inline const Int64Value* Int64Value::internal_default_instance() { - return &Int64Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1139,7 +994,9 @@ const int UInt64Value::kValueFieldNumber; UInt64Value::UInt64Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value) } @@ -1153,15 +1010,12 @@ UInt64Value::UInt64Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value) } - -void UInt64Value::InitAsDefaultInstance() { -} - UInt64Value::UInt64Value(const UInt64Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value) } @@ -1196,7 +1050,7 @@ void UInt64Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UInt64Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return UInt64Value_descriptor_; + return file_level_metadata[3].descriptor; } const UInt64Value& UInt64Value::default_instance() { @@ -1204,8 +1058,6 @@ const UInt64Value& UInt64Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_; - UInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena); } @@ -1221,13 +1073,13 @@ bool UInt64Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional uint64 value = 1; + // uint64 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( @@ -1235,7 +1087,6 @@ bool UInt64Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1263,7 +1114,7 @@ failure: void UInt64Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.UInt64Value) - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output); } @@ -1275,7 +1126,7 @@ void UInt64Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value) - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target); } @@ -1288,7 +1139,7 @@ size_t UInt64Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value) size_t total_size = 0; - // optional uint64 value = 1; + // uint64 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( @@ -1304,7 +1155,7 @@ size_t UInt64Value::ByteSizeLong() const { void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UInt64Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>( &from); @@ -1313,21 +1164,14 @@ void UInt64Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt64Value) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UInt64Value::MergeFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UInt64Value::UnsafeMergeFrom(const UInt64Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1344,11 +1188,10 @@ void UInt64Value::CopyFrom(const UInt64Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UInt64Value::IsInitialized() const { - return true; } @@ -1357,10 +1200,13 @@ void UInt64Value::Swap(UInt64Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - UInt64Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + UInt64Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { @@ -1370,22 +1216,18 @@ void UInt64Value::UnsafeArenaSwap(UInt64Value* other) { } void UInt64Value::InternalSwap(UInt64Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt64Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UInt64Value_descriptor_; - metadata.reflection = UInt64Value_reflection_; - return metadata; + return file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // UInt64Value -// optional uint64 value = 1; +// uint64 value = 1; void UInt64Value::clear_value() { value_ = GOOGLE_ULONGLONG(0); } @@ -1399,9 +1241,6 @@ void UInt64Value::set_value(::google::protobuf::uint64 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) } -inline const UInt64Value* UInt64Value::internal_default_instance() { - return &UInt64Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1412,7 +1251,9 @@ const int Int32Value::kValueFieldNumber; Int32Value::Int32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.Int32Value) } @@ -1426,15 +1267,12 @@ Int32Value::Int32Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value) } - -void Int32Value::InitAsDefaultInstance() { -} - Int32Value::Int32Value(const Int32Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value) } @@ -1469,7 +1307,7 @@ void Int32Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* Int32Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return Int32Value_descriptor_; + return file_level_metadata[4].descriptor; } const Int32Value& Int32Value::default_instance() { @@ -1477,8 +1315,6 @@ const Int32Value& Int32Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_; - Int32Value* Int32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena); } @@ -1494,13 +1330,13 @@ bool Int32Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.Int32Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional int32 value = 1; + // int32 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -1508,7 +1344,6 @@ bool Int32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1536,7 +1371,7 @@ failure: void Int32Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.Int32Value) - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output); } @@ -1548,7 +1383,7 @@ void Int32Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value) - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target); } @@ -1561,7 +1396,7 @@ size_t Int32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value) size_t total_size = 0; - // optional int32 value = 1; + // int32 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( @@ -1577,7 +1412,7 @@ size_t Int32Value::ByteSizeLong() const { void Int32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const Int32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>( &from); @@ -1586,21 +1421,14 @@ void Int32Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int32Value) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void Int32Value::MergeFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void Int32Value::UnsafeMergeFrom(const Int32Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1617,11 +1445,10 @@ void Int32Value::CopyFrom(const Int32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool Int32Value::IsInitialized() const { - return true; } @@ -1630,10 +1457,13 @@ void Int32Value::Swap(Int32Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - Int32Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + Int32Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void Int32Value::UnsafeArenaSwap(Int32Value* other) { @@ -1643,22 +1473,18 @@ void Int32Value::UnsafeArenaSwap(Int32Value* other) { } void Int32Value::InternalSwap(Int32Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata Int32Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Int32Value_descriptor_; - metadata.reflection = Int32Value_reflection_; - return metadata; + return file_level_metadata[4]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // Int32Value -// optional int32 value = 1; +// int32 value = 1; void Int32Value::clear_value() { value_ = 0; } @@ -1672,9 +1498,6 @@ void Int32Value::set_value(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) } -inline const Int32Value* Int32Value::internal_default_instance() { - return &Int32Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1685,7 +1508,9 @@ const int UInt32Value::kValueFieldNumber; UInt32Value::UInt32Value() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value) } @@ -1699,15 +1524,12 @@ UInt32Value::UInt32Value(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value) } - -void UInt32Value::InitAsDefaultInstance() { -} - UInt32Value::UInt32Value(const UInt32Value& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value) } @@ -1742,7 +1564,7 @@ void UInt32Value::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* UInt32Value::descriptor() { protobuf_AssignDescriptorsOnce(); - return UInt32Value_descriptor_; + return file_level_metadata[5].descriptor; } const UInt32Value& UInt32Value::default_instance() { @@ -1750,8 +1572,6 @@ const UInt32Value& UInt32Value::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_; - UInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena); } @@ -1767,13 +1587,13 @@ bool UInt32Value::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional uint32 value = 1; + // uint32 value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -1781,7 +1601,6 @@ bool UInt32Value::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -1809,7 +1628,7 @@ failure: void UInt32Value::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.UInt32Value) - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output); } @@ -1821,7 +1640,7 @@ void UInt32Value::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value) - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target); } @@ -1834,7 +1653,7 @@ size_t UInt32Value::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value) size_t total_size = 0; - // optional uint32 value = 1; + // uint32 value = 1; if (this->value() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( @@ -1850,7 +1669,7 @@ size_t UInt32Value::ByteSizeLong() const { void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const UInt32Value* source = ::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>( &from); @@ -1859,21 +1678,14 @@ void UInt32Value::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt32Value) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void UInt32Value::MergeFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void UInt32Value::UnsafeMergeFrom(const UInt32Value& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -1890,11 +1702,10 @@ void UInt32Value::CopyFrom(const UInt32Value& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool UInt32Value::IsInitialized() const { - return true; } @@ -1903,10 +1714,13 @@ void UInt32Value::Swap(UInt32Value* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - UInt32Value temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + UInt32Value* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { @@ -1916,22 +1730,18 @@ void UInt32Value::UnsafeArenaSwap(UInt32Value* other) { } void UInt32Value::InternalSwap(UInt32Value* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata UInt32Value::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = UInt32Value_descriptor_; - metadata.reflection = UInt32Value_reflection_; - return metadata; + return file_level_metadata[5]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // UInt32Value -// optional uint32 value = 1; +// uint32 value = 1; void UInt32Value::clear_value() { value_ = 0u; } @@ -1945,9 +1755,6 @@ void UInt32Value::set_value(::google::protobuf::uint32 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) } -inline const UInt32Value* UInt32Value::internal_default_instance() { - return &UInt32Value_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -1958,7 +1765,9 @@ const int BoolValue::kValueFieldNumber; BoolValue::BoolValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BoolValue) } @@ -1972,15 +1781,12 @@ BoolValue::BoolValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue) } - -void BoolValue::InitAsDefaultInstance() { -} - BoolValue::BoolValue(const BoolValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_ = from.value_; // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue) } @@ -2015,7 +1821,7 @@ void BoolValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* BoolValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return BoolValue_descriptor_; + return file_level_metadata[6].descriptor; } const BoolValue& BoolValue::default_instance() { @@ -2023,8 +1829,6 @@ const BoolValue& BoolValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_; - BoolValue* BoolValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena); } @@ -2040,13 +1844,13 @@ bool BoolValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.BoolValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bool value = 1; + // bool value = 1; case 1: { - if (tag == 8) { + if (tag == 8u) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( @@ -2054,7 +1858,6 @@ bool BoolValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2082,7 +1885,7 @@ failure: void BoolValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.BoolValue) - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output); } @@ -2094,7 +1897,7 @@ void BoolValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue) - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target); } @@ -2107,7 +1910,7 @@ size_t BoolValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue) size_t total_size = 0; - // optional bool value = 1; + // bool value = 1; if (this->value() != 0) { total_size += 1 + 1; } @@ -2121,7 +1924,7 @@ size_t BoolValue::ByteSizeLong() const { void BoolValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const BoolValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>( &from); @@ -2130,21 +1933,14 @@ void BoolValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BoolValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void BoolValue::MergeFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void BoolValue::UnsafeMergeFrom(const BoolValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value() != 0) { set_value(from.value()); } @@ -2161,11 +1957,10 @@ void BoolValue::CopyFrom(const BoolValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool BoolValue::IsInitialized() const { - return true; } @@ -2174,10 +1969,13 @@ void BoolValue::Swap(BoolValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - BoolValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + BoolValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void BoolValue::UnsafeArenaSwap(BoolValue* other) { @@ -2187,22 +1985,18 @@ void BoolValue::UnsafeArenaSwap(BoolValue* other) { } void BoolValue::InternalSwap(BoolValue* other) { std::swap(value_, other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BoolValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = BoolValue_descriptor_; - metadata.reflection = BoolValue_reflection_; - return metadata; + return file_level_metadata[6]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // BoolValue -// optional bool value = 1; +// bool value = 1; void BoolValue::clear_value() { value_ = false; } @@ -2216,9 +2010,6 @@ void BoolValue::set_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) } -inline const BoolValue* BoolValue::internal_default_instance() { - return &BoolValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2229,7 +2020,9 @@ const int StringValue::kValueFieldNumber; StringValue::StringValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.StringValue) } @@ -2243,15 +2036,16 @@ StringValue::StringValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue) } - -void StringValue::InitAsDefaultInstance() { -} - StringValue::StringValue(const StringValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(), + GetArenaNoVirtual()); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) } @@ -2287,7 +2081,7 @@ void StringValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* StringValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return StringValue_descriptor_; + return file_level_metadata[7].descriptor; } const StringValue& StringValue::default_instance() { @@ -2295,8 +2089,6 @@ const StringValue& StringValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_; - StringValue* StringValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<StringValue>(arena); } @@ -2312,13 +2104,13 @@ bool StringValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.StringValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional string value = 1; + // string value = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_value())); DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String( @@ -2328,7 +2120,6 @@ bool StringValue::MergePartialFromCodedStream( } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2356,7 +2147,7 @@ failure: void StringValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.StringValue) - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), this->value().length(), @@ -2373,7 +2164,7 @@ void StringValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue) - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::VerifyUtf8String( this->value().data(), this->value().length(), @@ -2392,7 +2183,7 @@ size_t StringValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue) size_t total_size = 0; - // optional string value = 1; + // string value = 1; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( @@ -2408,7 +2199,7 @@ size_t StringValue::ByteSizeLong() const { void StringValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const StringValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const StringValue>( &from); @@ -2417,21 +2208,14 @@ void StringValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.StringValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void StringValue::MergeFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void StringValue::UnsafeMergeFrom(const StringValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value().size() > 0) { set_value(from.value()); } @@ -2448,11 +2232,10 @@ void StringValue::CopyFrom(const StringValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool StringValue::IsInitialized() const { - return true; } @@ -2461,10 +2244,13 @@ void StringValue::Swap(StringValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - StringValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + StringValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void StringValue::UnsafeArenaSwap(StringValue* other) { @@ -2474,28 +2260,24 @@ void StringValue::UnsafeArenaSwap(StringValue* other) { } void StringValue::InternalSwap(StringValue* other) { value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata StringValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = StringValue_descriptor_; - metadata.reflection = StringValue_reflection_; - return metadata; + return file_level_metadata[7]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // StringValue -// optional string value = 1; +// string value = 1; void StringValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } void StringValue::set_value(const ::std::string& value) { @@ -2555,9 +2337,6 @@ void StringValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) } -inline const StringValue* StringValue::internal_default_instance() { - return &StringValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // =================================================================== @@ -2568,7 +2347,9 @@ const int BytesValue::kValueFieldNumber; BytesValue::BytesValue() : ::google::protobuf::Message(), _internal_metadata_(NULL) { - if (this != internal_default_instance()) protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); + } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.BytesValue) } @@ -2582,15 +2363,16 @@ BytesValue::BytesValue(::google::protobuf::Arena* arena) RegisterArenaDtor(arena); // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue) } - -void BytesValue::InitAsDefaultInstance() { -} - BytesValue::BytesValue(const BytesValue& from) : ::google::protobuf::Message(), - _internal_metadata_(NULL) { - SharedCtor(); - UnsafeMergeFrom(from); + _internal_metadata_(NULL), + _cached_size_(0) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + if (from.value().size() > 0) { + value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value(), + GetArenaNoVirtual()); + } // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) } @@ -2626,7 +2408,7 @@ void BytesValue::SetCachedSize(int size) const { } const ::google::protobuf::Descriptor* BytesValue::descriptor() { protobuf_AssignDescriptorsOnce(); - return BytesValue_descriptor_; + return file_level_metadata[8].descriptor; } const BytesValue& BytesValue::default_instance() { @@ -2634,8 +2416,6 @@ const BytesValue& BytesValue::default_instance() { return *internal_default_instance(); } -::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_; - BytesValue* BytesValue::New(::google::protobuf::Arena* arena) const { return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena); } @@ -2651,19 +2431,18 @@ bool BytesValue::MergePartialFromCodedStream( ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.protobuf.BytesValue) for (;;) { - ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127); + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // optional bytes value = 1; + // bytes value = 1; case 1: { - if (tag == 10) { + if (tag == 10u) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->mutable_value())); } else { goto handle_unusual; } - if (input->ExpectAtEnd()) goto success; break; } @@ -2691,7 +2470,7 @@ failure: void BytesValue::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.protobuf.BytesValue) - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased( 1, this->value(), output); @@ -2704,7 +2483,7 @@ void BytesValue::SerializeWithCachedSizes( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue) - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { target = ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( @@ -2719,7 +2498,7 @@ size_t BytesValue::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue) size_t total_size = 0; - // optional bytes value = 1; + // bytes value = 1; if (this->value().size() > 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize( @@ -2735,7 +2514,7 @@ size_t BytesValue::ByteSizeLong() const { void BytesValue::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__); + GOOGLE_DCHECK_NE(&from, this); const BytesValue* source = ::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>( &from); @@ -2744,21 +2523,14 @@ void BytesValue::MergeFrom(const ::google::protobuf::Message& from) { ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BytesValue) - UnsafeMergeFrom(*source); + MergeFrom(*source); } } void BytesValue::MergeFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue) - if (GOOGLE_PREDICT_TRUE(&from != this)) { - UnsafeMergeFrom(from); - } else { - MergeFromFail(__LINE__); - } -} - -void BytesValue::UnsafeMergeFrom(const BytesValue& from) { - GOOGLE_DCHECK(&from != this); + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); if (from.value().size() > 0) { set_value(from.value()); } @@ -2775,11 +2547,10 @@ void BytesValue::CopyFrom(const BytesValue& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue) if (&from == this) return; Clear(); - UnsafeMergeFrom(from); + MergeFrom(from); } bool BytesValue::IsInitialized() const { - return true; } @@ -2788,10 +2559,13 @@ void BytesValue::Swap(BytesValue* other) { if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) { InternalSwap(other); } else { - BytesValue temp; - temp.UnsafeMergeFrom(*this); - CopyFrom(*other); - other->CopyFrom(temp); + BytesValue* temp = New(GetArenaNoVirtual()); + temp->MergeFrom(*other); + other->CopyFrom(*this); + InternalSwap(temp); + if (GetArenaNoVirtual() == NULL) { + delete temp; + } } } void BytesValue::UnsafeArenaSwap(BytesValue* other) { @@ -2801,28 +2575,24 @@ void BytesValue::UnsafeArenaSwap(BytesValue* other) { } void BytesValue::InternalSwap(BytesValue* other) { value_.Swap(&other->value_); - _internal_metadata_.Swap(&other->_internal_metadata_); std::swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata BytesValue::GetMetadata() const { protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = BytesValue_descriptor_; - metadata.reflection = BytesValue_reflection_; - return metadata; + return file_level_metadata[8]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // BytesValue -// optional bytes value = 1; +// bytes value = 1; void BytesValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } const ::std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } void BytesValue::set_value(const ::std::string& value) { @@ -2882,9 +2652,6 @@ void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) } -inline const BytesValue* BytesValue::internal_default_instance() { - return &BytesValue_default_instance_.get(); -} #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 568f8669..0197b6c5 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -24,29 +24,48 @@ #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> -#include <google/protobuf/repeated_field.h> -#include <google/protobuf/extension_set.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) - namespace google { namespace protobuf { - -// Internal implementation detail -- do not call these. -void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); -void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); -void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); -void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - class BoolValue; +class BoolValueDefaultTypeInternal; +extern BoolValueDefaultTypeInternal _BoolValue_default_instance_; class BytesValue; +class BytesValueDefaultTypeInternal; +extern BytesValueDefaultTypeInternal _BytesValue_default_instance_; class DoubleValue; +class DoubleValueDefaultTypeInternal; +extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; class FloatValue; +class FloatValueDefaultTypeInternal; +extern FloatValueDefaultTypeInternal _FloatValue_default_instance_; class Int32Value; +class Int32ValueDefaultTypeInternal; +extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_; class Int64Value; +class Int64ValueDefaultTypeInternal; +extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_; class StringValue; +class StringValueDefaultTypeInternal; +extern StringValueDefaultTypeInternal _StringValue_default_instance_; class UInt32Value; +class UInt32ValueDefaultTypeInternal; +extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; class UInt64Value; +class UInt64ValueDefaultTypeInternal; +extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; +} // namespace protobuf +} // namespace google + +namespace google { +namespace protobuf { + +// Internal implementation detail -- do not call these. +void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto(); +void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto(); // =================================================================== @@ -62,47 +81,52 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const DoubleValue& default_instance(); - static const DoubleValue* internal_default_instance(); + static inline const DoubleValue* internal_default_instance() { + return reinterpret_cast<const DoubleValue*>( + &_DoubleValue_default_instance_); + } void UnsafeArenaSwap(DoubleValue* other); void Swap(DoubleValue* other); // implements Message ---------------------------------------------- - inline DoubleValue* New() const { return New(NULL); } + inline DoubleValue* New() const PROTOBUF_FINAL { return New(NULL); } - DoubleValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + DoubleValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const DoubleValue& from); void MergeFrom(const DoubleValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(DoubleValue* other); - void UnsafeMergeFrom(const DoubleValue& from); protected: explicit DoubleValue(::google::protobuf::Arena* arena); private: @@ -117,13 +141,13 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional double value = 1; + // double value = 1; void clear_value(); static const int kValueFieldNumber = 1; double value() const; @@ -140,13 +164,10 @@ class LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@p mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<DoubleValue> DoubleValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ { @@ -161,47 +182,52 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const FloatValue& default_instance(); - static const FloatValue* internal_default_instance(); + static inline const FloatValue* internal_default_instance() { + return reinterpret_cast<const FloatValue*>( + &_FloatValue_default_instance_); + } void UnsafeArenaSwap(FloatValue* other); void Swap(FloatValue* other); // implements Message ---------------------------------------------- - inline FloatValue* New() const { return New(NULL); } + inline FloatValue* New() const PROTOBUF_FINAL { return New(NULL); } - FloatValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + FloatValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const FloatValue& from); void MergeFrom(const FloatValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(FloatValue* other); - void UnsafeMergeFrom(const FloatValue& from); protected: explicit FloatValue(::google::protobuf::Arena* arena); private: @@ -216,13 +242,13 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional float value = 1; + // float value = 1; void clear_value(); static const int kValueFieldNumber = 1; float value() const; @@ -239,13 +265,10 @@ class LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<FloatValue> FloatValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ { @@ -260,47 +283,52 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Int64Value& default_instance(); - static const Int64Value* internal_default_instance(); + static inline const Int64Value* internal_default_instance() { + return reinterpret_cast<const Int64Value*>( + &_Int64Value_default_instance_); + } void UnsafeArenaSwap(Int64Value* other); void Swap(Int64Value* other); // implements Message ---------------------------------------------- - inline Int64Value* New() const { return New(NULL); } + inline Int64Value* New() const PROTOBUF_FINAL { return New(NULL); } - Int64Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Int64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int64Value& from); void MergeFrom(const Int64Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Int64Value* other); - void UnsafeMergeFrom(const Int64Value& from); protected: explicit Int64Value(::google::protobuf::Arena* arena); private: @@ -315,13 +343,13 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int64 value = 1; + // int64 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::int64 value() const; @@ -338,13 +366,10 @@ class LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Int64Value> Int64Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ { @@ -359,47 +384,52 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UInt64Value& default_instance(); - static const UInt64Value* internal_default_instance(); + static inline const UInt64Value* internal_default_instance() { + return reinterpret_cast<const UInt64Value*>( + &_UInt64Value_default_instance_); + } void UnsafeArenaSwap(UInt64Value* other); void Swap(UInt64Value* other); // implements Message ---------------------------------------------- - inline UInt64Value* New() const { return New(NULL); } + inline UInt64Value* New() const PROTOBUF_FINAL { return New(NULL); } - UInt64Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UInt64Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt64Value& from); void MergeFrom(const UInt64Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UInt64Value* other); - void UnsafeMergeFrom(const UInt64Value& from); protected: explicit UInt64Value(::google::protobuf::Arena* arena); private: @@ -414,13 +444,13 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional uint64 value = 1; + // uint64 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::uint64 value() const; @@ -437,13 +467,10 @@ class LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@p mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UInt64Value> UInt64Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ { @@ -458,47 +485,52 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const Int32Value& default_instance(); - static const Int32Value* internal_default_instance(); + static inline const Int32Value* internal_default_instance() { + return reinterpret_cast<const Int32Value*>( + &_Int32Value_default_instance_); + } void UnsafeArenaSwap(Int32Value* other); void Swap(Int32Value* other); // implements Message ---------------------------------------------- - inline Int32Value* New() const { return New(NULL); } + inline Int32Value* New() const PROTOBUF_FINAL { return New(NULL); } - Int32Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + Int32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const Int32Value& from); void MergeFrom(const Int32Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(Int32Value* other); - void UnsafeMergeFrom(const Int32Value& from); protected: explicit Int32Value(::google::protobuf::Arena* arena); private: @@ -513,13 +545,13 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional int32 value = 1; + // int32 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::int32 value() const; @@ -536,13 +568,10 @@ class LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<Int32Value> Int32Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ { @@ -557,47 +586,52 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const UInt32Value& default_instance(); - static const UInt32Value* internal_default_instance(); + static inline const UInt32Value* internal_default_instance() { + return reinterpret_cast<const UInt32Value*>( + &_UInt32Value_default_instance_); + } void UnsafeArenaSwap(UInt32Value* other); void Swap(UInt32Value* other); // implements Message ---------------------------------------------- - inline UInt32Value* New() const { return New(NULL); } + inline UInt32Value* New() const PROTOBUF_FINAL { return New(NULL); } - UInt32Value* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + UInt32Value* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const UInt32Value& from); void MergeFrom(const UInt32Value& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(UInt32Value* other); - void UnsafeMergeFrom(const UInt32Value& from); protected: explicit UInt32Value(::google::protobuf::Arena* arena); private: @@ -612,13 +646,13 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional uint32 value = 1; + // uint32 value = 1; void clear_value(); static const int kValueFieldNumber = 1; ::google::protobuf::uint32 value() const; @@ -635,13 +669,10 @@ class LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@p mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<UInt32Value> UInt32Value_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ { @@ -656,47 +687,52 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BoolValue& default_instance(); - static const BoolValue* internal_default_instance(); + static inline const BoolValue* internal_default_instance() { + return reinterpret_cast<const BoolValue*>( + &_BoolValue_default_instance_); + } void UnsafeArenaSwap(BoolValue* other); void Swap(BoolValue* other); // implements Message ---------------------------------------------- - inline BoolValue* New() const { return New(NULL); } + inline BoolValue* New() const PROTOBUF_FINAL { return New(NULL); } - BoolValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + BoolValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BoolValue& from); void MergeFrom(const BoolValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(BoolValue* other); - void UnsafeMergeFrom(const BoolValue& from); protected: explicit BoolValue(::google::protobuf::Arena* arena); private: @@ -711,13 +747,13 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bool value = 1; + // bool value = 1; void clear_value(); static const int kValueFieldNumber = 1; bool value() const; @@ -734,13 +770,10 @@ class LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@pro mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<BoolValue> BoolValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ { @@ -755,47 +788,52 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const StringValue& default_instance(); - static const StringValue* internal_default_instance(); + static inline const StringValue* internal_default_instance() { + return reinterpret_cast<const StringValue*>( + &_StringValue_default_instance_); + } void UnsafeArenaSwap(StringValue* other); void Swap(StringValue* other); // implements Message ---------------------------------------------- - inline StringValue* New() const { return New(NULL); } + inline StringValue* New() const PROTOBUF_FINAL { return New(NULL); } - StringValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + StringValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const StringValue& from); void MergeFrom(const StringValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(StringValue* other); - void UnsafeMergeFrom(const StringValue& from); protected: explicit StringValue(::google::protobuf::Arena* arena); private: @@ -810,13 +848,13 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional string value = 1; + // string value = 1; void clear_value(); static const int kValueFieldNumber = 1; const ::std::string& value() const; @@ -841,13 +879,10 @@ class LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@p mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<StringValue> StringValue_default_instance_; - // ------------------------------------------------------------------- class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ { @@ -862,47 +897,52 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr return *this; } - inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); } - inline void* GetMaybeArenaPointer() const { + inline ::google::protobuf::Arena* GetArena() const PROTOBUF_FINAL { + return GetArenaNoVirtual(); + } + inline void* GetMaybeArenaPointer() const PROTOBUF_FINAL { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const BytesValue& default_instance(); - static const BytesValue* internal_default_instance(); + static inline const BytesValue* internal_default_instance() { + return reinterpret_cast<const BytesValue*>( + &_BytesValue_default_instance_); + } void UnsafeArenaSwap(BytesValue* other); void Swap(BytesValue* other); // implements Message ---------------------------------------------- - inline BytesValue* New() const { return New(NULL); } + inline BytesValue* New() const PROTOBUF_FINAL { return New(NULL); } - BytesValue* New(::google::protobuf::Arena* arena) const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); + BytesValue* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const BytesValue& from); void MergeFrom(const BytesValue& from); - void Clear(); - bool IsInitialized() const; + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; - size_t ByteSizeLong() const; + size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( - bool deterministic, ::google::protobuf::uint8* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const { + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } - int GetCachedSize() const { return _cached_size_; } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); - void SetCachedSize(int size) const; + void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(BytesValue* other); - void UnsafeMergeFrom(const BytesValue& from); protected: explicit BytesValue(::google::protobuf::Arena* arena); private: @@ -917,13 +957,13 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr } public: - ::google::protobuf::Metadata GetMetadata() const; + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- - // optional bytes value = 1; + // bytes value = 1; void clear_value(); static const int kValueFieldNumber = 1; const ::std::string& value() const; @@ -948,13 +988,10 @@ class LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@pr mutable int _cached_size_; friend void LIBPROTOBUF_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fwrappers_2eproto_impl(); friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto_impl(); - friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto(); + friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fwrappers_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto(); - void InitAsDefaultInstance(); }; -extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValue_default_instance_; - // =================================================================== @@ -963,7 +1000,7 @@ extern ::google::protobuf::internal::ExplicitlyConstructed<BytesValue> BytesValu #if !PROTOBUF_INLINE_NOT_IN_HEADERS // DoubleValue -// optional double value = 1; +// double value = 1; inline void DoubleValue::clear_value() { value_ = 0; } @@ -977,14 +1014,11 @@ inline void DoubleValue::set_value(double value) { // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value) } -inline const DoubleValue* DoubleValue::internal_default_instance() { - return &DoubleValue_default_instance_.get(); -} // ------------------------------------------------------------------- // FloatValue -// optional float value = 1; +// float value = 1; inline void FloatValue::clear_value() { value_ = 0; } @@ -998,14 +1032,11 @@ inline void FloatValue::set_value(float value) { // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value) } -inline const FloatValue* FloatValue::internal_default_instance() { - return &FloatValue_default_instance_.get(); -} // ------------------------------------------------------------------- // Int64Value -// optional int64 value = 1; +// int64 value = 1; inline void Int64Value::clear_value() { value_ = GOOGLE_LONGLONG(0); } @@ -1019,14 +1050,11 @@ inline void Int64Value::set_value(::google::protobuf::int64 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value) } -inline const Int64Value* Int64Value::internal_default_instance() { - return &Int64Value_default_instance_.get(); -} // ------------------------------------------------------------------- // UInt64Value -// optional uint64 value = 1; +// uint64 value = 1; inline void UInt64Value::clear_value() { value_ = GOOGLE_ULONGLONG(0); } @@ -1040,14 +1068,11 @@ inline void UInt64Value::set_value(::google::protobuf::uint64 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value) } -inline const UInt64Value* UInt64Value::internal_default_instance() { - return &UInt64Value_default_instance_.get(); -} // ------------------------------------------------------------------- // Int32Value -// optional int32 value = 1; +// int32 value = 1; inline void Int32Value::clear_value() { value_ = 0; } @@ -1061,14 +1086,11 @@ inline void Int32Value::set_value(::google::protobuf::int32 value) { // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value) } -inline const Int32Value* Int32Value::internal_default_instance() { - return &Int32Value_default_instance_.get(); -} // ------------------------------------------------------------------- // UInt32Value -// optional uint32 value = 1; +// uint32 value = 1; inline void UInt32Value::clear_value() { value_ = 0u; } @@ -1082,14 +1104,11 @@ inline void UInt32Value::set_value(::google::protobuf::uint32 value) { // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value) } -inline const UInt32Value* UInt32Value::internal_default_instance() { - return &UInt32Value_default_instance_.get(); -} // ------------------------------------------------------------------- // BoolValue -// optional bool value = 1; +// bool value = 1; inline void BoolValue::clear_value() { value_ = false; } @@ -1103,20 +1122,17 @@ inline void BoolValue::set_value(bool value) { // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value) } -inline const BoolValue* BoolValue::internal_default_instance() { - return &BoolValue_default_instance_.get(); -} // ------------------------------------------------------------------- // StringValue -// optional string value = 1; +// string value = 1; inline void StringValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } inline void StringValue::set_value(const ::std::string& value) { @@ -1176,20 +1192,17 @@ inline void StringValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value) } -inline const StringValue* StringValue::internal_default_instance() { - return &StringValue_default_instance_.get(); -} // ------------------------------------------------------------------- // BytesValue -// optional bytes value = 1; +// bytes value = 1; inline void BytesValue::clear_value() { value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline const ::std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); + return value_.Get(); } inline void BytesValue::set_value(const ::std::string& value) { @@ -1249,9 +1262,6 @@ inline void BytesValue::unsafe_arena_set_allocated_value( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value) } -inline const BytesValue* BytesValue::internal_default_instance() { - return &BytesValue_default_instance_.get(); -} #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- @@ -1272,6 +1282,7 @@ inline const BytesValue* BytesValue::internal_default_instance() { // @@protoc_insertion_point(namespace_scope) + } // namespace protobuf } // namespace google @@ -51,7 +51,7 @@ build_cpp_distcheck() { make dist # List all files that should be included in the distribution package. - git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|cmake\|examples\)" |\ + git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\)" |\ grep -v ".gitignore" | grep -v "java/compatibility_tests" > dist.lst # Unzip the dist tar file. DIST=`ls *.tar.gz` @@ -89,7 +89,7 @@ build_csharp() { echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list sudo apt-get update -qq sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit - + # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net. sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 @@ -335,6 +335,19 @@ build_javascript() { cd js && npm install && npm test && cd .. } +generate_php_test_proto() { + internal_build_cpp + pushd php/tests + # Generate test file + rm -rf generated + mkdir generated + ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto + pushd ../../src + ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto + popd + popd +} + use_php() { VERSION=$1 PHP=`which php` @@ -346,6 +359,7 @@ use_php() { cp "/usr/bin/php$VERSION" $PHP cp "/usr/bin/php-config$VERSION" $PHP_CONFIG cp "/usr/bin/phpize$VERSION" $PHPIZE + generate_php_test_proto } use_php_zts() { @@ -356,6 +370,7 @@ use_php_zts() { ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE + generate_php_test_proto } use_php_bc() { @@ -366,10 +381,12 @@ use_php_bc() { ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE + generate_php_test_proto } build_php5.5() { use_php 5.5 + cd php rm -rf vendor cp -r /usr/local/vendor-5.5 vendor ./vendor/bin/phpunit @@ -388,6 +405,7 @@ build_php5.5_zts_c() { build_php5.5_32() { use_php_bc 5.5 + cd php rm -rf vendor cp -r /usr/local/vendor-5.5 vendor ./vendor/bin/phpunit @@ -401,6 +419,7 @@ build_php5.5_c_32() { build_php5.6() { use_php 5.6 + cd php rm -rf vendor cp -r /usr/local/vendor-5.6 vendor ./vendor/bin/phpunit @@ -412,6 +431,7 @@ build_php5.6_c() { } build_php5.6_mac() { + generate_php_test_proto # Install PHP curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6 PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time @@ -433,6 +453,7 @@ build_php5.6_mac() { build_php7.0() { use_php 7.0 + cd php rm -rf vendor cp -r /usr/local/vendor-7.0 vendor ./vendor/bin/phpunit |