diff --git a/BUILD b/BUILD index ef9fae28a6..5d82fc1d4d 100644 --- a/BUILD +++ b/BUILD @@ -1,5 +1,9 @@ # Bazel (https://bazel.build/) BUILD file for Protobuf. +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library") +load("@rules_java//java:defs.bzl", "java_library") +load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") + licenses(["notice"]) exports_files(["LICENSE"]) @@ -103,10 +107,10 @@ LINK_OPTS = select({ load( ":protobuf.bzl", "cc_proto_library", - "py_proto_library", "internal_copied_filegroup", "internal_gen_well_known_protos_java", "internal_protobuf_py_tests", + "py_proto_library", ) cc_library( @@ -493,6 +497,7 @@ cc_proto_library( COMMON_TEST_SRCS = [ # AUTOGEN(common_test_srcs) "src/google/protobuf/arena_test_util.cc", + "src/google/protobuf/map_test_util.inc", "src/google/protobuf/test_util.cc", "src/google/protobuf/test_util.inc", "src/google/protobuf/testing/file.cc", @@ -605,7 +610,7 @@ cc_test( "src/google/protobuf/wire_format_unittest.cc", ] + select({ "//conditions:default": [ - # Doesn't pass on Windows with MSVC + # AUTOGEN(non_msvc_test_srcs) "src/google/protobuf/compiler/command_line_interface_unittest.cc", ], ":msvc": [], @@ -1216,3 +1221,20 @@ cc_binary( ":text_format_conformance_suite", ], ) + +sh_test( + name = "build_files_updated_unittest", + srcs = [ + "build_files_updated_unittest.sh", + ], + data = [ + "BUILD", + "cmake/extract_includes.bat.in", + "cmake/libprotobuf.cmake", + "cmake/libprotobuf-lite.cmake", + "cmake/libprotoc.cmake", + "cmake/tests.cmake", + "src/Makefile.am", + "update_file_lists.sh", + ], +) diff --git a/Makefile.am b/Makefile.am index c03b45c78a..9d1b607116 100644 --- a/Makefile.am +++ b/Makefile.am @@ -339,6 +339,7 @@ java_EXTRA_DIST= java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \ java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java \ java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java \ + java/core/src/main/java/com/google/protobuf/TypeRegistry.java \ java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java \ java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java \ java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java \ @@ -435,6 +436,7 @@ java_EXTRA_DIST= java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java \ java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java \ java/core/src/test/java/com/google/protobuf/TextFormatTest.java \ + java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java \ java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \ java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \ java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \ diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec new file mode 100644 index 0000000000..ffcb1a744c --- /dev/null +++ b/Protobuf-C++.podspec @@ -0,0 +1,42 @@ +Pod::Spec.new do |s| + s.name = 'Protobuf-C++' + s.version = '3.9.0-rc1' + s.summary = 'Protocol Buffers v3 runtime library for C++.' + s.homepage = 'https://github.com/google/protobuf' + s.license = '3-Clause BSD License' + s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } + s.cocoapods_version = '>= 1.0' + + s.source = { :git => 'https://github.com/google/protobuf.git', + :tag => "v#{s.version}" } + + s.source_files = 'src/google/protobuf/*.{h,cc,inc}', + 'src/google/protobuf/stubs/*.{h,cc}', + 'src/google/protobuf/io/*.{h,cc}', + 'src/google/protobuf/util/*.{h,cc}', + 'src/google/protobuf/util/internal/*.{h,cc}' + + # Excluding all the tests in the directories above + s.exclude_files = 'src/google/**/*_test.{h,cc,inc}', + 'src/google/**/*_unittest.{h,cc}', + 'src/google/protobuf/test_util*.{h,cc}', + 'src/google/protobuf/map_lite_test_util.{h,cc}', + 'src/google/protobuf/map_test_util*.{h,cc,inc}' + + s.header_mappings_dir = 'src' + + s.ios.deployment_target = '7.0' + s.osx.deployment_target = '10.9' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' + + s.pod_target_xcconfig = { + # Do not let src/google/protobuf/stubs/time.h override system API + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + + # Configure tool is not being used for Xcode. When building, assume pthread is supported. + 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "HAVE_PTHREAD=1"', + } + +end diff --git a/build_files_updated_unittest.sh b/build_files_updated_unittest.sh new file mode 100755 index 0000000000..c86307193c --- /dev/null +++ b/build_files_updated_unittest.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# This script verifies that BUILD files and cmake files are in sync with src/Makefile.am + +set -eo pipefail + +if [ "$(uname)" != "Linux" ]; then + echo "build_files_updated_unittest only supported on Linux. Skipping..." + exit 0 +fi + +# Keep in sync with files needed by update_file_lists.sh +generated_files=( + "BUILD" + "cmake/extract_includes.bat.in" + "cmake/libprotobuf-lite.cmake" + "cmake/libprotobuf.cmake" + "cmake/libprotoc.cmake" + "cmake/tests.cmake" + "src/Makefile.am" +) + +# If we're running in Bazel, use the Bazel-provided temp-dir. +if [ -n "${TEST_TMPDIR}" ]; then + # Env-var TEST_TMPDIR is set, assume that this is Bazel. + # Bazel may have opinions whether we are allowed to delete TEST_TMPDIR. + test_root="${TEST_TMPDIR}/build_files_updated_unittest" + mkdir "${test_root}" +else + # Seems like we're not executed by Bazel. + test_root=$(mktemp -d) +fi + +# From now on, fail if there are any unbound variables. +set -u + +# Remove artifacts after test is finished. +function cleanup { + rm -rf "${test_root}" +} +trap cleanup EXIT + +# Create golden dir and add snapshot of current state. +golden_dir="${test_root}/golden" +mkdir -p "${golden_dir}/cmake" "${golden_dir}/src" +for file in ${generated_files[@]}; do + cp "${file}" "${golden_dir}/${file}" +done + +# Create test dir, copy current state into it, and execute update script. +test_dir="${test_root}/test" +cp -R "${golden_dir}" "${test_dir}" + +cp "update_file_lists.sh" "${test_dir}/update_file_lists.sh" +chmod +x "${test_dir}/update_file_lists.sh" +cd "${test_root}/test" +bash "${test_dir}/update_file_lists.sh" + +# Test whether there are any differences +for file in ${generated_files[@]}; do + diff "${golden_dir}/${file}" "${test_dir}/${file}" +done diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 7c97f20c4f..007cc80669 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -92,6 +92,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h" incl copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h" include\google\protobuf\stubs\hash.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h" include\google\protobuf\stubs\macros.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\map_util.h" include\google\protobuf\stubs\map_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h" include\google\protobuf\stubs\mutex.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h" include\google\protobuf\stubs\once.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h" include\google\protobuf\stubs\platform_macros.h diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 39c39c1310..6bf86a2770 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -10,7 +10,7 @@ set(libprotobuf_lite_files ${protobuf_source_dir}/src/google/protobuf/io/io_win32.cc ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc - ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc + ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${protobuf_source_dir}/src/google/protobuf/message_lite.cc ${protobuf_source_dir}/src/google/protobuf/parse_context.cc diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 5c25acc68a..d4b47c54e5 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -132,7 +132,6 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc ${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.cc - ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc @@ -203,12 +202,21 @@ set(tests_files ${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc ) +set(non_msvc_tests_files + ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc +) + +set(all_tests_files + ${tests_files} + ${non_msvc_tests_files} +) + if(protobuf_ABSOLUTE_TEST_PLUGIN_PATH) add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH="$") endif() if(MINGW) - set_source_files_properties(${tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") + set_source_files_properties(${all_tests_files} PROPERTIES COMPILE_FLAGS "-Wno-narrowing") # required for tests on MinGW Win64 if (CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -218,7 +226,7 @@ if(MINGW) endif() -add_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) +add_executable(tests ${all_tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files}) target_link_libraries(tests libprotoc libprotobuf gmock_main) set(test_plugin_files diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index 9c34b42a0d..a2855e95ed 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -149,10 +149,6 @@ string tag(uint32_t fieldnum, char wire_type) { return varint((fieldnum << 3) | wire_type); } -string submsg(uint32_t fn, const string& buf) { - return cat( tag(fn, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), delim(buf) ); -} - #define UNKNOWN_FIELD 666 const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type, @@ -375,12 +371,21 @@ void BinaryAndJsonConformanceSuite::RunValidProtobufTest( void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest( const string& test_name, ConformanceLevel level, const string& input_protobuf, bool is_proto3) { + RunValidBinaryProtobufTest( + test_name, level, input_protobuf, input_protobuf, is_proto3); +} + +void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest( + const string& test_name, ConformanceLevel level, + const string& input_protobuf, + const string& expected_protobuf, + bool is_proto3) { std::unique_ptr prototype = NewTestMessage(is_proto3); ConformanceRequestSetting setting( level, conformance::PROTOBUF, conformance::PROTOBUF, conformance::BINARY_TEST, *prototype, test_name, input_protobuf); - RunValidBinaryInputTest(setting, input_protobuf); + RunValidBinaryInputTest(setting, expected_protobuf, true); } void BinaryAndJsonConformanceSuite::RunValidProtobufTestWithMessage( @@ -594,27 +599,149 @@ void BinaryAndJsonConformanceSuite::TestValidDataForType( const FieldDescriptor* field = GetFieldForType(type, false, is_proto3); const FieldDescriptor* rep_field = GetFieldForType(type, true, is_proto3); - RunValidProtobufTest("ValidDataScalar" + type_name, REQUIRED, - cat(tag(field->number(), wire_type), values[0].first), - field->name() + ": " + values[0].second, is_proto3); - - string proto; - string text = field->name() + ": " + values.back().second; + // Test singular data for singular fields. for (size_t i = 0; i < values.size(); i++) { - proto += cat(tag(field->number(), wire_type), values[i].first); + string proto = + cat(tag(field->number(), wire_type), values[i].first); + string expected_proto = + cat(tag(field->number(), wire_type), values[i].second); + std::unique_ptr test_message = NewTestMessage(is_proto3); + test_message->MergeFromString(expected_proto); + string text = test_message->DebugString(); + + RunValidProtobufTest(StrCat("ValidDataScalar", type_name, "[", i, "]"), + REQUIRED, proto, text, is_proto3); + } + + // Test repeated data for singular fields. + // For scalar message fields, repeated values are merged, which is tested + // separately. + if (type != FieldDescriptor::TYPE_MESSAGE) { + string proto; + for (size_t i = 0; i < values.size(); i++) { + proto += cat(tag(field->number(), wire_type), values[i].first); + } + string expected_proto = + cat(tag(field->number(), wire_type), values.back().second); + std::unique_ptr test_message = NewTestMessage(is_proto3); + test_message->MergeFromString(expected_proto); + string text = test_message->DebugString(); + + RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED, + proto, text, is_proto3); + } + + // Test repeated fields. + if (FieldDescriptor::IsTypePackable(type)) { + string packed_proto; + string unpacked_proto; + string packed_proto_expected; + string unpacked_proto_expected; + + for (size_t i = 0; i < values.size(); i++) { + unpacked_proto += + cat(tag(rep_field->number(), wire_type), values[i].first); + unpacked_proto_expected += + cat(tag(rep_field->number(), wire_type), values[i].second); + packed_proto += values[i].first; + packed_proto_expected += values[i].second; + } + packed_proto = + cat(tag(rep_field->number(), + WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + delim(packed_proto)); + packed_proto_expected = + cat(tag(rep_field->number(), + WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + delim(packed_proto_expected)); + + std::unique_ptr test_message = NewTestMessage(is_proto3); + test_message->MergeFromString(packed_proto_expected); + string text = test_message->DebugString(); + + // Ensures both packed and unpacked data can be parsed. + RunValidProtobufTest( + StrCat("ValidDataRepeated", type_name, ".UnpackedInput"), + REQUIRED, unpacked_proto, text, is_proto3); + RunValidProtobufTest( + StrCat("ValidDataRepeated", type_name, ".PackedInput"), + REQUIRED, packed_proto, text, is_proto3); + + // proto2 should encode as unpacked by default and proto3 should encode as + // packed by default. + string expected_proto = + rep_field->is_packed() ? packed_proto_expected : + unpacked_proto_expected; + RunValidBinaryProtobufTest( + StrCat("ValidDataRepeated", type_name, + ".UnpackedInput.DefaultOutput"), + RECOMMENDED, + unpacked_proto, + expected_proto, is_proto3); + RunValidBinaryProtobufTest( + StrCat("ValidDataRepeated", type_name, + ".PackedInput.DefaultOutput"), + RECOMMENDED, + packed_proto, + expected_proto, is_proto3); + } else { + string proto; + string expected_proto; + for (size_t i = 0; i < values.size(); i++) { + proto += cat(tag(rep_field->number(), wire_type), values[i].first); + expected_proto += + cat(tag(rep_field->number(), wire_type), values[i].second); + } + std::unique_ptr test_message = NewTestMessage(is_proto3); + test_message->MergeFromString(expected_proto); + string text = test_message->DebugString(); + + RunValidProtobufTest( + StrCat("ValidDataRepeated", type_name), + REQUIRED, proto, text, is_proto3); } - RunValidProtobufTest("RepeatedScalarSelectsLast" + type_name, REQUIRED, - proto, text, is_proto3); + } +} - proto.clear(); - text.clear(); +void BinaryAndJsonConformanceSuite::TestValidDataForRepeatedScalarMessage() { + std::vector values = { + delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + delim(cat( + tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234), + tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1234), + tag(31, WireFormatLite::WIRETYPE_VARINT), varint(1234) + )))), + delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + delim(cat( + tag(1, WireFormatLite::WIRETYPE_VARINT), varint(4321), + tag(3, WireFormatLite::WIRETYPE_VARINT), varint(4321), + tag(31, WireFormatLite::WIRETYPE_VARINT), varint(4321) + )))), + }; + + const std::string expected = + R"({ + corecursive: { + optional_int32: 4321, + optional_int64: 1234, + optional_uint32: 4321, + repeated_int32: [1234, 4321], + } + })"; + for (int is_proto3 = 0; is_proto3 < 2; is_proto3++) { + string proto; + const FieldDescriptor* field = + GetFieldForType(FieldDescriptor::TYPE_MESSAGE, false, is_proto3); for (size_t i = 0; i < values.size(); i++) { - proto += cat(tag(rep_field->number(), wire_type), values[i].first); - text += rep_field->name() + ": " + values[i].second + " "; + proto += + cat(tag(field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED), + values[i]); } - RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED, - proto, text, is_proto3); + + RunValidProtobufTest( + "RepeatedScalarMessageMerge", REQUIRED, proto, + field->name() + ": " + expected, is_proto3); } } @@ -714,88 +841,109 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() { uint32 kUint32Max = 4294967295UL; TestValidDataForType(FieldDescriptor::TYPE_DOUBLE, { - {dbl(0.1), "0.1"}, - {dbl(1.7976931348623157e+308), "1.7976931348623157e+308"}, - {dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"} + {dbl(0.1), dbl(0.1)}, + {dbl(1.7976931348623157e+308), dbl(1.7976931348623157e+308)}, + {dbl(2.22507385850720138309e-308), dbl(2.22507385850720138309e-308)} }); TestValidDataForType(FieldDescriptor::TYPE_FLOAT, { - {flt(0.1), "0.1"}, - {flt(1.00000075e-36), "1.00000075e-36"}, - {flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38 - {flt(1.17549435e-38f), "1.17549435e-38"} + {flt(0.1), flt(0.1)}, + {flt(1.00000075e-36), flt(1.00000075e-36)}, + {flt(3.402823e+38), flt(3.402823e+38)}, // 3.40282347e+38 + {flt(1.17549435e-38f), flt(1.17549435e-38)} }); TestValidDataForType(FieldDescriptor::TYPE_INT64, { - {varint(12345), "12345"}, - {varint(kInt64Max), std::to_string(kInt64Max)}, - {varint(kInt64Min), std::to_string(kInt64Min)} + {varint(12345), varint(12345)}, + {varint(kInt64Max), varint(kInt64Max)}, + {varint(kInt64Min), varint(kInt64Min)} }); TestValidDataForType(FieldDescriptor::TYPE_UINT64, { - {varint(12345), "12345"}, - {varint(kUint64Max), std::to_string(kUint64Max)}, - {varint(0), "0"} + {varint(12345), varint(12345)}, + {varint(kUint64Max), varint(kUint64Max)}, + {varint(0), varint(0)} }); TestValidDataForType(FieldDescriptor::TYPE_INT32, { - {varint(12345), "12345"}, - {longvarint(12345, 2), "12345"}, - {longvarint(12345, 7), "12345"}, - {varint(kInt32Max), std::to_string(kInt32Max)}, - {varint(kInt32Min), std::to_string(kInt32Min)}, - {varint(1LL << 33), std::to_string(static_cast(1LL << 33))}, - {varint((1LL << 33) - 1), - std::to_string(static_cast((1LL << 33) - 1))}, + {varint(12345), varint(12345)}, + {longvarint(12345, 2), varint(12345)}, + {longvarint(12345, 7), varint(12345)}, + {varint(kInt32Max), varint(kInt32Max)}, + {varint(kInt32Min), varint(kInt32Min)}, + {varint(1LL << 33), varint(0)}, + {varint((1LL << 33) - 1), varint(-1)}, }); TestValidDataForType(FieldDescriptor::TYPE_UINT32, { - {varint(12345), "12345"}, - {longvarint(12345, 2), "12345"}, - {longvarint(12345, 7), "12345"}, - {varint(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX - {varint(0), "0"}, - {varint(1LL << 33), std::to_string(static_cast(1LL << 33))}, - {varint((1LL << 33) - 1), - std::to_string(static_cast((1LL << 33) - 1))}, + {varint(12345), varint(12345)}, + {longvarint(12345, 2), varint(12345)}, + {longvarint(12345, 7), varint(12345)}, + {varint(kUint32Max), varint(kUint32Max)}, // UINT32_MAX + {varint(0), varint(0)}, + {varint(1LL << 33), varint(0)}, + {varint((1LL << 33) - 1), varint((1LL << 32) - 1)}, }); TestValidDataForType(FieldDescriptor::TYPE_FIXED64, { - {u64(12345), "12345"}, - {u64(kUint64Max), std::to_string(kUint64Max)}, - {u64(0), "0"} + {u64(12345), u64(12345)}, + {u64(kUint64Max), u64(kUint64Max)}, + {u64(0), u64(0)} }); TestValidDataForType(FieldDescriptor::TYPE_FIXED32, { - {u32(12345), "12345"}, - {u32(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX - {u32(0), "0"} + {u32(12345), u32(12345)}, + {u32(kUint32Max), u32(kUint32Max)}, // UINT32_MAX + {u32(0), u32(0)} }); TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, { - {u64(12345), "12345"}, - {u64(kInt64Max), std::to_string(kInt64Max)}, - {u64(kInt64Min), std::to_string(kInt64Min)} + {u64(12345), u64(12345)}, + {u64(kInt64Max), u64(kInt64Max)}, + {u64(kInt64Min), u64(kInt64Min)} }); TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, { - {u32(12345), "12345"}, - {u32(kInt32Max), std::to_string(kInt32Max)}, - {u32(kInt32Min), std::to_string(kInt32Min)} + {u32(12345), u32(12345)}, + {u32(kInt32Max), u32(kInt32Max)}, + {u32(kInt32Min), u32(kInt32Min)} }); TestValidDataForType(FieldDescriptor::TYPE_BOOL, { - {varint(1), "true"}, - {varint(0), "false"}, - {varint(12345678), "true"} + {varint(1), varint(1)}, + {varint(0), varint(0)}, + {varint(12345678), varint(1)} }); TestValidDataForType(FieldDescriptor::TYPE_SINT32, { - {zz32(12345), "12345"}, - {zz32(kInt32Max), std::to_string(kInt32Max)}, - {zz32(kInt32Min), std::to_string(kInt32Min)} + {zz32(12345), zz32(12345)}, + {zz32(kInt32Max), zz32(kInt32Max)}, + {zz32(kInt32Min), zz32(kInt32Min)} }); TestValidDataForType(FieldDescriptor::TYPE_SINT64, { - {zz64(12345), "12345"}, - {zz64(kInt64Max), std::to_string(kInt64Max)}, - {zz64(kInt64Min), std::to_string(kInt64Min)} + {zz64(12345), zz64(12345)}, + {zz64(kInt64Max), zz64(kInt64Max)}, + {zz64(kInt64Min), zz64(kInt64Min)} + }); + TestValidDataForType(FieldDescriptor::TYPE_STRING, { + {delim("Hello world!"), delim("Hello world!")}, + {delim("\'\"\?\\\a\b\f\n\r\t\v"), + delim("\'\"\?\\\a\b\f\n\r\t\v")}, // escape + {delim("谷歌"), delim("谷歌")}, // Google in Chinese + {delim("\u8C37\u6B4C"), delim("谷歌")}, // unicode escape + {delim("\u8c37\u6b4c"), delim("谷歌")}, // lowercase unicode + {delim("\xF0\x9F\x98\x81"), delim("\xF0\x9F\x98\x81")}, // emoji: 😁 + {delim(""), delim("")}, + }); + TestValidDataForType(FieldDescriptor::TYPE_BYTES, { + {delim("\x01\x02"), delim("\x01\x02")}, + {delim("\xfb"), delim("\xfb")}, + {delim(""), delim("")}, + }); + TestValidDataForType(FieldDescriptor::TYPE_ENUM, { + {varint(0), varint(0)}, + {varint(1), varint(1)}, + {varint(2), varint(2)}, + {varint(-1), varint(-1)}, + }); + TestValidDataForRepeatedScalarMessage(); + TestValidDataForType(FieldDescriptor::TYPE_MESSAGE, { + {delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234))), + delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234)))}, + {delim(""), delim("")}, }); // TODO(haberman): - // TestValidDataForType(FieldDescriptor::TYPE_STRING // TestValidDataForType(FieldDescriptor::TYPE_GROUP - // TestValidDataForType(FieldDescriptor::TYPE_MESSAGE - // TestValidDataForType(FieldDescriptor::TYPE_BYTES - // TestValidDataForType(FieldDescriptor::TYPE_ENUM RunValidJsonTest("HelloWorld", REQUIRED, "{\"optionalString\":\"Hello, World!\"}", diff --git a/conformance/binary_json_conformance_suite.h b/conformance/binary_json_conformance_suite.h index 7a03545fa5..a689a9c57b 100644 --- a/conformance/binary_json_conformance_suite.h +++ b/conformance/binary_json_conformance_suite.h @@ -63,6 +63,11 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite { ConformanceLevel level, const string& input_protobuf, bool is_proto3); + void RunValidBinaryProtobufTest(const string& test_name, + ConformanceLevel level, + const string& input_protobuf, + const string& expected_protobuf, + bool is_proto3); void RunValidProtobufTestWithMessage( const string& test_name, ConformanceLevel level, const Message *input, @@ -109,6 +114,7 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite { void TestValidDataForType( google::protobuf::FieldDescriptor::Type, std::vector> values); + void TestValidDataForRepeatedScalarMessage(); std::unique_ptr type_resolver_; diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m index 60b2ac59ed..1d677034e6 100644 --- a/conformance/conformance_objc.m +++ b/conformance/conformance_objc.m @@ -68,7 +68,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.payloadOneOfCase) { case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase: - Die(@"Request didn't have a payload: %@", request); + response.runtimeError = + [NSString stringWithFormat:@"Request didn't have a payload: %@", request]; break; case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: { @@ -78,7 +79,10 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { } else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) { msgClass = [TestAllTypesProto2 class]; } else { - Die(@"Protobuf request had an unknown message_type: %@", request.messageType); + response.runtimeError = + [NSString stringWithFormat: + @"Protobuf request had an unknown message_type: %@", request.messageType]; + break; } NSError *error = nil; testMessage = [msgClass parseFromData:request.protobufPayload error:&error]; @@ -108,7 +112,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { switch (request.requestedOutputFormat) { case WireFormat_GPBUnrecognizedEnumeratorValue: case WireFormat_Unspecified: - Die(@"Unrecognized/unspecified output format: %@", request); + response.runtimeError = + [NSString stringWithFormat:@"Unrecognized/unspecified output format: %@", request]; break; case WireFormat_Protobuf: diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 6325b354a3..0ad929aadb 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -54,6 +54,25 @@ using google::protobuf::util::MessageDifferencer; using google::protobuf::util::Status; using std::string; +namespace { + +static string ToOctString(const string& binary_string) { + string oct_string; + for (size_t i = 0; i < binary_string.size(); i++) { + uint8_t c = binary_string.at(i); + uint8_t high = c / 64; + uint8_t mid = (c % 64) / 8; + uint8_t low = c % 8; + oct_string.push_back('\\'); + oct_string.push_back('0' + high); + oct_string.push_back('0' + mid); + oct_string.push_back('0' + low); + } + return oct_string; +} + +} + namespace google { namespace protobuf { @@ -220,18 +239,21 @@ void ConformanceTestSuite::RunValidInputTest( void ConformanceTestSuite::RunValidBinaryInputTest( const ConformanceRequestSetting& setting, - const string& equivalent_wire_format) { + const string& equivalent_wire_format, + bool require_same_wire_format) { const ConformanceRequest& request = setting.GetRequest(); ConformanceResponse response; RunTest(setting.GetTestName(), request, &response); - VerifyResponse(setting, equivalent_wire_format, response, true); + VerifyResponse(setting, equivalent_wire_format, response, + true, require_same_wire_format); } void ConformanceTestSuite::VerifyResponse( const ConformanceRequestSetting& setting, const string& equivalent_wire_format, const ConformanceResponse& response, - bool need_report_success) { + bool need_report_success, + bool require_same_wire_format) { Message* test_message = setting.GetTestMessage(); const ConformanceRequest& request = setting.GetRequest(); const string& test_name = setting.GetTestName(); @@ -270,8 +292,19 @@ void ConformanceTestSuite::VerifyResponse( string differences; differencer.ReportDifferencesToString(&differences); - bool check; - check = differencer.Compare(*reference_message, *test_message); + bool check = false; + + if (require_same_wire_format) { + GOOGLE_DCHECK_EQ(response.result_case(), + ConformanceResponse::kProtobufPayload); + const string& protobuf_payload = response.protobuf_payload(); + check = equivalent_wire_format == protobuf_payload; + differences = StrCat("Expect: ", ToOctString(equivalent_wire_format), + ", but got: ", ToOctString(protobuf_payload)); + } else { + check = differencer.Compare(*reference_message, *test_message); + } + if (check) { if (need_report_success) { ReportSuccess(test_name); diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h index 4d741e7f15..2f42d83e15 100644 --- a/conformance/conformance_test.h +++ b/conformance/conformance_test.h @@ -261,7 +261,8 @@ class ConformanceTestSuite { const ConformanceRequestSetting& setting, const string& equivalent_wire_format, const conformance::ConformanceResponse& response, - bool need_report_success); + bool need_report_success, + bool require_same_wire_format); void ReportSuccess(const std::string& test_name); void ReportFailure(const string& test_name, @@ -276,7 +277,8 @@ class ConformanceTestSuite { void RunValidInputTest(const ConformanceRequestSetting& setting, const string& equivalent_text_format); void RunValidBinaryInputTest(const ConformanceRequestSetting& setting, - const string& equivalent_wire_format); + const string& equivalent_wire_format, + bool require_same_wire_format = false); void RunTest(const std::string& test_name, const conformance::ConformanceRequest& request, diff --git a/conformance/failure_list_js.txt b/conformance/failure_list_js.txt index f8f6a578fa..f4a72fcd92 100644 --- a/conformance/failure_list_js.txt +++ b/conformance/failure_list_js.txt @@ -1,13 +1,57 @@ -Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.INT64.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.ProtobufOutput +Required.Proto2.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.ProtobufOutput diff --git a/conformance/failure_list_objc.txt b/conformance/failure_list_objc.txt index e34501ead7..e2d83bd724 100644 --- a/conformance/failure_list_objc.txt +++ b/conformance/failure_list_objc.txt @@ -1,2 +1,6 @@ # JSON input or output tests are skipped (in conformance_objc.m) as mobile # platforms don't support JSON wire format to avoid code bloat. +Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto2.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt index 28ca461d47..f346489539 100644 --- a/conformance/failure_list_php.txt +++ b/conformance/failure_list_php.txt @@ -4,17 +4,49 @@ Recommended.FieldMaskTooManyUnderscore.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldTooSmall Required.Proto3.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooSmall -Required.Proto3.JsonInput.DoubleFieldTooSmall +Required.Proto3.JsonInput.Int32FieldLeadingSpace Required.Proto3.JsonInput.Int32FieldNotInteger Required.Proto3.JsonInput.Int64FieldNotInteger +Required.Proto3.JsonInput.OneofFieldDuplicate Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt Required.Proto3.JsonInput.RepeatedListValue.JsonOutput Required.Proto3.JsonInput.RepeatedListValue.ProtobufOutput Required.Proto3.JsonInput.StringFieldNotAString Required.Proto3.JsonInput.Uint32FieldNotInteger Required.Proto3.JsonInput.Uint64FieldNotInteger -Required.Proto3.JsonInput.Int32FieldLeadingSpace -Required.Proto3.JsonInput.OneofFieldDuplicate -Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.JsonOutput +Required.Proto3.ProtobufInput.RepeatedScalarMessageMerge.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[1].JsonOutput diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt index 8f7af61855..2d79d1b709 100644 --- a/conformance/failure_list_php_c.txt +++ b/conformance/failure_list_php_c.txt @@ -17,10 +17,36 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput -Required.TimestampProtoInputTooLarge.JsonOutput -Required.TimestampProtoInputTooSmall.JsonOutput Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput @@ -34,11 +60,19 @@ Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput Required.Proto3.JsonInput.OneofFieldDuplicate Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.RejectTopLevelNull Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput -Required.Proto3.JsonInput.RejectTopLevelNull +Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[1].JsonOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt index fc6455d8e4..63dcde5156 100644 --- a/conformance/failure_list_ruby.txt +++ b/conformance/failure_list_ruby.txt @@ -15,6 +15,34 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput @@ -27,6 +55,12 @@ Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput Required.Proto3.JsonInput.FloatFieldNan.JsonOutput Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput Required.Proto3.JsonInput.OneofFieldDuplicate Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput @@ -39,6 +73,7 @@ Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.RejectTopLevelNull Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput @@ -54,13 +89,8 @@ Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[1].JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput -Required.Proto3.JsonInput.RejectTopLevelNull diff --git a/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt index 153b0a2019..63dcde5156 100644 --- a/conformance/failure_list_ruby_mac.txt +++ b/conformance/failure_list_ruby_mac.txt @@ -5,6 +5,7 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter Recommended.Proto3.JsonInput.MapFieldValueIsNull Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull @@ -14,6 +15,34 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput Required.DurationProtoInputTooSmall.JsonOutput Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput @@ -26,6 +55,12 @@ Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput Required.Proto3.JsonInput.FloatFieldNan.JsonOutput Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput +Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput Required.Proto3.JsonInput.OneofFieldDuplicate Required.Proto3.JsonInput.OptionalBoolWrapper.JsonOutput Required.Proto3.JsonInput.OptionalBytesWrapper.JsonOutput @@ -38,6 +73,7 @@ Required.Proto3.JsonInput.OptionalUint32Wrapper.JsonOutput Required.Proto3.JsonInput.OptionalUint64Wrapper.JsonOutput Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput +Required.Proto3.JsonInput.RejectTopLevelNull Required.Proto3.JsonInput.RepeatedBoolWrapper.JsonOutput Required.Proto3.JsonInput.RepeatedBytesWrapper.JsonOutput Required.Proto3.JsonInput.RepeatedDoubleWrapper.JsonOutput @@ -53,14 +89,8 @@ Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[1].JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonFalse.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonNull.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonNumber.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonObject.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonString.ProtobufOutput -Required.Proto3.JsonInput.IgnoreUnknownJsonTrue.ProtobufOutput -Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter -Required.Proto3.JsonInput.RejectTopLevelNull diff --git a/csharp/compatibility_tests/v3.0.0/test.sh b/csharp/compatibility_tests/v3.0.0/test.sh index 9fcf406c25..7c6df4fcc8 100755 --- a/csharp/compatibility_tests/v3.0.0/test.sh +++ b/csharp/compatibility_tests/v3.0.0/test.sh @@ -34,6 +34,8 @@ cd $(dirname $0) # these tests). TEST_VERSION=3.0.0 +LAST_RELEASED=3.9.0 + # The old version of protobuf that we are testing compatibility against. This # is usually the same as TEST_VERSION (i.e., we use the tests extracted from # that version to test compatibility of the newest runtime against it), but it @@ -52,6 +54,10 @@ case "$1" in OLD_VERSION=3.1.0 OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe ;; + $LAST_RELEASED) + OLD_VERSION=$LAST_RELEASED + OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe + ;; *) echo "[ERROR]: Unknown version number: $1" exit 1 diff --git a/csharp/src/Google.Protobuf.Test/testprotos.pb b/csharp/src/Google.Protobuf.Test/testprotos.pb index 71256aea77..e7a2fc68cc 100644 Binary files a/csharp/src/Google.Protobuf.Test/testprotos.pb and b/csharp/src/Google.Protobuf.Test/testprotos.pb differ diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs index 60e64effd4..90d31131fe 100644 --- a/csharp/src/Google.Protobuf/FieldCodec.cs +++ b/csharp/src/Google.Protobuf/FieldCodec.cs @@ -45,13 +45,178 @@ namespace Google.Protobuf { // TODO: Avoid the "dual hit" of lambda expressions: create open delegates instead. (At least test...) + /// + /// Retrieves a codec suitable for a string field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForString(uint tag) + { + return FieldCodec.ForString(tag, ""); + } + + /// + /// Retrieves a codec suitable for a bytes field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForBytes(uint tag) + { + return FieldCodec.ForBytes(tag, ByteString.Empty); + } + + /// + /// Retrieves a codec suitable for a bool field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForBool(uint tag) + { + return FieldCodec.ForBool(tag, false); + } + + /// + /// Retrieves a codec suitable for an int32 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForInt32(uint tag) + { + return FieldCodec.ForInt32(tag, 0); + } + + /// + /// Retrieves a codec suitable for an sint32 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForSInt32(uint tag) + { + return FieldCodec.ForSInt32(tag, 0); + } + + /// + /// Retrieves a codec suitable for a fixed32 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForFixed32(uint tag) + { + return FieldCodec.ForFixed32(tag, 0); + } + + /// + /// Retrieves a codec suitable for an sfixed32 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForSFixed32(uint tag) + { + return FieldCodec.ForSFixed32(tag, 0); + } + + /// + /// Retrieves a codec suitable for a uint32 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForUInt32(uint tag) + { + return FieldCodec.ForUInt32(tag, 0); + } + + /// + /// Retrieves a codec suitable for an int64 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForInt64(uint tag) + { + return FieldCodec.ForInt64(tag, 0); + } + + /// + /// Retrieves a codec suitable for an sint64 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForSInt64(uint tag) + { + return FieldCodec.ForSInt64(tag, 0); + } + + /// + /// Retrieves a codec suitable for a fixed64 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForFixed64(uint tag) + { + return FieldCodec.ForFixed64(tag, 0); + } + + /// + /// Retrieves a codec suitable for an sfixed64 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForSFixed64(uint tag) + { + return FieldCodec.ForSFixed64(tag, 0); + } + + /// + /// Retrieves a codec suitable for a uint64 field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForUInt64(uint tag) + { + return FieldCodec.ForUInt64(tag, 0); + } + + /// + /// Retrieves a codec suitable for a float field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForFloat(uint tag) + { + return FieldCodec.ForFloat(tag, 0); + } + + /// + /// Retrieves a codec suitable for a double field with the given tag. + /// + /// The tag. + /// A codec for the given tag. + public static FieldCodec ForDouble(uint tag) + { + return FieldCodec.ForDouble(tag, 0); + } + + // Enums are tricky. We can probably use expression trees to build these delegates automatically, + // but it's easy to generate the code for it. + + /// + /// Retrieves a codec suitable for an enum field with the given tag. + /// + /// The tag. + /// A conversion function from to the enum type. + /// A conversion function from the enum type to . + /// A codec for the given tag. + public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32) + { + return FieldCodec.ForEnum(tag, toInt32, fromInt32, default(T)); + } + /// /// Retrieves a codec suitable for a string field with the given tag. /// /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForString(uint tag, string defaultValue = "") + public static FieldCodec ForString(uint tag, string defaultValue) { return new FieldCodec(input => input.ReadString(), (output, value) => output.WriteString(value), CodedOutputStream.ComputeStringSize, tag); } @@ -62,7 +227,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForBytes(uint tag, ByteString defaultValue = null) + public static FieldCodec ForBytes(uint tag, ByteString defaultValue) { return new FieldCodec(input => input.ReadBytes(), (output, value) => output.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag); } @@ -73,7 +238,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForBool(uint tag, bool defaultValue = false) + public static FieldCodec ForBool(uint tag, bool defaultValue) { return new FieldCodec(input => input.ReadBool(), (output, value) => output.WriteBool(value), CodedOutputStream.BoolSize, tag); } @@ -84,7 +249,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForInt32(uint tag, int defaultValue = 0) + public static FieldCodec ForInt32(uint tag, int defaultValue) { return new FieldCodec(input => input.ReadInt32(), (output, value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag); } @@ -95,7 +260,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForSInt32(uint tag, int defaultValue = 0) + public static FieldCodec ForSInt32(uint tag, int defaultValue) { return new FieldCodec(input => input.ReadSInt32(), (output, value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag); } @@ -106,7 +271,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForFixed32(uint tag, uint defaultValue = 0) + public static FieldCodec ForFixed32(uint tag, uint defaultValue) { return new FieldCodec(input => input.ReadFixed32(), (output, value) => output.WriteFixed32(value), 4, tag); } @@ -117,7 +282,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForSFixed32(uint tag, int defaultValue = 0) + public static FieldCodec ForSFixed32(uint tag, int defaultValue) { return new FieldCodec(input => input.ReadSFixed32(), (output, value) => output.WriteSFixed32(value), 4, tag); } @@ -128,7 +293,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForUInt32(uint tag, uint defaultValue = 0) + public static FieldCodec ForUInt32(uint tag, uint defaultValue) { return new FieldCodec(input => input.ReadUInt32(), (output, value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag); } @@ -139,7 +304,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForInt64(uint tag, long defaultValue = 0) + public static FieldCodec ForInt64(uint tag, long defaultValue) { return new FieldCodec(input => input.ReadInt64(), (output, value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag); } @@ -150,7 +315,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForSInt64(uint tag, long defaultValue = 0) + public static FieldCodec ForSInt64(uint tag, long defaultValue) { return new FieldCodec(input => input.ReadSInt64(), (output, value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag); } @@ -161,7 +326,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForFixed64(uint tag, ulong defaultValue = 0) + public static FieldCodec ForFixed64(uint tag, ulong defaultValue) { return new FieldCodec(input => input.ReadFixed64(), (output, value) => output.WriteFixed64(value), 8, tag); } @@ -172,7 +337,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForSFixed64(uint tag, long defaultValue = 0) + public static FieldCodec ForSFixed64(uint tag, long defaultValue) { return new FieldCodec(input => input.ReadSFixed64(), (output, value) => output.WriteSFixed64(value), 8, tag); } @@ -183,7 +348,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForUInt64(uint tag, ulong defaultValue = 0) + public static FieldCodec ForUInt64(uint tag, ulong defaultValue) { return new FieldCodec(input => input.ReadUInt64(), (output, value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag); } @@ -194,7 +359,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForFloat(uint tag, float defaultValue = 0) + public static FieldCodec ForFloat(uint tag, float defaultValue) { return new FieldCodec(input => input.ReadFloat(), (output, value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag); } @@ -205,7 +370,7 @@ namespace Google.Protobuf /// The tag. /// The default value. /// A codec for the given tag. - public static FieldCodec ForDouble(uint tag, double defaultValue = 0) + public static FieldCodec ForDouble(uint tag, double defaultValue) { return new FieldCodec(input => input.ReadDouble(), (output, value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag); } @@ -221,7 +386,7 @@ namespace Google.Protobuf /// A conversion function from the enum type to . /// The default value. /// A codec for the given tag. - public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32, T defaultValue = default(T)) + public static FieldCodec ForEnum(uint tag, Func toInt32, Func fromInt32, T defaultValue) { return new FieldCodec(input => fromInt32( input.ReadEnum()), diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index 7a6f50190e..f0078c4dd4 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -62,7 +62,7 @@ namespace Google.Protobuf.WellKnownTypes { /// if (duration.seconds < 0 && duration.nanos > 0) { /// duration.seconds += 1; /// duration.nanos -= 1000000000; - /// } else if (durations.seconds > 0 && duration.nanos < 0) { + /// } else if (duration.seconds > 0 && duration.nanos < 0) { /// duration.seconds -= 1; /// duration.nanos += 1000000000; /// } diff --git a/java/core/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java index ddfd0e5601..2042dc93eb 100644 --- a/java/core/src/main/java/com/google/protobuf/FieldSet.java +++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java @@ -48,8 +48,7 @@ import java.util.Map; * * @author kenton@google.com Kenton Varda */ -final class FieldSet< - FieldDescriptorType extends FieldSet.FieldDescriptorLite> { +final class FieldSet> { /** * Interface for a FieldDescriptor or lite extension descriptor. This prevents FieldSet from * depending on {@link Descriptors.FieldDescriptor}. @@ -72,18 +71,26 @@ final class FieldSet< MessageLite.Builder internalMergeFrom(MessageLite.Builder to, MessageLite from); } - private final SmallSortedMap fields; + private static final int DEFAULT_FIELD_MAP_ARRAY_SIZE = 16; + + private final SmallSortedMap fields; private boolean isImmutable; - private boolean hasLazyField = false; + private boolean hasLazyField; /** Construct a new FieldSet. */ private FieldSet() { - this.fields = SmallSortedMap.newFieldMap(16); + this.fields = SmallSortedMap.newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE); } /** Construct an empty FieldSet. This is only used to initialize DEFAULT_INSTANCE. */ + @SuppressWarnings("unused") private FieldSet(final boolean dummy) { - this.fields = SmallSortedMap.newFieldMap(0); + this(SmallSortedMap.newFieldMap(0)); + makeImmutable(); + } + + private FieldSet(SmallSortedMap fields) { + this.fields = fields; makeImmutable(); } @@ -98,6 +105,11 @@ final class FieldSet< return DEFAULT_INSTANCE; } + /** Construct a new Builder. */ + public static > Builder newBuilder() { + return new Builder(); + } + @SuppressWarnings("rawtypes") private static final FieldSet DEFAULT_INSTANCE = new FieldSet(true); @@ -152,18 +164,16 @@ final class FieldSet< * @return the newly cloned FieldSet */ @Override - public FieldSet clone() { + public FieldSet clone() { // We can't just call fields.clone because List objects in the map // should not be shared. - FieldSet clone = FieldSet.newFieldSet(); + FieldSet clone = FieldSet.newFieldSet(); for (int i = 0; i < fields.getNumArrayEntries(); i++) { - Map.Entry entry = fields.getArrayEntryAt(i); - FieldDescriptorType descriptor = entry.getKey(); - clone.setField(descriptor, entry.getValue()); + Map.Entry entry = fields.getArrayEntryAt(i); + clone.setField(entry.getKey(), entry.getValue()); } - for (Map.Entry entry : fields.getOverflowEntries()) { - FieldDescriptorType descriptor = entry.getKey(); - clone.setField(descriptor, entry.getValue()); + for (Map.Entry entry : fields.getOverflowEntries()) { + clone.setField(entry.getKey(), entry.getValue()); } clone.hasLazyField = hasLazyField; return clone; @@ -179,15 +189,9 @@ final class FieldSet< } /** Get a simple map containing all the fields. */ - public Map getAllFields() { + public Map getAllFields() { if (hasLazyField) { - SmallSortedMap result = SmallSortedMap.newFieldMap(16); - for (int i = 0; i < fields.getNumArrayEntries(); i++) { - cloneFieldEntry(result, fields.getArrayEntryAt(i)); - } - for (Map.Entry entry : fields.getOverflowEntries()) { - cloneFieldEntry(result, entry); - } + SmallSortedMap result = cloneAllFieldsMap(fields, /* copyList */ false); if (fields.isImmutable()) { result.makeImmutable(); } @@ -196,12 +200,26 @@ final class FieldSet< return fields.isImmutable() ? fields : Collections.unmodifiableMap(fields); } - private void cloneFieldEntry( - Map map, Map.Entry entry) { - FieldDescriptorType key = entry.getKey(); + private static > SmallSortedMap cloneAllFieldsMap( + SmallSortedMap fields, boolean copyList) { + SmallSortedMap result = SmallSortedMap.newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE); + for (int i = 0; i < fields.getNumArrayEntries(); i++) { + cloneFieldEntry(result, fields.getArrayEntryAt(i), copyList); + } + for (Map.Entry entry : fields.getOverflowEntries()) { + cloneFieldEntry(result, entry, copyList); + } + return result; + } + + private static > void cloneFieldEntry( + Map map, Map.Entry entry, boolean copyList) { + T key = entry.getKey(); Object value = entry.getValue(); if (value instanceof LazyField) { map.put(key, ((LazyField) value).getValue()); + } else if (copyList && value instanceof List) { + map.put(key, new ArrayList<>((List) value)); } else { map.put(key, value); } @@ -211,9 +229,9 @@ final class FieldSet< * Get an iterator to the field map. This iterator should not be leaked out of the protobuf * library as it is not protected from mutation when fields is not immutable. */ - public Iterator> iterator() { + public Iterator> iterator() { if (hasLazyField) { - return new LazyIterator(fields.entrySet().iterator()); + return new LazyIterator(fields.entrySet().iterator()); } return fields.entrySet().iterator(); } @@ -223,15 +241,15 @@ final class FieldSet< * should not be leaked out of the protobuf library as it is not protected from mutation when * fields is not immutable. */ - Iterator> descendingIterator() { + Iterator> descendingIterator() { if (hasLazyField) { - return new LazyIterator(fields.descendingEntrySet().iterator()); + return new LazyIterator(fields.descendingEntrySet().iterator()); } return fields.descendingEntrySet().iterator(); } /** Useful for implementing {@link Message#hasField(Descriptors.FieldDescriptor)}. */ - public boolean hasField(final FieldDescriptorType descriptor) { + public boolean hasField(final T descriptor) { if (descriptor.isRepeated()) { throw new IllegalArgumentException("hasField() can only be called on non-repeated fields."); } @@ -244,7 +262,7 @@ final class FieldSet< * returns {@code null} if the field is not set; in this case it is up to the caller to fetch the * field's default value. */ - public Object getField(final FieldDescriptorType descriptor) { + public Object getField(final T descriptor) { Object o = fields.get(descriptor); if (o instanceof LazyField) { return ((LazyField) o).getValue(); @@ -256,7 +274,7 @@ final class FieldSet< * Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor,Object)}. */ @SuppressWarnings({"unchecked", "rawtypes"}) - public void setField(final FieldDescriptorType descriptor, Object value) { + public void setField(final T descriptor, Object value) { if (descriptor.isRepeated()) { if (!(value instanceof List)) { throw new IllegalArgumentException( @@ -282,7 +300,7 @@ final class FieldSet< } /** Useful for implementing {@link Message.Builder#clearField(Descriptors.FieldDescriptor)}. */ - public void clearField(final FieldDescriptorType descriptor) { + public void clearField(final T descriptor) { fields.remove(descriptor); if (fields.isEmpty()) { hasLazyField = false; @@ -290,7 +308,7 @@ final class FieldSet< } /** Useful for implementing {@link Message#getRepeatedFieldCount(Descriptors.FieldDescriptor)}. */ - public int getRepeatedFieldCount(final FieldDescriptorType descriptor) { + public int getRepeatedFieldCount(final T descriptor) { if (!descriptor.isRepeated()) { throw new IllegalArgumentException( "getRepeatedField() can only be called on repeated fields."); @@ -305,7 +323,7 @@ final class FieldSet< } /** Useful for implementing {@link Message#getRepeatedField(Descriptors.FieldDescriptor,int)}. */ - public Object getRepeatedField(final FieldDescriptorType descriptor, final int index) { + public Object getRepeatedField(final T descriptor, final int index) { if (!descriptor.isRepeated()) { throw new IllegalArgumentException( "getRepeatedField() can only be called on repeated fields."); @@ -325,8 +343,7 @@ final class FieldSet< * Message.Builder#setRepeatedField(Descriptors.FieldDescriptor,int,Object)}. */ @SuppressWarnings("unchecked") - public void setRepeatedField( - final FieldDescriptorType descriptor, final int index, final Object value) { + public void setRepeatedField(final T descriptor, final int index, final Object value) { if (!descriptor.isRepeated()) { throw new IllegalArgumentException( "getRepeatedField() can only be called on repeated fields."); @@ -346,7 +363,7 @@ final class FieldSet< * Message.Builder#addRepeatedField(Descriptors.FieldDescriptor,Object)}. */ @SuppressWarnings("unchecked") - public void addRepeatedField(final FieldDescriptorType descriptor, final Object value) { + public void addRepeatedField(final T descriptor, final Object value) { if (!descriptor.isRepeated()) { throw new IllegalArgumentException( "addRepeatedField() can only be called on repeated fields."); @@ -373,53 +390,45 @@ final class FieldSet< * * @throws IllegalArgumentException The value is not of the right type. */ - private static void verifyType(final WireFormat.FieldType type, final Object value) { - checkNotNull(value); + private void verifyType(final WireFormat.FieldType type, final Object value) { + if (!isValidType(type, value)) { + // TODO(kenton): When chaining calls to setField(), it can be hard to + // tell from the stack trace which exact call failed, since the whole + // chain is considered one line of code. It would be nice to print + // more information here, e.g. naming the field. We used to do that. + // But we can't now that FieldSet doesn't use descriptors. Maybe this + // isn't a big deal, though, since it would only really apply when using + // reflection and generally people don't chain reflection setters. + throw new IllegalArgumentException( + "Wrong object type used with protocol message reflection."); + } + } - boolean isValid = false; + private static boolean isValidType(final WireFormat.FieldType type, final Object value) { + checkNotNull(value); switch (type.getJavaType()) { case INT: - isValid = value instanceof Integer; - break; + return value instanceof Integer; case LONG: - isValid = value instanceof Long; - break; + return value instanceof Long; case FLOAT: - isValid = value instanceof Float; - break; + return value instanceof Float; case DOUBLE: - isValid = value instanceof Double; - break; + return value instanceof Double; case BOOLEAN: - isValid = value instanceof Boolean; - break; + return value instanceof Boolean; case STRING: - isValid = value instanceof String; - break; + return value instanceof String; case BYTE_STRING: - isValid = value instanceof ByteString || value instanceof byte[]; - break; + return value instanceof ByteString || value instanceof byte[]; case ENUM: // TODO(kenton): Caller must do type checking here, I guess. - isValid = (value instanceof Integer || value instanceof Internal.EnumLite); - break; + return (value instanceof Integer || value instanceof Internal.EnumLite); case MESSAGE: // TODO(kenton): Caller must do type checking here, I guess. - isValid = (value instanceof MessageLite) || (value instanceof LazyField); - break; - } - - if (!isValid) { - // TODO(kenton): When chaining calls to setField(), it can be hard to - // tell from the stack trace which exact call failed, since the whole - // chain is considered one line of code. It would be nice to print - // more information here, e.g. naming the field. We used to do that. - // But we can't now that FieldSet doesn't use descriptors. Maybe this - // isn't a big deal, though, since it would only really apply when using - // reflection and generally people don't chain reflection setters. - throw new IllegalArgumentException( - "Wrong object type used with protocol message reflection."); + return (value instanceof MessageLite) || (value instanceof LazyField); } + return false; } // ================================================================= @@ -436,7 +445,7 @@ final class FieldSet< return false; } } - for (final Map.Entry entry : fields.getOverflowEntries()) { + for (final Map.Entry entry : fields.getOverflowEntries()) { if (!isInitialized(entry)) { return false; } @@ -445,8 +454,9 @@ final class FieldSet< } @SuppressWarnings("unchecked") - private boolean isInitialized(final Map.Entry entry) { - final FieldDescriptorType descriptor = entry.getKey(); + private static > boolean isInitialized( + final Map.Entry entry) { + final T descriptor = entry.getKey(); if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) { if (descriptor.isRepeated()) { for (final MessageLite element : (List) entry.getValue()) { @@ -485,16 +495,16 @@ final class FieldSet< } /** Like {@link Message.Builder#mergeFrom(Message)}, but merges from another {@link FieldSet}. */ - public void mergeFrom(final FieldSet other) { + public void mergeFrom(final FieldSet other) { for (int i = 0; i < other.fields.getNumArrayEntries(); i++) { mergeFromField(other.fields.getArrayEntryAt(i)); } - for (final Map.Entry entry : other.fields.getOverflowEntries()) { + for (final Map.Entry entry : other.fields.getOverflowEntries()) { mergeFromField(entry); } } - private Object cloneIfMutable(Object value) { + private static Object cloneIfMutable(Object value) { if (value instanceof byte[]) { byte[] bytes = (byte[]) value; byte[] copy = new byte[bytes.length]; @@ -506,8 +516,8 @@ final class FieldSet< } @SuppressWarnings({"unchecked", "rawtypes"}) - private void mergeFromField(final Map.Entry entry) { - final FieldDescriptorType descriptor = entry.getKey(); + private void mergeFromField(final Map.Entry entry) { + final T descriptor = entry.getKey(); Object otherValue = entry.getValue(); if (otherValue instanceof LazyField) { otherValue = ((LazyField) otherValue).getValue(); @@ -532,7 +542,6 @@ final class FieldSet< descriptor .internalMergeFrom(((MessageLite) value).toBuilder(), (MessageLite) otherValue) .build(); - fields.put(descriptor, value); } } else { @@ -567,10 +576,10 @@ final class FieldSet< /** See {@link Message#writeTo(CodedOutputStream)}. */ public void writeTo(final CodedOutputStream output) throws IOException { for (int i = 0; i < fields.getNumArrayEntries(); i++) { - final Map.Entry entry = fields.getArrayEntryAt(i); + final Map.Entry entry = fields.getArrayEntryAt(i); writeField(entry.getKey(), entry.getValue(), output); } - for (final Map.Entry entry : fields.getOverflowEntries()) { + for (final Map.Entry entry : fields.getOverflowEntries()) { writeField(entry.getKey(), entry.getValue(), output); } } @@ -580,15 +589,14 @@ final class FieldSet< for (int i = 0; i < fields.getNumArrayEntries(); i++) { writeMessageSetTo(fields.getArrayEntryAt(i), output); } - for (final Map.Entry entry : fields.getOverflowEntries()) { + for (final Map.Entry entry : fields.getOverflowEntries()) { writeMessageSetTo(entry, output); } } - private void writeMessageSetTo( - final Map.Entry entry, final CodedOutputStream output) + private void writeMessageSetTo(final Map.Entry entry, final CodedOutputStream output) throws IOException { - final FieldDescriptorType descriptor = entry.getKey(); + final T descriptor = entry.getKey(); if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE && !descriptor.isRepeated() && !descriptor.isPacked()) { @@ -750,10 +758,10 @@ final class FieldSet< public int getSerializedSize() { int size = 0; for (int i = 0; i < fields.getNumArrayEntries(); i++) { - final Map.Entry entry = fields.getArrayEntryAt(i); + final Map.Entry entry = fields.getArrayEntryAt(i); size += computeFieldSize(entry.getKey(), entry.getValue()); } - for (final Map.Entry entry : fields.getOverflowEntries()) { + for (final Map.Entry entry : fields.getOverflowEntries()) { size += computeFieldSize(entry.getKey(), entry.getValue()); } return size; @@ -765,14 +773,14 @@ final class FieldSet< for (int i = 0; i < fields.getNumArrayEntries(); i++) { size += getMessageSetSerializedSize(fields.getArrayEntryAt(i)); } - for (final Map.Entry entry : fields.getOverflowEntries()) { + for (final Map.Entry entry : fields.getOverflowEntries()) { size += getMessageSetSerializedSize(entry); } return size; } - private int getMessageSetSerializedSize(final Map.Entry entry) { - final FieldDescriptorType descriptor = entry.getKey(); + private int getMessageSetSerializedSize(final Map.Entry entry) { + final T descriptor = entry.getKey(); Object value = entry.getValue(); if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE && !descriptor.isRepeated() @@ -904,4 +912,385 @@ final class FieldSet< return computeElementSize(type, number, value); } } + + /** + * A FieldSet Builder that accept a {@link MessageLite.Builder} as a field value. This is useful + * for implementing methods in {@link MessageLite.Builder}. + */ + static final class Builder> { + + private SmallSortedMap fields; + private boolean hasLazyField; + private boolean isMutable; + private boolean hasNestedBuilders; + + private Builder() { + this(SmallSortedMap.newFieldMap(DEFAULT_FIELD_MAP_ARRAY_SIZE)); + } + + private Builder(SmallSortedMap fields) { + this.fields = fields; + this.isMutable = true; + } + + /** Creates the FieldSet */ + public FieldSet build() { + if (fields.isEmpty()) { + return FieldSet.emptySet(); + } + isMutable = false; + SmallSortedMap fieldsForBuild = fields; + if (hasNestedBuilders) { + // Make a copy of the fields map with all Builders replaced by Message. + fieldsForBuild = cloneAllFieldsMap(fields, /* copyList */ false); + replaceBuilders(fieldsForBuild); + } + FieldSet fieldSet = new FieldSet<>(fieldsForBuild); + fieldSet.hasLazyField = hasLazyField; + return fieldSet; + } + + private static > void replaceBuilders( + SmallSortedMap fieldMap) { + for (int i = 0; i < fieldMap.getNumArrayEntries(); i++) { + replaceBuilders(fieldMap.getArrayEntryAt(i)); + } + for (Map.Entry entry : fieldMap.getOverflowEntries()) { + replaceBuilders(entry); + } + } + + private static > void replaceBuilders( + Map.Entry entry) { + entry.setValue(replaceBuilders(entry.getKey(), entry.getValue())); + } + + private static > Object replaceBuilders( + T descriptor, Object value) { + if (value == null) { + return value; + } + if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) { + if (descriptor.isRepeated()) { + if (!(value instanceof List)) { + throw new IllegalStateException( + "Repeated field should contains a List but actually contains type: " + + value.getClass()); + } + @SuppressWarnings("unchecked") // We just check that value is an instance of List above. + List list = (List) value; + for (int i = 0; i < list.size(); i++) { + Object oldElement = list.get(i); + Object newElement = replaceBuilder(oldElement); + if (newElement != oldElement) { + // If the list contains a Message.Builder, then make a copy of that list and then + // modify the Message.Builder into a Message and return the new list. This way, the + // existing Message.Builder will still be able to modify the inner fields of the + // original FieldSet.Builder. + if (list == value) { + list = new ArrayList<>(list); + } + list.set(i, newElement); + } + } + return list; + } else { + return replaceBuilder(value); + } + } + return value; + } + + private static Object replaceBuilder(Object value) { + return (value instanceof MessageLite.Builder) ? ((MessageLite.Builder) value).build() : value; + } + + /** Returns a new Builder using the fields from {@code fieldSet}. */ + public static > Builder fromFieldSet(FieldSet fieldSet) { + Builder builder = new Builder(cloneAllFieldsMap(fieldSet.fields, /* copyList */ true)); + builder.hasLazyField = fieldSet.hasLazyField; + return builder; + } + + // ================================================================= + + /** Get a simple map containing all the fields. */ + public Map getAllFields() { + if (hasLazyField) { + SmallSortedMap result = cloneAllFieldsMap(fields, /* copyList */ false); + if (fields.isImmutable()) { + result.makeImmutable(); + } else { + replaceBuilders(result); + } + return result; + } + return fields.isImmutable() ? fields : Collections.unmodifiableMap(fields); + } + + /** Useful for implementing {@link Message#hasField(Descriptors.FieldDescriptor)}. */ + public boolean hasField(final T descriptor) { + if (descriptor.isRepeated()) { + throw new IllegalArgumentException("hasField() can only be called on non-repeated fields."); + } + + return fields.get(descriptor) != null; + } + + /** + * Useful for implementing {@link Message#getField(Descriptors.FieldDescriptor)}. This method + * returns {@code null} if the field is not set; in this case it is up to the caller to fetch + * the field's default value. + */ + public Object getField(final T descriptor) { + Object value = getFieldAllowBuilders(descriptor); + return replaceBuilders(descriptor, value); + } + + /** Same as {@link #getField(F)}, but allow a {@link MessageLite.Builder} to be returned. */ + Object getFieldAllowBuilders(final T descriptor) { + Object o = fields.get(descriptor); + if (o instanceof LazyField) { + return ((LazyField) o).getValue(); + } + return o; + } + + private void ensureIsMutable() { + if (!isMutable) { + fields = cloneAllFieldsMap(fields, /* copyList */ true); + isMutable = true; + } + } + + /** + * Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor, + * Object)}. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public void setField(final T descriptor, Object value) { + ensureIsMutable(); + if (descriptor.isRepeated()) { + if (!(value instanceof List)) { + throw new IllegalArgumentException( + "Wrong object type used with protocol message reflection."); + } + + // Wrap the contents in a new list so that the caller cannot change + // the list's contents after setting it. + final List newList = new ArrayList(); + newList.addAll((List) value); + for (final Object element : newList) { + verifyType(descriptor.getLiteType(), element); + hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder; + } + value = newList; + } else { + verifyType(descriptor.getLiteType(), value); + } + + if (value instanceof LazyField) { + hasLazyField = true; + } + hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder; + + fields.put(descriptor, value); + } + + /** Useful for implementing {@link Message.Builder#clearField(Descriptors.FieldDescriptor)}. */ + public void clearField(final T descriptor) { + ensureIsMutable(); + fields.remove(descriptor); + if (fields.isEmpty()) { + hasLazyField = false; + } + } + + /** + * Useful for implementing {@link Message#getRepeatedFieldCount(Descriptors.FieldDescriptor)}. + */ + public int getRepeatedFieldCount(final T descriptor) { + if (!descriptor.isRepeated()) { + throw new IllegalArgumentException( + "getRepeatedField() can only be called on repeated fields."); + } + + final Object value = getField(descriptor); + if (value == null) { + return 0; + } else { + return ((List) value).size(); + } + } + + /** + * Useful for implementing {@link Message#getRepeatedField(Descriptors.FieldDescriptor, int)}. + */ + public Object getRepeatedField(final T descriptor, final int index) { + if (hasNestedBuilders) { + ensureIsMutable(); + } + Object value = getRepeatedFieldAllowBuilders(descriptor, index); + return replaceBuilder(value); + } + + /** + * Same as {@link #getRepeatedField(F, int)}, but allow a {@link MessageLite.Builder} to be + * returned. + */ + Object getRepeatedFieldAllowBuilders(final T descriptor, final int index) { + if (!descriptor.isRepeated()) { + throw new IllegalArgumentException( + "getRepeatedField() can only be called on repeated fields."); + } + + final Object value = getFieldAllowBuilders(descriptor); + + if (value == null) { + throw new IndexOutOfBoundsException(); + } else { + return ((List) value).get(index); + } + } + + /** + * Useful for implementing {@link Message.Builder#setRepeatedField(Descriptors.FieldDescriptor, + * int, Object)}. + */ + @SuppressWarnings("unchecked") + public void setRepeatedField(final T descriptor, final int index, final Object value) { + ensureIsMutable(); + if (!descriptor.isRepeated()) { + throw new IllegalArgumentException( + "getRepeatedField() can only be called on repeated fields."); + } + + hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder; + + final Object list = getField(descriptor); + if (list == null) { + throw new IndexOutOfBoundsException(); + } + + verifyType(descriptor.getLiteType(), value); + ((List) list).set(index, value); + } + + /** + * Useful for implementing {@link Message.Builder#addRepeatedField(Descriptors.FieldDescriptor, + * Object)}. + */ + @SuppressWarnings("unchecked") + public void addRepeatedField(final T descriptor, final Object value) { + ensureIsMutable(); + if (!descriptor.isRepeated()) { + throw new IllegalArgumentException( + "addRepeatedField() can only be called on repeated fields."); + } + + hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder; + + verifyType(descriptor.getLiteType(), value); + + final Object existingValue = getField(descriptor); + List list; + if (existingValue == null) { + list = new ArrayList<>(); + fields.put(descriptor, list); + } else { + list = (List) existingValue; + } + + list.add(value); + } + + /** + * Verifies that the given object is of the correct type to be a valid value for the given + * field. (For repeated fields, this checks if the object is the right type to be one element of + * the field.) + * + * @throws IllegalArgumentException The value is not of the right type. + */ + private static void verifyType(final WireFormat.FieldType type, final Object value) { + if (!FieldSet.isValidType(type, value)) { + // Builder can accept Message.Builder values even though FieldSet will reject. + if (type.getJavaType() == WireFormat.JavaType.MESSAGE + && value instanceof MessageLite.Builder) { + return; + } + throw new IllegalArgumentException( + "Wrong object type used with protocol message reflection."); + } + } + + /** + * See {@link Message#isInitialized()}. Note: Since {@code FieldSet} itself does not have any + * way of knowing about required fields that aren't actually present in the set, it is up to the + * caller to check that all required fields are present. + */ + public boolean isInitialized() { + for (int i = 0; i < fields.getNumArrayEntries(); i++) { + if (!FieldSet.isInitialized(fields.getArrayEntryAt(i))) { + return false; + } + } + for (final Map.Entry entry : fields.getOverflowEntries()) { + if (!FieldSet.isInitialized(entry)) { + return false; + } + } + return true; + } + + /** + * Like {@link Message.Builder#mergeFrom(Message)}, but merges from another {@link FieldSet}. + */ + public void mergeFrom(final FieldSet other) { + ensureIsMutable(); + for (int i = 0; i < other.fields.getNumArrayEntries(); i++) { + mergeFromField(other.fields.getArrayEntryAt(i)); + } + for (final Map.Entry entry : other.fields.getOverflowEntries()) { + mergeFromField(entry); + } + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private void mergeFromField(final Map.Entry entry) { + final T descriptor = entry.getKey(); + Object otherValue = entry.getValue(); + if (otherValue instanceof LazyField) { + otherValue = ((LazyField) otherValue).getValue(); + } + + if (descriptor.isRepeated()) { + Object value = getField(descriptor); + if (value == null) { + value = new ArrayList(); + } + for (Object element : (List) otherValue) { + ((List) value).add(FieldSet.cloneIfMutable(element)); + } + fields.put(descriptor, value); + } else if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) { + Object value = getField(descriptor); + if (value == null) { + fields.put(descriptor, FieldSet.cloneIfMutable(otherValue)); + } else { + // Merge the messages. + if (value instanceof MessageLite.Builder) { + descriptor.internalMergeFrom((MessageLite.Builder) value, (MessageLite) otherValue); + } else { + value = + descriptor + .internalMergeFrom(((MessageLite) value).toBuilder(), (MessageLite) otherValue) + .build(); + fields.put(descriptor, value); + } + } + } else { + fields.put(descriptor, cloneIfMutable(otherValue)); + } + } + } } 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 bea008c85c..ae5e56c5fc 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -1363,7 +1363,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage extends Builder implements ExtendableMessageOrBuilder { - private FieldSet extensions = FieldSet.emptySet(); + private FieldSet.Builder extensions; protected ExtendableBuilder() {} @@ -1374,18 +1374,18 @@ public abstract class GeneratedMessageV3 extends AbstractMessage // For immutable message conversion. void internalSetExtensionSet(FieldSet extensions) { - this.extensions = extensions; + this.extensions = FieldSet.Builder.fromFieldSet(extensions); } @Override public BuilderType clear() { - extensions = FieldSet.emptySet(); + extensions = null; return super.clear(); } private void ensureExtensionsIsMutable() { - if (extensions.isImmutable()) { - extensions = extensions.clone(); + if (extensions == null) { + extensions = FieldSet.newBuilder(); } } @@ -1408,7 +1408,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage Extension extension = checkNotLite(extensionLite); verifyExtensionContainingType(extension); - return extensions.hasField(extension.getDescriptor()); + return extensions == null ? false : extensions.hasField(extension.getDescriptor()); } /** Get the number of elements in a repeated extension. */ @@ -1419,7 +1419,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage verifyExtensionContainingType(extension); final FieldDescriptor descriptor = extension.getDescriptor(); - return extensions.getRepeatedFieldCount(descriptor); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(descriptor); } /** Get the value of an extension. */ @@ -1429,7 +1429,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage verifyExtensionContainingType(extension); FieldDescriptor descriptor = extension.getDescriptor(); - final Object value = extensions.getField(descriptor); + final Object value = extensions == null ? null : extensions.getField(descriptor); if (value == null) { if (descriptor.isRepeated()) { return (Type) Collections.emptyList(); @@ -1453,8 +1453,11 @@ public abstract class GeneratedMessageV3 extends AbstractMessage verifyExtensionContainingType(extension); FieldDescriptor descriptor = extension.getDescriptor(); - return (Type) extension.singularFromReflectionType( - extensions.getRepeatedField(descriptor, index)); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } + return (Type) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); } /** Set the value of an extension. */ @@ -1605,7 +1608,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage /** Called by subclasses to check if all extensions are initialized. */ protected boolean extensionsAreInitialized() { - return extensions.isInitialized(); + return extensions == null ? true : extensions.isInitialized(); } /** @@ -1613,8 +1616,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage * building the message. */ private FieldSet buildExtensions() { - extensions.makeImmutable(); - return extensions; + return extensions == null + ? (FieldSet) FieldSet.emptySet() + : extensions.build(); } @Override @@ -1628,7 +1632,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage @Override public Map getAllFields() { final Map result = super.getAllFieldsMutable(); - result.putAll(extensions.getAllFields()); + if (extensions != null) { + result.putAll(extensions.getAllFields()); + } return Collections.unmodifiableMap(result); } @@ -1636,7 +1642,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage public Object getField(final FieldDescriptor field) { if (field.isExtension()) { verifyContainingType(field); - final Object value = extensions.getField(field); + final Object value = extensions == null ? null : extensions.getField(field); if (value == null) { if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { // Lacking an ExtensionRegistry, we have no way to determine the @@ -1653,11 +1659,44 @@ public abstract class GeneratedMessageV3 extends AbstractMessage } } + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on a non-Message type."); + } + ensureExtensionsIsMutable(); + final Object value = extensions.getFieldAllowBuilders(field); + if (value == null) { + Message.Builder builder = DynamicMessage.newBuilder(field.getMessageType()); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + } else { + return super.getFieldBuilder(field); + } + } + @Override public int getRepeatedFieldCount(final FieldDescriptor field) { if (field.isExtension()) { verifyContainingType(field); - return extensions.getRepeatedFieldCount(field); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(field); } else { return super.getRepeatedFieldCount(field); } @@ -1668,17 +1707,46 @@ public abstract class GeneratedMessageV3 extends AbstractMessage final int index) { if (field.isExtension()) { verifyContainingType(field); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } return extensions.getRepeatedField(field, index); } else { return super.getRepeatedField(field, index); } } + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + final Object value = extensions.getRepeatedFieldAllowBuilders(field, index); + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setRepeatedField(field, index, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } else { + return super.getRepeatedFieldBuilder(field, index); + } + } + @Override public boolean hasField(final FieldDescriptor field) { if (field.isExtension()) { verifyContainingType(field); - return extensions.hasField(field); + return extensions == null ? false : extensions.hasField(field); } else { return super.hasField(field); } @@ -1749,9 +1817,11 @@ public abstract class GeneratedMessageV3 extends AbstractMessage } protected final void mergeExtensionFields(final ExtendableMessage other) { - ensureExtensionsIsMutable(); - extensions.mergeFrom(other.extensions); - onChanged(); + if (other.extensions != null) { + ensureExtensionsIsMutable(); + extensions.mergeFrom(other.extensions); + onChanged(); + } } private void verifyContainingType(final FieldDescriptor field) { diff --git a/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java index 175b1ddf46..33e4bd5e35 100644 --- a/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java @@ -32,9 +32,10 @@ package com.google.protobuf; import com.google.protobuf.Internal.ProtobufList; import java.util.Arrays; +import java.util.RandomAccess; /** Implements {@link ProtobufList} for non-primitive and {@link String} types. */ -final class ProtobufArrayList extends AbstractProtobufList { +final class ProtobufArrayList extends AbstractProtobufList implements RandomAccess { private static final ProtobufArrayList EMPTY_LIST = new ProtobufArrayList(new Object[0], 0); diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java index 0385b2425a..f3f1011a58 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java @@ -113,8 +113,8 @@ public final class TextFormat { } /** - * Generates a human readable form of the field, useful for debugging and other purposes, with no - * newline characters. + * Generates a human readable form of the field, useful for debugging and other purposes, with + * no newline characters. * * @deprecated Use {@code printer().shortDebugString(FieldDescriptor, Object)} */ @@ -122,10 +122,10 @@ public final class TextFormat { public static String shortDebugString(final FieldDescriptor field, final Object value) { return printer().shortDebugString(field, value); } - + // /** - * Generates a human readable form of the unknown fields, useful for debugging and other purposes, - * with no newline characters. + * Generates a human readable form of the unknown fields, useful for debugging and other + * purposes, with no newline characters. * * @deprecated Use {@code printer().shortDebugString(UnknownFieldSet)} */ @@ -166,8 +166,8 @@ public final class TextFormat { } /** - * Same as {@code printToString()}, except that non-ASCII characters in string type fields are not - * escaped in backslash+octals. + * Same as {@code printToString()}, except that non-ASCII characters in string type fields are + * not escaped in backslash+octals. * * @deprecated Use {@code printer().escapingNonAscii(false).printToString(UnknownFieldSet)} */ @@ -175,20 +175,21 @@ public final class TextFormat { public static String printToUnicodeString(final UnknownFieldSet fields) { return printer().escapingNonAscii(false).printToString(fields); } - + // /** @deprecated Use {@code printer().printField(FieldDescriptor, Object, Appendable)} */ @Deprecated public static void printField( - final FieldDescriptor field, final Object value, final Appendable output) throws IOException { + final FieldDescriptor field, final Object value, final Appendable output) + throws IOException { printer().printField(field, value, output); } - + // /** @deprecated Use {@code printer().printFieldToString(FieldDescriptor, Object)} */ @Deprecated public static String printFieldToString(final FieldDescriptor field, final Object value) { return printer().printFieldToString(field, value); } - + // /** * Outputs a unicode textual representation of the value of given field value. * @@ -205,7 +206,8 @@ public final class TextFormat { */ @Deprecated public static void printUnicodeFieldValue( - final FieldDescriptor field, final Object value, final Appendable output) throws IOException { + final FieldDescriptor field, final Object value, final Appendable output) + throws IOException { printer().escapingNonAscii(false).printFieldValue(field, value, output); } @@ -285,13 +287,16 @@ public final class TextFormat { public static final class Printer { // Printer instance which escapes non-ASCII characters. - private static final Printer DEFAULT = new Printer(true); + private static final Printer DEFAULT = new Printer(true, TypeRegistry.getEmptyTypeRegistry()); /** Whether to escape non ASCII characters with backslash and octal. */ private final boolean escapeNonAscii; - private Printer(boolean escapeNonAscii) { + private final TypeRegistry typeRegistry; + + private Printer(boolean escapeNonAscii, TypeRegistry typeRegistry) { this.escapeNonAscii = escapeNonAscii; + this.typeRegistry = typeRegistry; } /** @@ -304,7 +309,20 @@ public final class TextFormat { * with the escape mode set to the given parameter. */ public Printer escapingNonAscii(boolean escapeNonAscii) { - return new Printer(escapeNonAscii); + return new Printer(escapeNonAscii, typeRegistry); + } + + /** + * Creates a new {@link Printer} using the given typeRegistry. The new Printer clones all other + * configurations from the current {@link Printer}. + * + * @throws IllegalArgumentException if a registry is already set. + */ + public Printer usingTypeRegistry(TypeRegistry typeRegistry) { + if (this.typeRegistry != TypeRegistry.getEmptyTypeRegistry()) { + throw new IllegalArgumentException("Only one typeRegistry is allowed."); + } + return new Printer(escapeNonAscii, typeRegistry); } /** @@ -323,9 +341,66 @@ public final class TextFormat { private void print(final MessageOrBuilder message, final TextGenerator generator) throws IOException { + if (message.getDescriptorForType().getFullName().equals("google.protobuf.Any") + && printAny(message, generator)) { + return; + } printMessage(message, generator); } + /** + * Attempt to print the 'google.protobuf.Any' message in a human-friendly format. Returns false + * if the message isn't a valid 'google.protobuf.Any' message (in which case the message should + * be rendered just like a regular message to help debugging). + */ + private boolean printAny(final MessageOrBuilder message, final TextGenerator generator) + throws IOException { + Descriptor messageType = message.getDescriptorForType(); + FieldDescriptor typeUrlField = messageType.findFieldByNumber(1); + FieldDescriptor valueField = messageType.findFieldByNumber(2); + if (typeUrlField == null + || typeUrlField.getType() != FieldDescriptor.Type.STRING + || valueField == null + || valueField.getType() != FieldDescriptor.Type.BYTES) { + // The message may look like an Any but isn't actually an Any message (might happen if the + // user tries to use DynamicMessage to construct an Any from incomplete Descriptor). + return false; + } + String typeUrl = (String) message.getField(typeUrlField); + // If type_url is not set, we will not be able to decode the content of the value, so just + // print out the Any like a regular message. + if (typeUrl.isEmpty()) { + return false; + } + Object value = message.getField(valueField); + + Message.Builder contentBuilder = null; + try { + Descriptor contentType = typeRegistry.getDescriptorForTypeUrl(typeUrl); + if (contentType == null) { + return false; + } + contentBuilder = DynamicMessage.getDefaultInstance(contentType).newBuilderForType(); + contentBuilder.mergeFrom((ByteString) value); + } catch (InvalidProtocolBufferException e) { + // The value of Any is malformed. We cannot print it out nicely, so fallback to printing out + // the type_url and value as bytes. Note that we fail open here to be consistent with + // text_format.cc, and also to allow a way for users to inspect the content of the broken + // message. + return false; + } + generator.print("["); + generator.print(typeUrl); + generator.print("] {"); + generator.eol(); + generator.indent(); + print(contentBuilder, generator); + generator.outdent(); + generator.print("}"); + generator.eol(); + return true; + } + public String printFieldToString(final FieldDescriptor field, final Object value) { try { final StringBuilder text = new StringBuilder(); @@ -1382,6 +1457,7 @@ public final class TextFormat { FORBID_SINGULAR_OVERWRITES } + private final TypeRegistry typeRegistry; private final boolean allowUnknownFields; private final boolean allowUnknownEnumValues; private final boolean allowUnknownExtensions; @@ -1389,11 +1465,13 @@ public final class TextFormat { private TextFormatParseInfoTree.Builder parseInfoTreeBuilder; private Parser( + TypeRegistry typeRegistry, boolean allowUnknownFields, boolean allowUnknownEnumValues, boolean allowUnknownExtensions, SingularOverwritePolicy singularOverwritePolicy, TextFormatParseInfoTree.Builder parseInfoTreeBuilder) { + this.typeRegistry = typeRegistry; this.allowUnknownFields = allowUnknownFields; this.allowUnknownEnumValues = allowUnknownEnumValues; this.allowUnknownExtensions = allowUnknownExtensions; @@ -1414,6 +1492,18 @@ public final class TextFormat { private SingularOverwritePolicy singularOverwritePolicy = SingularOverwritePolicy.ALLOW_SINGULAR_OVERWRITES; private TextFormatParseInfoTree.Builder parseInfoTreeBuilder = null; + private TypeRegistry typeRegistry = TypeRegistry.getEmptyTypeRegistry(); + + /** + * Sets the TypeRegistry for resolving Any. If this is not set, TextFormat will not be able to + * parse Any unless Any is write as bytes. + * + * @throws IllegalArgumentException if a registry is already set. + */ + public Builder setTypeRegistry(TypeRegistry typeRegistry) { + this.typeRegistry = typeRegistry; + return this; + } /** * Set whether this parser will allow unknown fields. By default, an exception is thrown if an @@ -1452,6 +1542,7 @@ public final class TextFormat { public Parser build() { return new Parser( + typeRegistry, allowUnknownFields, allowUnknownEnumValues, allowUnknownExtensions, @@ -1834,6 +1925,14 @@ public final class TextFormat { endToken = "}"; } + // Try to parse human readable format of Any in the form: [type_url]: { ... } + if (field.getMessageType().getFullName().equals("google.protobuf.Any") + && tokenizer.tryConsume("[")) { + value = + consumeAnyFieldValue( + tokenizer, extensionRegistry, field, parseTreeBuilder, unknownFields); + tokenizer.consume(endToken); + } else { Message defaultInstance = (extension == null) ? null : extension.defaultInstance; MessageReflection.MergeTarget subField = target.newMergeTargetForField(field, defaultInstance); @@ -1846,6 +1945,8 @@ public final class TextFormat { } value = subField.finish(); + } + } else { switch (field.getType()) { case INT32: @@ -1951,6 +2052,71 @@ public final class TextFormat { } } + private Object consumeAnyFieldValue( + final Tokenizer tokenizer, + final ExtensionRegistry extensionRegistry, + final FieldDescriptor field, + final TextFormatParseInfoTree.Builder parseTreeBuilder, + List unknownFields) + throws ParseException { + // Try to parse human readable format of Any in the form: [type_url]: { ... } + StringBuilder typeUrlBuilder = new StringBuilder(); + // Parse the type_url inside []. + while (true) { + typeUrlBuilder.append(tokenizer.consumeIdentifier()); + if (tokenizer.tryConsume("]")) { + break; + } + if (tokenizer.tryConsume("/")) { + typeUrlBuilder.append("/"); + } else if (tokenizer.tryConsume(".")) { + typeUrlBuilder.append("."); + } else { + throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL."); + } + } + tokenizer.tryConsume(":"); + final String anyEndToken; + if (tokenizer.tryConsume("<")) { + anyEndToken = ">"; + } else { + tokenizer.consume("{"); + anyEndToken = "}"; + } + String typeUrl = typeUrlBuilder.toString(); + Descriptor contentType = null; + try { + contentType = typeRegistry.getDescriptorForTypeUrl(typeUrl); + } catch (InvalidProtocolBufferException e) { + throw tokenizer.parseException("Invalid valid type URL. Found: " + typeUrl); + } + if (contentType == null) { + throw tokenizer.parseException( + "Unable to parse Any of type: " + + typeUrl + + ". Please make sure that the TypeRegistry contains the descriptors for the given" + + " types."); + } + Message.Builder contentBuilder = + DynamicMessage.getDefaultInstance(contentType).newBuilderForType(); + MessageReflection.BuilderAdapter contentTarget = + new MessageReflection.BuilderAdapter(contentBuilder); + while (!tokenizer.tryConsume(anyEndToken)) { + mergeField(tokenizer, extensionRegistry, contentTarget, parseTreeBuilder, unknownFields); + } + + // Serialize the content and put it back into an Any. Note that we can't depend on Any here + // because of a cyclic dependency (java_proto_library for any_java_proto depends on the + // protobuf_impl), so we need to construct the Any using proto reflection. + Descriptor anyDescriptor = field.getMessageType(); + Message.Builder anyBuilder = + DynamicMessage.getDefaultInstance(anyDescriptor).newBuilderForType(); + anyBuilder.setField(anyDescriptor.findFieldByName("type_url"), typeUrlBuilder.toString()); + anyBuilder.setField( + anyDescriptor.findFieldByName("value"), contentBuilder.build().toByteString()); + + return anyBuilder.build(); + } /** Skips the next field including the field's name and value. */ private void skipField(Tokenizer tokenizer) throws ParseException { diff --git a/java/core/src/main/java/com/google/protobuf/TypeRegistry.java b/java/core/src/main/java/com/google/protobuf/TypeRegistry.java new file mode 100755 index 0000000000..47d798bfe6 --- /dev/null +++ b/java/core/src/main/java/com/google/protobuf/TypeRegistry.java @@ -0,0 +1,160 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf; + +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.FileDescriptor; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; + +/** + * A TypeRegistry is used to resolve Any messages. You must provide a TypeRegistry containing all + * message types used in Any message fields. + */ +public class TypeRegistry { + private static final Logger logger = Logger.getLogger(TypeRegistry.class.getName()); + + private static class EmptyTypeRegistryHolder { + private static final TypeRegistry EMPTY = + new TypeRegistry(Collections.emptyMap()); + } + + public static TypeRegistry getEmptyTypeRegistry() { + return EmptyTypeRegistryHolder.EMPTY; + } + + + public static Builder newBuilder() { + return new Builder(); + } + + /** + * Find a type by its full name. Returns null if it cannot be found in this {@link TypeRegistry}. + */ + public Descriptor find(String name) { + return types.get(name); + } + + /** + * Find a type by its typeUrl. Returns null if it cannot be found in this {@link TypeRegistry}. + */ + /* @Nullable */ + public final Descriptor getDescriptorForTypeUrl(String typeUrl) + throws InvalidProtocolBufferException { + return find(getTypeName(typeUrl)); + } + + private final Map types; + + TypeRegistry(Map types) { + this.types = types; + } + + private static String getTypeName(String typeUrl) throws InvalidProtocolBufferException { + String[] parts = typeUrl.split("/"); + if (parts.length == 1) { + throw new InvalidProtocolBufferException("Invalid type url found: " + typeUrl); + } + return parts[parts.length - 1]; + } + + /** A Builder is used to build {@link TypeRegistry}. */ + public static final class Builder { + private Builder() {} + + /** + * Adds a message type and all types defined in the same .proto file as well as all transitively + * imported .proto files to this {@link Builder}. + */ + public Builder add(Descriptor messageType) { + if (types == null) { + throw new IllegalStateException("A TypeRegistry.Builder can only be used once."); + } + addFile(messageType.getFile()); + return this; + } + + /** + * Adds message types and all types defined in the same .proto file as well as all transitively + * imported .proto files to this {@link Builder}. + */ + public Builder add(Iterable messageTypes) { + if (types == null) { + throw new IllegalStateException("A TypeRegistry.Builder can only be used once."); + } + for (Descriptor type : messageTypes) { + addFile(type.getFile()); + } + return this; + } + + /** Builds a {@link TypeRegistry}. This method can only be called once for one Builder. */ + public TypeRegistry build() { + TypeRegistry result = new TypeRegistry(types); + // Make sure the built {@link TypeRegistry} is immutable. + types = null; + return result; + } + + private void addFile(FileDescriptor file) { + // Skip the file if it's already added. + if (!files.add(file.getFullName())) { + return; + } + for (FileDescriptor dependency : file.getDependencies()) { + addFile(dependency); + } + for (Descriptor message : file.getMessageTypes()) { + addMessage(message); + } + } + + private void addMessage(Descriptor message) { + for (Descriptor nestedType : message.getNestedTypes()) { + addMessage(nestedType); + } + + if (types.containsKey(message.getFullName())) { + logger.warning("Type " + message.getFullName() + " is added multiple times."); + return; + } + + types.put(message.getFullName(), message); + } + + private final Set files = new HashSet<>(); + private Map types = new HashMap<>(); + } +} diff --git a/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java index 12bba6b3be..5a43bca0e9 100644 --- a/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java +++ b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java @@ -115,6 +115,160 @@ public class GeneratedMessageTest extends TestCase { GeneratedMessageV3.setAlwaysUseFieldBuildersForTesting(false); } + public void testGetFieldBuilderForExtensionField() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + Message.Builder fieldBuilder = + builder.getFieldBuilder(UnittestProto.optionalNestedMessageExtension.getDescriptor()); + int expected = 7432; + FieldDescriptor field = + NestedMessage.getDescriptor().findFieldByNumber(NestedMessage.BB_FIELD_NUMBER); + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + + // fieldBuilder still updates the builder after builder build() has been called. + expected += 100; + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + } + + public void testGetFieldBuilderWithExistingMessage() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + builder.setExtension( + UnittestProto.optionalNestedMessageExtension, + NestedMessage.newBuilder().setBb(123).build()); + Message.Builder fieldBuilder = + builder.getFieldBuilder(UnittestProto.optionalNestedMessageExtension.getDescriptor()); + int expected = 7432; + FieldDescriptor field = + NestedMessage.getDescriptor().findFieldByNumber(NestedMessage.BB_FIELD_NUMBER); + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + + // fieldBuilder still updates the builder after builder build() has been called. + expected += 100; + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + } + + public void testGetFieldBuilderWithExistingBuilder() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + NestedMessage.Builder nestedMessageBuilder = NestedMessage.newBuilder().setBb(123); + builder.setField( + UnittestProto.optionalNestedMessageExtension.getDescriptor(), nestedMessageBuilder); + Message.Builder fieldBuilder = + builder.getFieldBuilder(UnittestProto.optionalNestedMessageExtension.getDescriptor()); + int expected = 7432; + FieldDescriptor field = + NestedMessage.getDescriptor().findFieldByNumber(NestedMessage.BB_FIELD_NUMBER); + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + + // Existing nestedMessageBuilder will also update builder. + expected += 100; + nestedMessageBuilder.setBb(expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + + // fieldBuilder still updates the builder. + expected += 100; + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.optionalNestedMessageExtension).getBb()); + } + + public void testGetRepeatedFieldBuilderForExtensionField() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + builder.addExtension( + UnittestProto.repeatedNestedMessageExtension, + NestedMessage.newBuilder().setBb(123).build()); + Message.Builder fieldBuilder = + builder.getRepeatedFieldBuilder( + UnittestProto.repeatedNestedMessageExtension.getDescriptor(), 0); + int expected = 7432; + FieldDescriptor field = + NestedMessage.getDescriptor().findFieldByNumber(NestedMessage.BB_FIELD_NUMBER); + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.repeatedNestedMessageExtension, 0).getBb()); + + // fieldBuilder still updates the builder after builder build() has been called. + expected += 100; + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.repeatedNestedMessageExtension, 0).getBb()); + } + + public void testGetRepeatedFieldBuilderForExistingBuilder() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + NestedMessage.Builder nestedMessageBuilder = NestedMessage.newBuilder().setBb(123); + builder.addRepeatedField( + UnittestProto.repeatedNestedMessageExtension.getDescriptor(), nestedMessageBuilder); + Message.Builder fieldBuilder = + builder.getRepeatedFieldBuilder( + UnittestProto.repeatedNestedMessageExtension.getDescriptor(), 0); + int expected = 7432; + FieldDescriptor field = + NestedMessage.getDescriptor().findFieldByNumber(NestedMessage.BB_FIELD_NUMBER); + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.repeatedNestedMessageExtension, 0).getBb()); + + // Existing nestedMessageBuilder will also update builder. + expected += 100; + nestedMessageBuilder.setBb(expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.repeatedNestedMessageExtension, 0).getBb()); + + // fieldBuilder still updates the builder. + expected += 100; + fieldBuilder.setField(field, expected); + assertEquals( + expected, + builder.build().getExtension(UnittestProto.repeatedNestedMessageExtension, 0).getBb()); + } + + public void testGetExtensionFieldOutOfBound() { + TestAllExtensions.Builder builder = TestAllExtensions.newBuilder(); + try { + builder.getRepeatedField(UnittestProto.repeatedNestedMessageExtension.getDescriptor(), 0); + fail("Expected IndexOutOfBoundsException to be thrown"); + } catch (IndexOutOfBoundsException expected) { + } + try { + builder.getExtension(UnittestProto.repeatedNestedMessageExtension, 0); + fail("Expected IndexOutOfBoundsException to be thrown"); + } catch (IndexOutOfBoundsException expected) { + } + TestAllExtensions extensionsMessage = builder.build(); + try { + extensionsMessage.getRepeatedField( + UnittestProto.repeatedNestedMessageExtension.getDescriptor(), 0); + fail("Expected IndexOutOfBoundsException to be thrown"); + } catch (IndexOutOfBoundsException expected) { + } + try { + extensionsMessage.getExtension(UnittestProto.repeatedNestedMessageExtension, 0); + fail("Expected IndexOutOfBoundsException to be thrown"); + } catch (IndexOutOfBoundsException expected) { + } + } + public void testDefaultInstance() throws Exception { assertSame( TestAllTypes.getDefaultInstance(), diff --git a/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java b/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java index 7bfeaf17c4..1af3f93c86 100644 --- a/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java +++ b/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java @@ -30,6 +30,7 @@ package com.google.protobuf; +import protobuf_unittest.Engine; import protobuf_unittest.Vehicle; import protobuf_unittest.Wheel; import java.util.ArrayList; @@ -64,7 +65,7 @@ public class NestedBuildersTest extends TestCase { for (int i = 0; i < 4; i++) { vehicleBuilder.getWheelBuilder(i).setRadius(5).setWidth(i + 10); } - vehicleBuilder.getEngineBuilder().setLiters(20); + Engine.Builder engineBuilder = vehicleBuilder.getEngineBuilder().setLiters(20); vehicle = vehicleBuilder.build(); for (int i = 0; i < 4; i++) { @@ -74,6 +75,9 @@ public class NestedBuildersTest extends TestCase { } assertEquals(20, vehicle.getEngine().getLiters()); assertTrue(vehicle.hasEngine()); + + engineBuilder.setLiters(50); + assertEquals(50, vehicleBuilder.getEngine().getLiters()); } public void testMessagesAreCached() { diff --git a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java index 4421c0cc4b..dd0e8c847c 100644 --- a/java/core/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java @@ -33,9 +33,14 @@ package com.google.protobuf; import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED; import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED; +import com.google.protobuf.DescriptorProtos.DescriptorProto; +import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; +import com.google.protobuf.DescriptorProtos.FileDescriptorProto; import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.TextFormat.Parser.SingularOverwritePolicy; +import any_test.AnyTestProto.TestAny; import map_test.MapTestProto.TestMap; import protobuf_unittest.UnittestMset.TestMessageSetExtension1; import protobuf_unittest.UnittestMset.TestMessageSetExtension2; @@ -48,6 +53,7 @@ import protobuf_unittest.UnittestProto.TestOneof2; import protobuf_unittest.UnittestProto.TestRequired; import proto2_wireformat_unittest.UnittestMsetWireFormat.TestMessageSet; import java.io.StringReader; +import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import junit.framework.TestCase; @@ -506,6 +512,191 @@ public class TextFormatTest extends TestCase { assertEquals(2, builder.getOptionalInt64()); } + public void testPrintAny_customBuiltTypeRegistry() throws Exception { + TestAny testAny = + TestAny.newBuilder() + .setValue( + Any.newBuilder() + .setTypeUrl("type.googleapis.com/" + TestAllTypes.getDescriptor().getFullName()) + .setValue( + TestAllTypes.newBuilder().setOptionalInt32(12345).build().toByteString()) + .build()) + .build(); + String actual = + TextFormat.printer() + .usingTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .printToString(testAny); + String expected = + "value {\n" + + " [type.googleapis.com/protobuf_unittest.TestAllTypes] {\n" + + " optional_int32: 12345\n" + + " }\n" + + "}\n"; + assertEquals(expected, actual); + } + + private static Descriptor createDescriptorForAny(FieldDescriptorProto... fields) + throws Exception { + FileDescriptor fileDescriptor = + FileDescriptor.buildFrom( + FileDescriptorProto.newBuilder() + .setName("any.proto") + .setPackage("google.protobuf") + .setSyntax("proto3") + .addMessageType( + DescriptorProto.newBuilder() + .setName("Any") + .addAllField(Arrays.asList(fields))) + .build(), + new FileDescriptor[0]); + return fileDescriptor.getMessageTypes().get(0); + } + + public void testPrintAny_anyWithDynamicMessage() throws Exception { + Descriptor descriptor = + createDescriptorForAny( + FieldDescriptorProto.newBuilder() + .setName("type_url") + .setNumber(1) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_STRING) + .build(), + FieldDescriptorProto.newBuilder() + .setName("value") + .setNumber(2) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_BYTES) + .build()); + DynamicMessage testAny = + DynamicMessage.newBuilder(descriptor) + .setField( + descriptor.findFieldByNumber(1), + "type.googleapis.com/" + TestAllTypes.getDescriptor().getFullName()) + .setField( + descriptor.findFieldByNumber(2), + TestAllTypes.newBuilder().setOptionalInt32(12345).build().toByteString()) + .build(); + String actual = + TextFormat.printer() + .usingTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .printToString(testAny); + String expected = + "[type.googleapis.com/protobuf_unittest.TestAllTypes] {\n" + + " optional_int32: 12345\n" + + "}\n"; + assertEquals(expected, actual); + } + + public void testPrintAny_anyFromWithNoValueField() throws Exception { + Descriptor descriptor = + createDescriptorForAny( + FieldDescriptorProto.newBuilder() + .setName("type_url") + .setNumber(1) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_STRING) + .build()); + DynamicMessage testAny = + DynamicMessage.newBuilder(descriptor) + .setField( + descriptor.findFieldByNumber(1), + "type.googleapis.com/" + TestAllTypes.getDescriptor().getFullName()) + .build(); + String actual = + TextFormat.printer() + .usingTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .printToString(testAny); + String expected = "type_url: \"type.googleapis.com/protobuf_unittest.TestAllTypes\"\n"; + assertEquals(expected, actual); + } + + public void testPrintAny_anyFromWithNoTypeUrlField() throws Exception { + Descriptor descriptor = + createDescriptorForAny( + FieldDescriptorProto.newBuilder() + .setName("value") + .setNumber(2) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_BYTES) + .build()); + DynamicMessage testAny = + DynamicMessage.newBuilder(descriptor) + .setField( + descriptor.findFieldByNumber(2), + TestAllTypes.newBuilder().setOptionalInt32(12345).build().toByteString()) + .build(); + String actual = + TextFormat.printer() + .usingTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .printToString(testAny); + String expected = "value: \"\\b\\271`\"\n"; + assertEquals(expected, actual); + } + + public void testPrintAny_anyWithInvalidFieldType() throws Exception { + Descriptor descriptor = + createDescriptorForAny( + FieldDescriptorProto.newBuilder() + .setName("type_url") + .setNumber(1) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_STRING) + .build(), + FieldDescriptorProto.newBuilder() + .setName("value") + .setNumber(2) + .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL) + .setType(FieldDescriptorProto.Type.TYPE_STRING) + .build()); + DynamicMessage testAny = + DynamicMessage.newBuilder(descriptor) + .setField( + descriptor.findFieldByNumber(1), + "type.googleapis.com/" + TestAllTypes.getDescriptor().getFullName()) + .setField(descriptor.findFieldByNumber(2), "test") + .build(); + String actual = + TextFormat.printer() + .usingTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .printToString(testAny); + String expected = + "type_url: \"type.googleapis.com/protobuf_unittest.TestAllTypes\"\n" + "value: \"test\"\n"; + assertEquals(expected, actual); + } + + + public void testMergeAny_customBuiltTypeRegistry() throws Exception { + TestAny.Builder builder = TestAny.newBuilder(); + TextFormat.Parser.newBuilder() + .setTypeRegistry(TypeRegistry.newBuilder().add(TestAllTypes.getDescriptor()).build()) + .build() + .merge( + "value: {\n" + + "[type.googleapis.com/protobuf_unittest.TestAllTypes] {\n" + + "optional_int32: 12345\n" + + "optional_nested_message {\n" + + " bb: 123\n" + + "}\n" + + "}\n" + + "}", + builder); + assertEquals( + TestAny.newBuilder() + .setValue( + Any.newBuilder() + .setTypeUrl("type.googleapis.com/" + TestAllTypes.getDescriptor().getFullName()) + .setValue( + TestAllTypes.newBuilder() + .setOptionalInt32(12345) + .setOptionalNestedMessage( + TestAllTypes.NestedMessage.newBuilder().setBb(123)) + .build() + .toByteString()) + .build()) + .build(), + builder.build()); + } + private void assertParseError(String error, String text) { // Test merge(). diff --git a/java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java b/java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java new file mode 100755 index 0000000000..0cd9677726 --- /dev/null +++ b/java/core/src/test/java/com/google/protobuf/TypeRegistryTest.java @@ -0,0 +1,70 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + +import com.google.protobuf.Descriptors.Descriptor; +import protobuf_unittest.UnittestProto; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class TypeRegistryTest { + + @Test + public void findDescriptorByFullName() throws Exception { + Descriptor descriptor = UnittestProto.TestAllTypes.getDescriptor(); + assertNull(TypeRegistry.getEmptyTypeRegistry().find(descriptor.getFullName())); + + assertSame( + descriptor, + TypeRegistry.newBuilder().add(descriptor).build().find(descriptor.getFullName())); + } + + @Test + public void findDescriptorByTypeUrl() throws Exception { + Descriptor descriptor = UnittestProto.TestAllTypes.getDescriptor(); + assertNull( + TypeRegistry.getEmptyTypeRegistry() + .getDescriptorForTypeUrl("type.googleapis.com/" + descriptor.getFullName())); + + assertSame( + descriptor, + TypeRegistry.newBuilder() + .add(descriptor) + .build() + .getDescriptorForTypeUrl("type.googleapis.com/" + descriptor.getFullName())); + } + +} diff --git a/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto b/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto index 0a51fc4199..d41b7a11cc 100644 --- a/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto +++ b/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto @@ -36,8 +36,6 @@ package protobuf_unittest; message Proto1 { option experimental_java_message_interface = "com.google.protobuf.ExtraInterfaces.HasBoolValue"; - option experimental_java_interface_extends = - "com.google.protobuf.ExtraInterfaces.HasByteValue"; option experimental_java_message_interface = "com.google.protobuf.ExtraInterfaces.HasStringValue"; option experimental_java_builder_interface = diff --git a/java/lite/pom.xml b/java/lite/pom.xml index f6e1c250fc..5079d9661e 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -224,6 +224,7 @@ TextFormatParseLocationTest.java TextFormatTest.java TestUtil.java + TypeRegistryTest.java UnknownEnumValueTest.java UnknownFieldSetLiteTest.java UnknownFieldSetTest.java 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 bf2e28ed72..a6efcc2fa4 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 @@ -108,15 +108,22 @@ public class JsonFormat { */ public static Printer printer() { return new Printer( - TypeRegistry.getEmptyTypeRegistry(), false, Collections.emptySet(), - false, false, false, false); + com.google.protobuf.TypeRegistry.getEmptyTypeRegistry(), + TypeRegistry.getEmptyTypeRegistry(), + /* alwaysOutputDefaultValueFields */ false, + /* includingDefaultValueFields */ Collections.emptySet(), + /* preservingProtoFieldNames */ false, + /* omittingInsignificantWhitespace */ false, + /* printingEnumsAsInts */ false, + /* sortingMapKeys */ false); } /** * A Printer converts protobuf message to JSON format. */ public static class Printer { - private final TypeRegistry registry; + private final com.google.protobuf.TypeRegistry registry; + private final TypeRegistry oldRegistry; // NOTE: There are 3 states for these *defaultValueFields variables: // 1) Default - alwaysOutput is false & including is empty set. Fields only output if they are // set to non-default values. @@ -133,7 +140,8 @@ public class JsonFormat { private final boolean sortingMapKeys; private Printer( - TypeRegistry registry, + com.google.protobuf.TypeRegistry registry, + TypeRegistry oldRegistry, boolean alwaysOutputDefaultValueFields, Set includingDefaultValueFields, boolean preservingProtoFieldNames, @@ -141,6 +149,7 @@ public class JsonFormat { boolean printingEnumsAsInts, boolean sortingMapKeys) { this.registry = registry; + this.oldRegistry = oldRegistry; this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields; this.includingDefaultValueFields = includingDefaultValueFields; this.preservingProtoFieldNames = preservingProtoFieldNames; @@ -150,17 +159,41 @@ public class JsonFormat { } /** - * Creates a new {@link Printer} using the given registry. The new Printer - * clones all other configurations from the current {@link Printer}. + * Creates a new {@link Printer} using the given registry. The new Printer clones all other + * configurations from the current {@link Printer}. * * @throws IllegalArgumentException if a registry is already set. */ - public Printer usingTypeRegistry(TypeRegistry registry) { - if (this.registry != TypeRegistry.getEmptyTypeRegistry()) { + public Printer usingTypeRegistry(TypeRegistry oldRegistry) { + if (this.oldRegistry != TypeRegistry.getEmptyTypeRegistry() + || this.registry != com.google.protobuf.TypeRegistry.getEmptyTypeRegistry()) { + throw new IllegalArgumentException("Only one registry is allowed."); + } + return new Printer( + com.google.protobuf.TypeRegistry.getEmptyTypeRegistry(), + oldRegistry, + alwaysOutputDefaultValueFields, + includingDefaultValueFields, + preservingProtoFieldNames, + omittingInsignificantWhitespace, + printingEnumsAsInts, + sortingMapKeys); + } + + /** + * Creates a new {@link Printer} using the given registry. The new Printer clones all other + * configurations from the current {@link Printer}. + * + * @throws IllegalArgumentException if a registry is already set. + */ + public Printer usingTypeRegistry(com.google.protobuf.TypeRegistry registry) { + if (this.oldRegistry != TypeRegistry.getEmptyTypeRegistry() + || this.registry != com.google.protobuf.TypeRegistry.getEmptyTypeRegistry()) { throw new IllegalArgumentException("Only one registry is allowed."); } return new Printer( registry, + oldRegistry, alwaysOutputDefaultValueFields, includingDefaultValueFields, preservingProtoFieldNames, @@ -179,6 +212,7 @@ public class JsonFormat { checkUnsetIncludingDefaultValueFields(); return new Printer( registry, + oldRegistry, true, Collections.emptySet(), preservingProtoFieldNames, @@ -197,6 +231,7 @@ public class JsonFormat { checkUnsetPrintingEnumsAsInts(); return new Printer( registry, + oldRegistry, alwaysOutputDefaultValueFields, Collections.emptySet(), preservingProtoFieldNames, @@ -226,6 +261,7 @@ public class JsonFormat { checkUnsetIncludingDefaultValueFields(); return new Printer( registry, + oldRegistry, false, Collections.unmodifiableSet(new HashSet<>(fieldsToAlwaysOutput)), preservingProtoFieldNames, @@ -250,6 +286,7 @@ public class JsonFormat { public Printer preservingProtoFieldNames() { return new Printer( registry, + oldRegistry, alwaysOutputDefaultValueFields, includingDefaultValueFields, true, @@ -279,6 +316,7 @@ public class JsonFormat { public Printer omittingInsignificantWhitespace() { return new Printer( registry, + oldRegistry, alwaysOutputDefaultValueFields, includingDefaultValueFields, preservingProtoFieldNames, @@ -302,6 +340,7 @@ public class JsonFormat { public Printer sortingMapKeys() { return new Printer( registry, + oldRegistry, alwaysOutputDefaultValueFields, includingDefaultValueFields, preservingProtoFieldNames, @@ -322,6 +361,7 @@ public class JsonFormat { // mobile. new PrinterImpl( registry, + oldRegistry, alwaysOutputDefaultValueFields, includingDefaultValueFields, preservingProtoFieldNames, @@ -354,37 +394,66 @@ public class JsonFormat { * Creates a {@link Parser} with default configuration. */ public static Parser parser() { - return new Parser(TypeRegistry.getEmptyTypeRegistry(), false, Parser.DEFAULT_RECURSION_LIMIT); + return new Parser( + com.google.protobuf.TypeRegistry.getEmptyTypeRegistry(), + TypeRegistry.getEmptyTypeRegistry(), + false, + Parser.DEFAULT_RECURSION_LIMIT); } /** * A Parser parses JSON to protobuf message. */ public static class Parser { - private final TypeRegistry registry; + private final com.google.protobuf.TypeRegistry registry; + private final TypeRegistry oldRegistry; 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, int recursionLimit) { + private Parser( + com.google.protobuf.TypeRegistry registry, + TypeRegistry oldRegistry, + boolean ignoreUnknownFields, + int recursionLimit) { this.registry = registry; + this.oldRegistry = oldRegistry; this.ignoringUnknownFields = ignoreUnknownFields; this.recursionLimit = recursionLimit; } /** - * Creates a new {@link Parser} using the given registry. The new Parser - * clones all other configurations from this Parser. + * Creates a new {@link Parser} using the given registry. The new Parser clones all other + * configurations from this Parser. * * @throws IllegalArgumentException if a registry is already set. */ - public Parser usingTypeRegistry(TypeRegistry registry) { - if (this.registry != TypeRegistry.getEmptyTypeRegistry()) { + public Parser usingTypeRegistry(TypeRegistry oldRegistry) { + if (this.oldRegistry != TypeRegistry.getEmptyTypeRegistry() + || this.registry != com.google.protobuf.TypeRegistry.getEmptyTypeRegistry()) { throw new IllegalArgumentException("Only one registry is allowed."); } - return new Parser(registry, ignoringUnknownFields, recursionLimit); + return new Parser( + com.google.protobuf.TypeRegistry.getEmptyTypeRegistry(), + oldRegistry, + ignoringUnknownFields, + recursionLimit); + } + + /** + * Creates a new {@link Parser} using the given registry. The new Parser clones all other + * configurations from this Parser. + * + * @throws IllegalArgumentException if a registry is already set. + */ + public Parser usingTypeRegistry(com.google.protobuf.TypeRegistry registry) { + if (this.oldRegistry != TypeRegistry.getEmptyTypeRegistry() + || this.registry != com.google.protobuf.TypeRegistry.getEmptyTypeRegistry()) { + throw new IllegalArgumentException("Only one registry is allowed."); + } + return new Parser(registry, oldRegistry, ignoringUnknownFields, recursionLimit); } /** @@ -392,7 +461,7 @@ public class JsonFormat { * encountered. The new Parser clones all other configurations from this Parser. */ public Parser ignoringUnknownFields() { - return new Parser(this.registry, true, recursionLimit); + return new Parser(this.registry, oldRegistry, true, recursionLimit); } /** @@ -404,7 +473,8 @@ 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, recursionLimit).merge(json, builder); + new ParserImpl(registry, oldRegistry, ignoringUnknownFields, recursionLimit) + .merge(json, builder); } /** @@ -417,12 +487,13 @@ 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, recursionLimit).merge(json, builder); + new ParserImpl(registry, oldRegistry, ignoringUnknownFields, recursionLimit) + .merge(json, builder); } // For testing only. Parser usingRecursionLimit(int recursionLimit) { - return new Parser(registry, ignoringUnknownFields, recursionLimit); + return new Parser(registry, oldRegistry, ignoringUnknownFields, recursionLimit); } } @@ -478,7 +549,7 @@ public class JsonFormat { @CanIgnoreReturnValue public Builder add(Descriptor messageType) { if (types == null) { - throw new IllegalStateException("A TypeRegistry.Builer can only be used once."); + throw new IllegalStateException("A TypeRegistry.Builder can only be used once."); } addFile(messageType.getFile()); return this; @@ -641,7 +712,8 @@ public class JsonFormat { * A Printer converts protobuf messages to JSON format. */ private static final class PrinterImpl { - private final TypeRegistry registry; + private final com.google.protobuf.TypeRegistry registry; + private final TypeRegistry oldRegistry; private final boolean alwaysOutputDefaultValueFields; private final Set includingDefaultValueFields; private final boolean preservingProtoFieldNames; @@ -658,7 +730,8 @@ public class JsonFormat { } PrinterImpl( - TypeRegistry registry, + com.google.protobuf.TypeRegistry registry, + TypeRegistry oldRegistry, boolean alwaysOutputDefaultValueFields, Set includingDefaultValueFields, boolean preservingProtoFieldNames, @@ -667,6 +740,7 @@ public class JsonFormat { boolean printingEnumsAsInts, boolean sortingMapKeys) { this.registry = registry; + this.oldRegistry = oldRegistry; this.alwaysOutputDefaultValueFields = alwaysOutputDefaultValueFields; this.includingDefaultValueFields = includingDefaultValueFields; this.preservingProtoFieldNames = preservingProtoFieldNames; @@ -807,7 +881,10 @@ public class JsonFormat { String typeUrl = (String) message.getField(typeUrlField); Descriptor type = registry.getDescriptorForTypeUrl(typeUrl); if (type == null) { - throw new InvalidProtocolBufferException("Cannot find type for url: " + typeUrl); + type = oldRegistry.getDescriptorForTypeUrl(typeUrl); + if (type == null) { + throw new InvalidProtocolBufferException("Cannot find type for url: " + typeUrl); + } } ByteString content = (ByteString) message.getField(valueField); Message contentMessage = @@ -1218,14 +1295,20 @@ public class JsonFormat { } private static class ParserImpl { - private final TypeRegistry registry; + private final com.google.protobuf.TypeRegistry registry; + private final TypeRegistry oldRegistry; private final JsonParser jsonParser; private final boolean ignoringUnknownFields; private final int recursionLimit; private int currentDepth; - ParserImpl(TypeRegistry registry, boolean ignoreUnknownFields, int recursionLimit) { + ParserImpl( + com.google.protobuf.TypeRegistry registry, + TypeRegistry oldRegistry, + boolean ignoreUnknownFields, + int recursionLimit) { this.registry = registry; + this.oldRegistry = oldRegistry; this.ignoringUnknownFields = ignoreUnknownFields; this.jsonParser = new JsonParser(); this.recursionLimit = recursionLimit; @@ -1448,7 +1531,10 @@ public class JsonFormat { String typeUrl = typeUrlElement.getAsString(); Descriptor contentType = registry.getDescriptorForTypeUrl(typeUrl); if (contentType == null) { - throw new InvalidProtocolBufferException("Cannot resolve type: " + typeUrl); + contentType = oldRegistry.getDescriptorForTypeUrl(typeUrl); + if (contentType == null) { + throw new InvalidProtocolBufferException("Cannot resolve type: " + typeUrl); + } } builder.setField(typeUrlField, typeUrl); Message.Builder contentBuilder = 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 04080eab42..2c46ecdcf0 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 @@ -152,6 +152,16 @@ public class JsonFormatTest extends TestCase { assertEquals(message.toString(), parsedMessage.toString()); } + private void assertRoundTripEquals(Message message, com.google.protobuf.TypeRegistry registry) + throws Exception { + JsonFormat.Printer printer = JsonFormat.printer().usingTypeRegistry(registry); + JsonFormat.Parser parser = JsonFormat.parser().usingTypeRegistry(registry); + Message.Builder builder = message.newBuilderForType(); + parser.merge(printer.print(message), builder); + Message parsedMessage = builder.build(); + assertEquals(message.toString(), parsedMessage.toString()); + } + private String toJsonString(Message message) throws IOException { return JsonFormat.printer().print(message); } @@ -850,6 +860,45 @@ public class JsonFormatTest extends TestCase { } + public void testAnyFieldsWithCustomAddedTypeRegistry() throws Exception { + TestAllTypes content = TestAllTypes.newBuilder().setOptionalInt32(1234).build(); + TestAny message = TestAny.newBuilder().setAnyValue(Any.pack(content)).build(); + + com.google.protobuf.TypeRegistry registry = + com.google.protobuf.TypeRegistry.newBuilder().add(content.getDescriptorForType()).build(); + JsonFormat.Printer printer = JsonFormat.printer().usingTypeRegistry(registry); + + assertEquals( + "{\n" + + " \"anyValue\": {\n" + + " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n" + + " \"optionalInt32\": 1234\n" + + " }\n" + + "}", + printer.print(message)); + assertRoundTripEquals(message, registry); + + TestAny messageWithDefaultAnyValue = + TestAny.newBuilder().setAnyValue(Any.getDefaultInstance()).build(); + assertEquals("{\n" + " \"anyValue\": {}\n" + "}", printer.print(messageWithDefaultAnyValue)); + assertRoundTripEquals(messageWithDefaultAnyValue, registry); + + // Well-known types have a special formatting when embedded in Any. + // + // 1. Any in Any. + Any anyMessage = Any.pack(Any.pack(content)); + assertEquals( + "{\n" + + " \"@type\": \"type.googleapis.com/google.protobuf.Any\",\n" + + " \"value\": {\n" + + " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n" + + " \"optionalInt32\": 1234\n" + + " }\n" + + "}", + printer.print(anyMessage)); + assertRoundTripEquals(anyMessage, registry); + } + public void testAnyFields() throws Exception { TestAllTypes content = TestAllTypes.newBuilder().setOptionalInt32(1234).build(); TestAny message = TestAny.newBuilder().setAnyValue(Any.pack(content)).build(); @@ -1136,7 +1185,7 @@ public class JsonFormatTest extends TestCase { Any.Builder builder = Any.newBuilder(); mergeFromJson( "{\n" - + " \"@type\": \"type.googleapis.com/json_test.TestAllTypes\",\n" + + " \"@type\": \"type.googleapis.com/json_test.UnexpectedTypes\",\n" + " \"optionalInt32\": 12345\n" + "}", builder); diff --git a/js/binary/decoder.js b/js/binary/decoder.js index d47c20e4af..45cf611efc 100644 --- a/js/binary/decoder.js +++ b/js/binary/decoder.js @@ -246,20 +246,6 @@ jspb.BinaryDecoder = function(opt_bytes, opt_start, opt_length) { */ this.cursor_ = 0; - /** - * Temporary storage for the low 32 bits of 64-bit data types that we're - * decoding. - * @private {number} - */ - this.tempLow_ = 0; - - /** - * Temporary storage for the high 32 bits of 64-bit data types that we're - * decoding. - * @private {number} - */ - this.tempHigh_ = 0; - /** * Set to true if this decoder encountered an error due to corrupt data. * @private {boolean} @@ -442,9 +428,9 @@ jspb.BinaryDecoder.prototype.getError = function() { /** - * Reads an unsigned varint from the binary stream and stores it as a split - * 64-bit integer. Since this does not convert the value to a number, no - * precision is lost. + * Reads an unsigned varint from the binary stream and invokes the conversion + * function with the value in two signed 32 bit integers to produce the result. + * Since this does not convert the value to a number, no precision is lost. * * It's possible for an unsigned varint to be incorrectly encoded - more than * 64 bits' worth of data could be present. If this happens, this method will @@ -454,52 +440,72 @@ jspb.BinaryDecoder.prototype.getError = function() { * details on the format, see * https://developers.google.com/protocol-buffers/docs/encoding * - * @private + * @param {function(number, number): T} convert Conversion function to produce + * the result value, takes parameters (lowBits, highBits). + * @return {T} + * @template T */ -jspb.BinaryDecoder.prototype.readSplitVarint64_ = function() { - var temp; +jspb.BinaryDecoder.prototype.readSplitVarint64 = function(convert) { + var temp = 128; var lowBits = 0; var highBits = 0; // Read the first four bytes of the varint, stopping at the terminator if we // see it. - for (var i = 0; i < 4; i++) { + for (var i = 0; i < 4 && temp >= 128; i++) { temp = this.bytes_[this.cursor_++]; lowBits |= (temp & 0x7F) << (i * 7); - if (temp < 128) { - this.tempLow_ = lowBits >>> 0; - this.tempHigh_ = 0; - return; - } } - // Read the fifth byte, which straddles the low and high dwords. - temp = this.bytes_[this.cursor_++]; - lowBits |= (temp & 0x7F) << 28; - highBits |= (temp & 0x7F) >> 4; - if (temp < 128) { - this.tempLow_ = lowBits >>> 0; - this.tempHigh_ = highBits >>> 0; - return; + if (temp >= 128) { + // Read the fifth byte, which straddles the low and high dwords. + temp = this.bytes_[this.cursor_++]; + lowBits |= (temp & 0x7F) << 28; + highBits |= (temp & 0x7F) >> 4; } - // Read the sixth through tenth byte. - for (var i = 0; i < 5; i++) { - temp = this.bytes_[this.cursor_++]; - highBits |= (temp & 0x7F) << (i * 7 + 3); - if (temp < 128) { - this.tempLow_ = lowBits >>> 0; - this.tempHigh_ = highBits >>> 0; - return; + if (temp >= 128) { + // Read the sixth through tenth byte. + for (var i = 0; i < 5 && temp >= 128; i++) { + temp = this.bytes_[this.cursor_++]; + highBits |= (temp & 0x7F) << (i * 7 + 3); } } + if (temp < 128) { + return convert(lowBits >>> 0, highBits >>> 0); + } + // If we did not see the terminator, the encoding was invalid. goog.asserts.fail('Failed to read varint, encoding is invalid.'); this.error_ = true; }; +/** + * Reads a 64-bit fixed-width value from the stream and invokes the conversion + * function with the value in two signed 32 bit integers to produce the result. + * Since this does not convert the value to a number, no precision is lost. + * + * @param {function(number, number): T} convert Conversion function to produce + * the result value, takes parameters (lowBits, highBits). + * @return {T} + * @template T + */ +jspb.BinaryDecoder.prototype.readSplitFixed64 = function(convert) { + var bytes = this.bytes_; + var cursor = this.cursor_; + this.cursor_ += 8; + var lowBits = 0; + var highBits = 0; + for (var i = cursor + 7; i >= cursor; i--) { + lowBits = (lowBits << 8) | bytes[i]; + highBits = (highBits << 8) | bytes[i + 4]; + } + return convert(lowBits, highBits); +}; + + /** * Skips over a varint in the block without decoding it. */ @@ -668,8 +674,7 @@ jspb.BinaryDecoder.prototype.readZigzagVarint32 = function() { * integer exceeds 2^53. */ jspb.BinaryDecoder.prototype.readUnsignedVarint64 = function() { - this.readSplitVarint64_(); - return jspb.utils.joinUint64(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinUint64); }; @@ -680,8 +685,7 @@ jspb.BinaryDecoder.prototype.readUnsignedVarint64 = function() { * @return {string} The decoded unsigned varint as a decimal string. */ jspb.BinaryDecoder.prototype.readUnsignedVarint64String = function() { - this.readSplitVarint64_(); - return jspb.utils.joinUnsignedDecimalString(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinUnsignedDecimalString); }; @@ -694,8 +698,7 @@ jspb.BinaryDecoder.prototype.readUnsignedVarint64String = function() { * integer exceeds 2^53. */ jspb.BinaryDecoder.prototype.readSignedVarint64 = function() { - this.readSplitVarint64_(); - return jspb.utils.joinInt64(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinInt64); }; @@ -706,8 +709,7 @@ jspb.BinaryDecoder.prototype.readSignedVarint64 = function() { * @return {string} The decoded signed varint as a decimal string. */ jspb.BinaryDecoder.prototype.readSignedVarint64String = function() { - this.readSplitVarint64_(); - return jspb.utils.joinSignedDecimalString(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinSignedDecimalString); }; @@ -725,8 +727,7 @@ jspb.BinaryDecoder.prototype.readSignedVarint64String = function() { * integer exceeds 2^53. */ jspb.BinaryDecoder.prototype.readZigzagVarint64 = function() { - this.readSplitVarint64_(); - return jspb.utils.joinZigzag64(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinZigzag64); }; @@ -1039,8 +1040,7 @@ jspb.BinaryDecoder.prototype.readBytes = function(length) { * @return {string} The hash value. */ jspb.BinaryDecoder.prototype.readVarintHash64 = function() { - this.readSplitVarint64_(); - return jspb.utils.joinHash64(this.tempLow_, this.tempHigh_); + return this.readSplitVarint64(jspb.utils.joinHash64); }; diff --git a/js/binary/decoder_test.js b/js/binary/decoder_test.js index 15a71d74d1..c5be8057da 100644 --- a/js/binary/decoder_test.js +++ b/js/binary/decoder_test.js @@ -45,6 +45,7 @@ goog.require('goog.testing.asserts'); goog.require('jspb.BinaryConstants'); goog.require('jspb.BinaryDecoder'); goog.require('jspb.BinaryEncoder'); +goog.require('jspb.utils'); /** @@ -172,11 +173,9 @@ describe('binaryDecoderTest', function() { }); - /** - * Tests reading 64-bit integers as hash strings. - */ - it('testHashStrings', function() { - var encoder = new jspb.BinaryEncoder(); + describe('varint64', function() { + var /** !jspb.BinaryEncoder */ encoder; + var /** !jspb.BinaryDecoder */ decoder; var hashA = String.fromCharCode(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); @@ -186,28 +185,54 @@ describe('binaryDecoderTest', function() { 0x87, 0x65, 0x43, 0x21); var hashD = String.fromCharCode(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); - - encoder.writeVarintHash64(hashA); - encoder.writeVarintHash64(hashB); - encoder.writeVarintHash64(hashC); - encoder.writeVarintHash64(hashD); - - encoder.writeFixedHash64(hashA); - encoder.writeFixedHash64(hashB); - encoder.writeFixedHash64(hashC); - encoder.writeFixedHash64(hashD); - - var decoder = jspb.BinaryDecoder.alloc(encoder.end()); - - assertEquals(hashA, decoder.readVarintHash64()); - assertEquals(hashB, decoder.readVarintHash64()); - assertEquals(hashC, decoder.readVarintHash64()); - assertEquals(hashD, decoder.readVarintHash64()); - - assertEquals(hashA, decoder.readFixedHash64()); - assertEquals(hashB, decoder.readFixedHash64()); - assertEquals(hashC, decoder.readFixedHash64()); - assertEquals(hashD, decoder.readFixedHash64()); + beforeEach(function() { + encoder = new jspb.BinaryEncoder(); + + encoder.writeVarintHash64(hashA); + encoder.writeVarintHash64(hashB); + encoder.writeVarintHash64(hashC); + encoder.writeVarintHash64(hashD); + + encoder.writeFixedHash64(hashA); + encoder.writeFixedHash64(hashB); + encoder.writeFixedHash64(hashC); + encoder.writeFixedHash64(hashD); + + decoder = jspb.BinaryDecoder.alloc(encoder.end()); + }); + + it('reads 64-bit integers as hash strings', function() { + assertEquals(hashA, decoder.readVarintHash64()); + assertEquals(hashB, decoder.readVarintHash64()); + assertEquals(hashC, decoder.readVarintHash64()); + assertEquals(hashD, decoder.readVarintHash64()); + + assertEquals(hashA, decoder.readFixedHash64()); + assertEquals(hashB, decoder.readFixedHash64()); + assertEquals(hashC, decoder.readFixedHash64()); + assertEquals(hashD, decoder.readFixedHash64()); + }); + + it('reads split 64 bit integers', function() { + function hexJoin(bitsLow, bitsHigh) { + return `0x${(bitsHigh >>> 0).toString(16)}:0x${ + (bitsLow >>> 0).toString(16)}`; + } + function hexJoinHash(hash64) { + jspb.utils.splitHash64(hash64); + return hexJoin(jspb.utils.split64Low, jspb.utils.split64High); + } + + expect(decoder.readSplitVarint64(hexJoin)).toEqual(hexJoinHash(hashA)); + expect(decoder.readSplitVarint64(hexJoin)).toEqual(hexJoinHash(hashB)); + expect(decoder.readSplitVarint64(hexJoin)).toEqual(hexJoinHash(hashC)); + expect(decoder.readSplitVarint64(hexJoin)).toEqual(hexJoinHash(hashD)); + + expect(decoder.readSplitFixed64(hexJoin)).toEqual(hexJoinHash(hashA)); + expect(decoder.readSplitFixed64(hexJoin)).toEqual(hexJoinHash(hashB)); + expect(decoder.readSplitFixed64(hexJoin)).toEqual(hexJoinHash(hashC)); + expect(decoder.readSplitFixed64(hexJoin)).toEqual(hexJoinHash(hashD)); + }); }); /** diff --git a/js/binary/reader.js b/js/binary/reader.js index 91c7b6dacf..d1ab4079b4 100644 --- a/js/binary/reader.js +++ b/js/binary/reader.js @@ -954,6 +954,23 @@ jspb.BinaryReader.prototype.readVarintHash64 = function() { }; +/** + * Reads a 64-bit varint field from the stream and invokes `convert` to produce + * the return value, or throws an error if the next field in the stream is not + * of the correct wire type. + * + * @param {function(number, number): T} convert Conversion function to produce + * the result value, takes parameters (lowBits, highBits). + * @return {T} + * @template T + */ +jspb.BinaryReader.prototype.readSplitVarint64 = function(convert) { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT); + return this.decoder_.readSplitVarint64(convert); +}; + + /** * Reads a 64-bit varint or fixed64 field from the stream and returns it as a * 8-character Unicode string for use as a hash table key, or throws an error @@ -968,6 +985,23 @@ jspb.BinaryReader.prototype.readFixedHash64 = function() { }; +/** + * Reads a 64-bit fixed64 field from the stream and invokes `convert` + * to produce the return value, or throws an error if the next field in the + * stream is not of the correct wire type. + * + * @param {function(number, number): T} convert Conversion function to produce + * the result value, takes parameters (lowBits, highBits). + * @return {T} + * @template T + */ +jspb.BinaryReader.prototype.readSplitFixed64 = function(convert) { + goog.asserts.assert( + this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64); + return this.decoder_.readSplitFixed64(convert); +}; + + /** * Reads a packed scalar field using the supplied raw reader function. * @param {function(this:jspb.BinaryDecoder)} decodeMethod diff --git a/js/binary/reader_test.js b/js/binary/reader_test.js index eb2af0a9e9..618e9add2b 100644 --- a/js/binary/reader_test.js +++ b/js/binary/reader_test.js @@ -407,6 +407,26 @@ describe('binaryReaderTest', function() { -6, '08 8B 80 80 80 80 80 80 80 80 00'); }); + /** + * Tests reading 64-bit integers as split values. + */ + it('handles split 64 fields', function() { + var writer = new jspb.BinaryWriter(); + writer.writeInt64String(1, '4294967296'); + writer.writeSfixed64String(2, '4294967298'); + var reader = jspb.BinaryReader.alloc(writer.getResultBuffer()); + + function rejoin(lowBits, highBits) { + return highBits * 2 ** 32 + (lowBits >>> 0); + } + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(1); + expect(reader.readSplitVarint64(rejoin)).toEqual(0x100000000); + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(2); + expect(reader.readSplitFixed64(rejoin)).toEqual(0x100000002); + }); /** * Tests 64-bit fields that are handled as strings. diff --git a/js/binary/utils.js b/js/binary/utils.js index 173c416b6f..0cf0ef02da 100644 --- a/js/binary/utils.js +++ b/js/binary/utils.js @@ -428,7 +428,6 @@ jspb.utils.joinHash64 = function(bitsLow, bitsHigh) { return String.fromCharCode(a, b, c, d, e, f, g, h); }; - /** * Individual digits for number->string conversion. * @const {!Array} @@ -438,6 +437,11 @@ jspb.utils.DIGITS = [ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' ]; +/** @const @private {number} '0' */ +jspb.utils.ZERO_CHAR_CODE_ = 48; + +/** @const @private {number} 'a' */ +jspb.utils.A_CHAR_CODE_ = 97; /** * Losslessly converts a 64-bit unsigned integer in 32:32 split representation @@ -487,27 +491,20 @@ jspb.utils.joinUnsignedDecimalString = function(bitsLow, bitsHigh) { digitB %= base; } - // Convert base-1e7 digits to base-10, omitting leading zeroes. - var table = jspb.utils.DIGITS; - var start = false; - var result = ''; - - function emit(digit) { - var temp = base; - for (var i = 0; i < 7; i++) { - temp /= 10; - var decimalDigit = ((digit / temp) % 10) >>> 0; - if ((decimalDigit == 0) && !start) continue; - start = true; - result += table[decimalDigit]; + // Convert base-1e7 digits to base-10, with optional leading zeroes. + function decimalFrom1e7(digit1e7, needLeadingZeros) { + var partial = digit1e7 ? String(digit1e7) : ''; + if (needLeadingZeros) { + return '0000000'.slice(partial.length) + partial; } + return partial; } - if (digitC || start) emit(digitC); - if (digitB || start) emit(digitB); - if (digitA || start) emit(digitA); - - return result; + return decimalFrom1e7(digitC, /*needLeadingZeros=*/ 0) + + decimalFrom1e7(digitB, /*needLeadingZeros=*/ digitC) + + // If the final 1e7 digit didn't need leading zeros, we would have + // returned via the trivial code path at the top. + decimalFrom1e7(digitA, /*needLeadingZeros=*/ 1); }; @@ -605,7 +602,7 @@ jspb.utils.decimalStringToHash64 = function(dec) { // For each decimal digit, set result to 10*result + digit. for (var i = 0; i < dec.length; i++) { - muladd(10, jspb.utils.DIGITS.indexOf(dec[i])); + muladd(10, dec.charCodeAt(i) - jspb.utils.ZERO_CHAR_CODE_); } // If there's a minus sign, convert into two's complement. @@ -627,6 +624,28 @@ jspb.utils.splitDecimalString = function(value) { jspb.utils.splitHash64(jspb.utils.decimalStringToHash64(value)); }; +/** + * @param {number} nibble A 4-bit integer. + * @return {string} + * @private + */ +jspb.utils.toHexDigit_ = function(nibble) { + return String.fromCharCode( + nibble < 10 ? jspb.utils.ZERO_CHAR_CODE_ + nibble : + jspb.utils.A_CHAR_CODE_ - 10 + nibble); +}; + +/** + * @param {number} hexCharCode + * @return {number} + * @private + */ +jspb.utils.fromHexCharCode_ = function(hexCharCode) { + if (hexCharCode >= jspb.utils.A_CHAR_CODE_) { + return hexCharCode - jspb.utils.A_CHAR_CODE_ + 10; + } + return hexCharCode - jspb.utils.ZERO_CHAR_CODE_; +}; /** * Converts an 8-character hash string into its hexadecimal representation. @@ -640,8 +659,8 @@ jspb.utils.hash64ToHexString = function(hash) { for (var i = 0; i < 8; i++) { var c = hash.charCodeAt(7 - i); - temp[i * 2 + 2] = jspb.utils.DIGITS[c >> 4]; - temp[i * 2 + 3] = jspb.utils.DIGITS[c & 0xF]; + temp[i * 2 + 2] = jspb.utils.toHexDigit_(c >> 4); + temp[i * 2 + 3] = jspb.utils.toHexDigit_(c & 0xF); } var result = temp.join(''); @@ -662,8 +681,8 @@ jspb.utils.hexStringToHash64 = function(hex) { var result = ''; for (var i = 0; i < 8; i++) { - var hi = jspb.utils.DIGITS.indexOf(hex[i * 2 + 2]); - var lo = jspb.utils.DIGITS.indexOf(hex[i * 2 + 3]); + var hi = jspb.utils.fromHexCharCode_(hex.charCodeAt(i * 2 + 2)); + var lo = jspb.utils.fromHexCharCode_(hex.charCodeAt(i * 2 + 3)); result = String.fromCharCode(hi * 16 + lo) + result; } diff --git a/js/binary/utils_test.js b/js/binary/utils_test.js index 1345064470..d4c1ef7172 100644 --- a/js/binary/utils_test.js +++ b/js/binary/utils_test.js @@ -38,7 +38,6 @@ goog.require('goog.crypt'); goog.require('goog.crypt.base64'); -goog.require('goog.testing.asserts'); goog.require('jspb.BinaryConstants'); goog.require('jspb.BinaryWriter'); goog.require('jspb.utils'); @@ -82,36 +81,36 @@ describe('binaryUtilsTest', function() { // Check some magic numbers. var result = jspb.utils.joinUnsignedDecimalString(0x89e80001, 0x8ac72304); - assertEquals('10000000000000000001', result); + expect(result).toEqual('10000000000000000001'); result = jspb.utils.joinUnsignedDecimalString(0xacd05f15, 0x1b69b4b); - assertEquals('123456789123456789', result); + expect(result).toEqual('123456789123456789'); result = jspb.utils.joinUnsignedDecimalString(0xeb1f0ad2, 0xab54a98c); - assertEquals('12345678901234567890', result); + expect(result).toEqual('12345678901234567890'); result = jspb.utils.joinUnsignedDecimalString(0xe3b70cb1, 0x891087b8); - assertEquals('9876543210987654321', result); + expect(result).toEqual('9876543210987654321'); // Check limits. result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x00000000); - assertEquals('0', result); + expect(result).toEqual('0'); result = jspb.utils.joinUnsignedDecimalString(0xFFFFFFFF, 0xFFFFFFFF); - assertEquals('18446744073709551615', result); + expect(result).toEqual('18446744073709551615'); // Check each bit of the low dword. for (var i = 0; i < 32; i++) { var low = (1 << i) >>> 0; result = jspb.utils.joinUnsignedDecimalString(low, 0); - assertEquals('' + Math.pow(2, i), result); + expect(result).toEqual('' + Math.pow(2, i)); } // Check the first 20 bits of the high dword. for (var i = 0; i < 20; i++) { var high = (1 << i) >>> 0; result = jspb.utils.joinUnsignedDecimalString(0, high); - assertEquals('' + Math.pow(2, 32 + i), result); + expect(result).toEqual('' + Math.pow(2, 32 + i)); } // V8's internal double-to-string conversion is inaccurate for values above @@ -119,40 +118,40 @@ describe('binaryUtilsTest', function() { // manually against the correct string representations of 2^N. result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x00100000); - assertEquals('4503599627370496', result); + expect(result).toEqual('4503599627370496'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x00200000); - assertEquals('9007199254740992', result); + expect(result).toEqual('9007199254740992'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x00400000); - assertEquals('18014398509481984', result); + expect(result).toEqual('18014398509481984'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x00800000); - assertEquals('36028797018963968', result); + expect(result).toEqual('36028797018963968'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x01000000); - assertEquals('72057594037927936', result); + expect(result).toEqual('72057594037927936'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x02000000); - assertEquals('144115188075855872', result); + expect(result).toEqual('144115188075855872'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x04000000); - assertEquals('288230376151711744', result); + expect(result).toEqual('288230376151711744'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x08000000); - assertEquals('576460752303423488', result); + expect(result).toEqual('576460752303423488'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x10000000); - assertEquals('1152921504606846976', result); + expect(result).toEqual('1152921504606846976'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x20000000); - assertEquals('2305843009213693952', result); + expect(result).toEqual('2305843009213693952'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x40000000); - assertEquals('4611686018427387904', result); + expect(result).toEqual('4611686018427387904'); result = jspb.utils.joinUnsignedDecimalString(0x00000000, 0x80000000); - assertEquals('9223372036854775808', result); + expect(result).toEqual('9223372036854775808'); }); @@ -164,38 +163,38 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.hash64ToDecimalString; result = convert(toHashString(0x00000000, 0x00000000), false); - assertEquals('0', result); + expect(result).toEqual('0'); result = convert(toHashString(0x00000000, 0x00000000), true); - assertEquals('0', result); + expect(result).toEqual('0'); result = convert(toHashString(0xFFFFFFFF, 0xFFFFFFFF), false); - assertEquals('18446744073709551615', result); + expect(result).toEqual('18446744073709551615'); result = convert(toHashString(0xFFFFFFFF, 0xFFFFFFFF), true); - assertEquals('-1', result); + expect(result).toEqual('-1'); result = convert(toHashString(0x00000000, 0x80000000), false); - assertEquals('9223372036854775808', result); + expect(result).toEqual('9223372036854775808'); result = convert(toHashString(0x00000000, 0x80000000), true); - assertEquals('-9223372036854775808', result); + expect(result).toEqual('-9223372036854775808'); result = convert(toHashString(0xacd05f15, 0x01b69b4b), false); - assertEquals('123456789123456789', result); + expect(result).toEqual('123456789123456789'); result = convert(toHashString(~0xacd05f15 + 1, ~0x01b69b4b), true); - assertEquals('-123456789123456789', result); + expect(result).toEqual('-123456789123456789'); // And converting arrays of hashes should work the same way. result = jspb.utils.hash64ArrayToDecimalStrings([ toHashString(0xFFFFFFFF, 0xFFFFFFFF), toHashString(0x00000000, 0x80000000), toHashString(0xacd05f15, 0x01b69b4b)], false); - assertEquals(3, result.length); - assertEquals('18446744073709551615', result[0]); - assertEquals('9223372036854775808', result[1]); - assertEquals('123456789123456789', result[2]); + expect(result.length).toEqual(3); + expect(result[0]).toEqual('18446744073709551615'); + expect(result[1]).toEqual('9223372036854775808'); + expect(result[2]).toEqual('123456789123456789'); }); /* @@ -206,32 +205,32 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.decimalStringToHash64; result = convert('0'); - assertEquals(goog.crypt.byteArrayToString( - [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])); result = convert('-1'); - assertEquals(goog.crypt.byteArrayToString( - [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])); result = convert('18446744073709551615'); - assertEquals(goog.crypt.byteArrayToString( - [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])); result = convert('9223372036854775808'); - assertEquals(goog.crypt.byteArrayToString( - [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80])); result = convert('-9223372036854775808'); - assertEquals(goog.crypt.byteArrayToString( - [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80])); result = convert('123456789123456789'); - assertEquals(goog.crypt.byteArrayToString( - [0x15, 0x5F, 0xD0, 0xAC, 0x4B, 0x9B, 0xB6, 0x01]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0x15, 0x5F, 0xD0, 0xAC, 0x4B, 0x9B, 0xB6, 0x01])); result = convert('-123456789123456789'); - assertEquals(goog.crypt.byteArrayToString( - [0xEB, 0xA0, 0x2F, 0x53, 0xB4, 0x64, 0x49, 0xFE]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xEB, 0xA0, 0x2F, 0x53, 0xB4, 0x64, 0x49, 0xFE])); }); /** @@ -242,13 +241,13 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.hash64ToHexString; result = convert(toHashString(0x00000000, 0x00000000)); - assertEquals('0x0000000000000000', result); + expect(result).toEqual('0x0000000000000000'); result = convert(toHashString(0xFFFFFFFF, 0xFFFFFFFF)); - assertEquals('0xffffffffffffffff', result); + expect(result).toEqual('0xffffffffffffffff'); result = convert(toHashString(0x12345678, 0x9ABCDEF0)); - assertEquals('0x9abcdef012345678', result); + expect(result).toEqual('0x9abcdef012345678'); }); @@ -260,22 +259,22 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.hexStringToHash64; result = convert('0x0000000000000000'); - assertEquals(goog.crypt.byteArrayToString( - [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])); result = convert('0xffffffffffffffff'); - assertEquals(goog.crypt.byteArrayToString( - [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])); // Hex string is big-endian, hash string is little-endian. result = convert('0x123456789ABCDEF0'); - assertEquals(goog.crypt.byteArrayToString( - [0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12])); // Capitalization should not matter. result = convert('0x0000abcdefABCDEF'); - assertEquals(goog.crypt.byteArrayToString( - [0xEF, 0xCD, 0xAB, 0xEF, 0xCD, 0xAB, 0x00, 0x00]), result); + expect(result).toEqual(goog.crypt.byteArrayToString( + [0xEF, 0xCD, 0xAB, 0xEF, 0xCD, 0xAB, 0x00, 0x00])); }); @@ -288,25 +287,25 @@ describe('binaryUtilsTest', function() { var convert = jspb.utils.numberToHash64; result = convert(0x0000000000000); - assertEquals('0x0000000000000000', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)).toEqual('0x0000000000000000'); result = convert(0xFFFFFFFFFFFFF); - assertEquals('0x000fffffffffffff', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)).toEqual('0x000fffffffffffff'); result = convert(0x123456789ABCD); - assertEquals('0x000123456789abcd', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)).toEqual('0x000123456789abcd'); result = convert(0xDCBA987654321); - assertEquals('0x000dcba987654321', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)).toEqual('0x000dcba987654321'); // 53 bits of precision should not be truncated. result = convert(0x10000000000001); - assertEquals('0x0010000000000001', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)).toEqual('0x0010000000000001'); // 54 bits of precision should be truncated. result = convert(0x20000000000001); - assertNotEquals( - '0x0020000000000001', jspb.utils.hash64ToHexString(result)); + expect(jspb.utils.hash64ToHexString(result)) + .not.toEqual('0x0020000000000001'); }); @@ -322,15 +321,15 @@ describe('binaryUtilsTest', function() { // come back out of the string unchanged. for (var i = 0; i < 65536; i++) { strings[i] = 'a' + String.fromCharCode(i) + 'a'; - if (3 != strings[i].length) throw 'fail!'; - if (i != strings[i].charCodeAt(1)) throw 'fail!'; + expect(strings[i].length).toEqual(3); + expect(strings[i].charCodeAt(1)).toEqual(i); } // Each unicode character should compare equal to itself and not equal to a // different unicode character. for (var i = 0; i < 65536; i++) { - if (strings[i] != strings[i]) throw 'fail!'; - if (strings[i] == strings[(i + 1) % 65536]) throw 'fail!'; + expect(strings[i] == strings[i]).toEqual(true); + expect(strings[i] == strings[(i + 1) % 65536]).toEqual(false); } }); @@ -345,10 +344,9 @@ describe('binaryUtilsTest', function() { // NaN. jspb.utils.splitFloat32(NaN); - if (!isNaN(jspb.utils.joinFloat32(jspb.utils.split64Low, - jspb.utils.split64High))) { - throw 'fail!'; - } + expect(isNaN(jspb.utils.joinFloat32( + jspb.utils.split64Low, jspb.utils.split64High))) + .toEqual(true); /** * @param {number} x @@ -359,10 +357,9 @@ describe('binaryUtilsTest', function() { if (goog.isDef(opt_bits)) { if (opt_bits != jspb.utils.split64Low) throw 'fail!'; } - if (truncate(x) != jspb.utils.joinFloat32(jspb.utils.split64Low, - jspb.utils.split64High)) { - throw 'fail!'; - } + expect(truncate(x)) + .toEqual(jspb.utils.joinFloat32( + jspb.utils.split64Low, jspb.utils.split64High)); } // Positive and negative infinity. @@ -411,10 +408,9 @@ describe('binaryUtilsTest', function() { // NaN. jspb.utils.splitFloat64(NaN); - if (!isNaN(jspb.utils.joinFloat64(jspb.utils.split64Low, - jspb.utils.split64High))) { - throw 'fail!'; - } + expect(isNaN(jspb.utils.joinFloat64( + jspb.utils.split64Low, jspb.utils.split64High))) + .toEqual(true); /** * @param {number} x @@ -429,10 +425,9 @@ describe('binaryUtilsTest', function() { if (goog.isDef(opt_lowBits)) { if (opt_lowBits != jspb.utils.split64Low) throw 'fail!'; } - if (x != jspb.utils.joinFloat64(jspb.utils.split64Low, - jspb.utils.split64High)) { - throw 'fail!'; - } + expect( + jspb.utils.joinFloat64(jspb.utils.split64Low, jspb.utils.split64High)) + .toEqual(x); } // Positive and negative infinity. @@ -487,8 +482,8 @@ describe('binaryUtilsTest', function() { // We should have two more varints than we started with - one for the field // tag, one for the packed length. - assertEquals(values.length + 2, - jspb.utils.countVarints(buffer, 0, buffer.length)); + expect(jspb.utils.countVarints(buffer, 0, buffer.length)) + .toEqual(values.length + 2); }); @@ -506,8 +501,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); var buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countVarintFields(buffer, 0, buffer.length, 1)); + expect(jspb.utils.countVarintFields(buffer, 0, buffer.length, 1)) + .toEqual(count); writer = new jspb.BinaryWriter(); @@ -519,8 +514,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countVarintFields(buffer, 0, buffer.length, 123456789)); + expect(jspb.utils.countVarintFields(buffer, 0, buffer.length, 123456789)) + .toEqual(count); }); @@ -538,8 +533,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); var buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countFixed32Fields(buffer, 0, buffer.length, 1)); + expect(jspb.utils.countFixed32Fields(buffer, 0, buffer.length, 1)) + .toEqual(count); writer = new jspb.BinaryWriter(); @@ -551,8 +546,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countFixed32Fields(buffer, 0, buffer.length, 123456789)); + expect(jspb.utils.countFixed32Fields(buffer, 0, buffer.length, 123456789)) + .toEqual(count); }); @@ -570,8 +565,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); var buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countFixed64Fields(buffer, 0, buffer.length, 1)); + expect(jspb.utils.countFixed64Fields(buffer, 0, buffer.length, 1)) + .toEqual(count); writer = new jspb.BinaryWriter(); @@ -583,8 +578,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countFixed64Fields(buffer, 0, buffer.length, 123456789)); + expect(jspb.utils.countFixed64Fields(buffer, 0, buffer.length, 123456789)) + .toEqual(count); }); @@ -602,8 +597,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); var buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countDelimitedFields(buffer, 0, buffer.length, 1)); + expect(jspb.utils.countDelimitedFields(buffer, 0, buffer.length, 1)) + .toEqual(count); writer = new jspb.BinaryWriter(); @@ -615,8 +610,8 @@ describe('binaryUtilsTest', function() { writer.writeString(2, 'terminator'); buffer = new Uint8Array(writer.getResultBuffer()); - assertEquals(count, - jspb.utils.countDelimitedFields(buffer, 0, buffer.length, 123456789)); + expect(jspb.utils.countDelimitedFields(buffer, 0, buffer.length, 123456789)) + .toEqual(count); }); @@ -624,9 +619,10 @@ describe('binaryUtilsTest', function() { * Tests byte format for debug strings. */ it('testDebugBytesToTextFormat', function() { - assertEquals('""', jspb.utils.debugBytesToTextFormat(null)); - assertEquals('"\\x00\\x10\\xff"', - jspb.utils.debugBytesToTextFormat([0, 16, 255])); + expect(jspb.utils.debugBytesToTextFormat(null)).toEqual('""'); + expect(jspb.utils.debugBytesToTextFormat([ + 0, 16, 255 + ])).toEqual('"\\x00\\x10\\xff"'); }); @@ -647,15 +643,15 @@ describe('binaryUtilsTest', function() { var sourceString = goog.crypt.byteArrayToString(sourceData); function check(result) { - assertEquals(Uint8Array, result.constructor); - assertEquals(sourceData.length, result.length); + expect(result.constructor).toEqual(Uint8Array); + expect(result.length).toEqual(sourceData.length); for (var i = 0; i < result.length; i++) { - assertEquals(sourceData[i], result[i]); + expect(result[i]).toEqual(sourceData[i]); } } // Converting Uint8Arrays into Uint8Arrays should be a no-op. - assertEquals(sourceBytes, convert(sourceBytes)); + expect(convert(sourceBytes)).toEqual(sourceBytes); // Converting Array into Uint8Arrays should work. check(convert(sourceData)); diff --git a/js/binary/writer.js b/js/binary/writer.js index ae1c29b822..017d4818a8 100644 --- a/js/binary/writer.js +++ b/js/binary/writer.js @@ -886,6 +886,32 @@ jspb.BinaryWriter.prototype.writeVarintHash64 = function(field, value) { }; +/** + * Writes a 64-bit field to the buffer as a fixed64. + * @param {number} field The field number. + * @param {number} lowBits The low 32 bits. + * @param {number} highBits The high 32 bits. + */ +jspb.BinaryWriter.prototype.writeSplitFixed64 = function( + field, lowBits, highBits) { + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.FIXED64); + this.encoder_.writeSplitFixed64(lowBits, highBits); +}; + + +/** + * Writes a 64-bit field to the buffer as a varint. + * @param {number} field The field number. + * @param {number} lowBits The low 32 bits. + * @param {number} highBits The high 32 bits. + */ +jspb.BinaryWriter.prototype.writeSplitVarint64 = function( + field, lowBits, highBits) { + this.writeFieldHeader_(field, jspb.BinaryConstants.WireType.VARINT); + this.encoder_.writeSplitVarint64(lowBits, highBits); +}; + + /** * Writes an array of numbers to the buffer as a repeated 32-bit int field. * @param {number} field The field number. @@ -926,6 +952,40 @@ jspb.BinaryWriter.prototype.writeRepeatedInt64 = function(field, value) { }; +/** + * Writes an array of 64-bit values to the buffer as a fixed64. + * @param {number} field The field number. + * @param {?Array} value The value. + * @param {function(T): number} lo Function to get low bits. + * @param {function(T): number} hi Function to get high bits. + * @template T + */ +jspb.BinaryWriter.prototype.writeRepeatedSplitFixed64 = function( + field, value, lo, hi) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeSplitFixed64(field, lo(value[i]), hi(value[i])); + } +}; + + +/** + * Writes an array of 64-bit values to the buffer as a varint. + * @param {number} field The field number. + * @param {?Array} value The value. + * @param {function(T): number} lo Function to get low bits. + * @param {function(T): number} hi Function to get high bits. + * @template T + */ +jspb.BinaryWriter.prototype.writeRepeatedSplitVarint64 = function( + field, value, lo, hi) { + if (value == null) return; + for (var i = 0; i < value.length; i++) { + this.writeSplitVarint64(field, lo(value[i]), hi(value[i])); + } +}; + + /** * Writes an array of numbers formatted as strings to the buffer as a repeated * 64-bit int field. @@ -1313,6 +1373,44 @@ jspb.BinaryWriter.prototype.writePackedInt64 = function(field, value) { }; +/** + * Writes an array of 64-bit values to the buffer as a fixed64. + * @param {number} field The field number. + * @param {?Array} value The value. + * @param {function(T): number} lo Function to get low bits. + * @param {function(T): number} hi Function to get high bits. + * @template T + */ +jspb.BinaryWriter.prototype.writePackedSplitFixed64 = function( + field, value, lo, hi) { + if (value == null) return; + var bookmark = this.beginDelimited_(field); + for (var i = 0; i < value.length; i++) { + this.encoder_.writeSplitFixed64(lo(value[i]), hi(value[i])); + } + this.endDelimited_(bookmark); +}; + + +/** + * Writes an array of 64-bit values to the buffer as a varint. + * @param {number} field The field number. + * @param {?Array} value The value. + * @param {function(T): number} lo Function to get low bits. + * @param {function(T): number} hi Function to get high bits. + * @template T + */ +jspb.BinaryWriter.prototype.writePackedSplitVarint64 = function( + field, value, lo, hi) { + if (value == null) return; + var bookmark = this.beginDelimited_(field); + for (var i = 0; i < value.length; i++) { + this.encoder_.writeSplitVarint64(lo(value[i]), hi(value[i])); + } + this.endDelimited_(bookmark); +}; + + /** * Writes an array of numbers represented as strings to the buffer as a packed * 64-bit int field. diff --git a/js/binary/writer_test.js b/js/binary/writer_test.js index 8a9a1bb009..b4860a1df4 100644 --- a/js/binary/writer_test.js +++ b/js/binary/writer_test.js @@ -40,6 +40,7 @@ goog.require('goog.crypt'); goog.require('goog.testing.asserts'); +goog.require('jspb.BinaryReader'); goog.require('jspb.BinaryWriter'); @@ -130,4 +131,74 @@ describe('binaryWriterTest', function() { assertEquals('CgF/', writer.getResultBase64String(false)); assertEquals('CgF_', writer.getResultBase64String(true)); }); + + it('writes split 64 fields', function() { + var writer = new jspb.BinaryWriter(); + writer.writeSplitVarint64(1, 0x1, 0x2); + writer.writeSplitVarint64(1, 0xFFFFFFFF, 0xFFFFFFFF); + writer.writeSplitFixed64(2, 0x1, 0x2); + writer.writeSplitFixed64(2, 0xFFFFFFF0, 0xFFFFFFFF); + function lo(i) { + return i + 1; + } + function hi(i) { + return i + 2; + } + writer.writeRepeatedSplitVarint64(3, [0, 1, 2], lo, hi); + writer.writeRepeatedSplitFixed64(4, [0, 1, 2], lo, hi); + writer.writePackedSplitVarint64(5, [0, 1, 2], lo, hi); + writer.writePackedSplitFixed64(6, [0, 1, 2], lo, hi); + + function bitsAsArray(lowBits, highBits) { + return [lowBits >>> 0, highBits >>> 0]; + } + var reader = jspb.BinaryReader.alloc(writer.getResultBuffer()); + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(1); + expect(reader.readSplitVarint64(bitsAsArray)).toEqual([0x1, 0x2]); + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(1); + expect(reader.readSplitVarint64(bitsAsArray)).toEqual([ + 0xFFFFFFFF, 0xFFFFFFFF + ]); + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(2); + expect(reader.readSplitFixed64(bitsAsArray)).toEqual([0x1, 0x2]); + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(2); + expect(reader.readSplitFixed64(bitsAsArray)).toEqual([ + 0xFFFFFFF0, 0xFFFFFFFF + ]); + + for (let i = 0; i < 3; i++) { + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(3); + expect(reader.readSplitVarint64(bitsAsArray)).toEqual([i + 1, i + 2]); + } + + for (let i = 0; i < 3; i++) { + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(4); + expect(reader.readSplitFixed64(bitsAsArray)).toEqual([i + 1, i + 2]); + } + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(5); + expect(reader.readPackedInt64String()).toEqual([ + String(2 * 2 ** 32 + 1), + String(3 * 2 ** 32 + 2), + String(4 * 2 ** 32 + 3), + ]); + + reader.nextField(); + expect(reader.getFieldNumber()).toEqual(6); + expect(reader.readPackedFixed64String()).toEqual([ + String(2 * 2 ** 32 + 1), + String(3 * 2 ** 32 + 2), + String(4 * 2 ** 32 + 3), + ]); + }); }); diff --git a/js/map.js b/js/map.js index b9a48afed7..734b1566f7 100644 --- a/js/map.js +++ b/js/map.js @@ -465,11 +465,15 @@ jspb.Map.prototype.serializeBinary = function( * entries with unset keys is required for maps to be backwards compatible * with the repeated message representation described here: goo.gl/zuoLAC * + * @param {V=} opt_defaultValue + * The default value for the type of map values. + * */ jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn, - opt_valueReaderCallback, opt_defaultKey) { + opt_valueReaderCallback, opt_defaultKey, + opt_defaultValue) { var key = opt_defaultKey; - var value = undefined; + var value = opt_defaultValue; while (reader.nextField()) { if (reader.isEndGroup()) { diff --git a/js/message.js b/js/message.js index 23e5af0d4b..0957c6db77 100644 --- a/js/message.js +++ b/js/message.js @@ -104,7 +104,7 @@ jspb.ExtensionFieldInfo = function(fieldNumber, fieldName, ctor, toObjectFn, /** * Stores binary-related information for a single extension field. * @param {!jspb.ExtensionFieldInfo} fieldInfo - * @param {function(this:jspb.BinaryReader,number,?)} binaryReaderFn + * @param {function(this:jspb.BinaryReader,number,?,?)} binaryReaderFn * @param {function(this:jspb.BinaryWriter,number,?) * |function(this:jspb.BinaryWriter,number,?,?,?,?,?)} binaryWriterFn * @param {function(?,?)=} opt_binaryMessageSerializeFn @@ -976,153 +976,186 @@ jspb.Message.getMapField = function(msg, fieldNumber, noLazyCreate, /** * Sets the value of a non-extension field. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {string|number|boolean|Uint8Array|Array|undefined} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setField = function(msg, fieldNumber, value) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); if (fieldNumber < msg.pivot_) { msg.array[jspb.Message.getIndex_(msg, fieldNumber)] = value; } else { jspb.Message.maybeInitEmptyExtensionObject_(msg); msg.extensionObject_[fieldNumber] = value; } + return msg; }; /** * Sets the value of a non-extension integer field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {number} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3IntField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0); }; /** * Sets the value of a non-extension floating point field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {number} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3FloatField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0.0); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0.0); }; /** * Sets the value of a non-extension boolean field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {boolean} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3BooleanField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, false); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, false); }; /** * Sets the value of a non-extension String field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {string} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3StringField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, ""); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, ''); }; /** * Sets the value of a non-extension Bytes field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {!Uint8Array|string} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3BytesField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, ""); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, ''); }; /** * Sets the value of a non-extension enum field of a proto3 - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {number} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3EnumField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, 0); }; /** * Sets the value of a non-extension int field of a proto3 that has jstype set * to String. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {string} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setProto3StringIntField = function(msg, fieldNumber, value) { - jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, "0"); + return jspb.Message.setFieldIgnoringDefault_(msg, fieldNumber, value, '0'); }; /** * Sets the value of a non-extension primitive field, with proto3 (non-nullable * primitives) semantics of ignoring values that are equal to the type's * default. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {!Uint8Array|string|number|boolean|undefined} value New value * @param {!Uint8Array|string|number|boolean} defaultValue The default value. + * @return {T} return msg + * @template T * @private */ jspb.Message.setFieldIgnoringDefault_ = function( msg, fieldNumber, value, defaultValue) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); if (value !== defaultValue) { jspb.Message.setField(msg, fieldNumber, value); } else { msg.array[jspb.Message.getIndex_(msg, fieldNumber)] = null; } + return msg; }; /** * Adds a value to a repeated, primitive field. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {string|number|boolean|!Uint8Array} value New value * @param {number=} opt_index Index where to put new value. + * @return {T} return msg + * @template T * @protected */ jspb.Message.addToRepeatedField = function(msg, fieldNumber, value, opt_index) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); var arr = jspb.Message.getRepeatedField(msg, fieldNumber); if (opt_index != undefined) { arr.splice(opt_index, 0, value); } else { arr.push(value); } + return msg; }; /** * Sets the value of a field in a oneof union and clears all other fields in * the union. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {!Array} oneof The fields belonging to the union. * @param {string|number|boolean|Uint8Array|Array|undefined} value New value + * @return {T} return msg + * @template T * @protected */ jspb.Message.setOneofField = function(msg, fieldNumber, oneof, value) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); var currentCase = jspb.Message.computeOneofCase(msg, oneof); if (currentCase && currentCase !== fieldNumber && value !== undefined) { if (msg.wrappers_ && currentCase in msg.wrappers_) { @@ -1130,7 +1163,7 @@ jspb.Message.setOneofField = function(msg, fieldNumber, oneof, value) { } jspb.Message.setField(msg, currentCase, undefined); } - jspb.Message.setField(msg, fieldNumber, value); + return jspb.Message.setField(msg, fieldNumber, value); }; @@ -1244,48 +1277,61 @@ 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 {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {?jspb.Message|?jspb.Map|undefined} value A new value for this proto * field. + * @return {T} the msg + * @template T * @protected */ jspb.Message.setWrapperField = function(msg, fieldNumber, value) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); if (!msg.wrappers_) { msg.wrappers_ = {}; } var data = value ? value.toArray() : value; msg.wrappers_[fieldNumber] = value; - jspb.Message.setField(msg, fieldNumber, data); + return jspb.Message.setField(msg, fieldNumber, data); }; + /** * Sets a proto field in a oneof union and syncs it to the backing array. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {!Array} oneof The fields belonging to the union. * @param {jspb.Message|undefined} value A new value for this proto field. + * @return {T} the msg + * @template T * @protected */ jspb.Message.setOneofWrapperField = function(msg, fieldNumber, oneof, value) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); if (!msg.wrappers_) { msg.wrappers_ = {}; } var data = value ? value.toArray() : value; msg.wrappers_[fieldNumber] = value; - jspb.Message.setOneofField(msg, fieldNumber, oneof, data); + return jspb.Message.setOneofField(msg, fieldNumber, oneof, data); }; /** * Sets a repeated proto field and syncs it to the backing array. - * @param {!jspb.Message} msg A jspb proto. + * @param {T} msg A jspb proto. * @param {number} fieldNumber The field number. * @param {Array|undefined} value An array of protos. + * @return {T} the msg + * @template T * @protected */ jspb.Message.setRepeatedWrapperField = function(msg, fieldNumber, value) { + // TODO(b/35241823): replace this with a bounded generic when available + goog.asserts.assertInstanceof(msg, jspb.Message); if (!msg.wrappers_) { msg.wrappers_ = {}; } @@ -1294,7 +1340,7 @@ jspb.Message.setRepeatedWrapperField = function(msg, fieldNumber, value) { data[i] = value[i].toArray(); } msg.wrappers_[fieldNumber] = value; - jspb.Message.setField(msg, fieldNumber, data); + return jspb.Message.setField(msg, fieldNumber, data); }; diff --git a/js/message_test.js b/js/message_test.js index a9fc64a98f..1965348cff 100644 --- a/js/message_test.js +++ b/js/message_test.js @@ -118,6 +118,7 @@ goog.require('proto.jspb.test.TestReservedNamesExtension'); goog.require('proto.jspb.test.ExtensionMessage'); goog.require('proto.jspb.test.TestExtensionsMessage'); +goog.require('proto.jspb.test.TestAllowAliasEnum'); describe('Message test suite', function() { var stubs = new goog.testing.PropertyReplacer(); diff --git a/js/test.proto b/js/test.proto index 7c2a4699a2..7c0578a4f3 100644 --- a/js/test.proto +++ b/js/test.proto @@ -28,6 +28,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// LINT: LEGACY_NAMES // Author: mwr@google.com (Mark Rawling) syntax = "proto2"; @@ -311,3 +312,11 @@ message Deeply { } + +enum TestAllowAliasEnum { + option allow_alias = true; + + TEST_ALLOW_ALIAS_DEFAULT = 0; + VALUE1 = 1; + value1 = 1; +} diff --git a/kokoro/linux/bazel/build.sh b/kokoro/linux/bazel/build.sh index 6b55ab1a47..b99b4d31df 100755 --- a/kokoro/linux/bazel/build.sh +++ b/kokoro/linux/bazel/build.sh @@ -3,11 +3,28 @@ # Build file to set up and run tests set -ex +# Install the latest Bazel version available +use_bazel.sh latest +bazel version + +# Print bazel testlogs to stdout when tests failed. +function print_test_logs { + # TODO(yannic): Only print logs of failing tests. + testlogs_dir=$(bazel info bazel-testlogs) + testlogs=$(find "${testlogs_dir}" -name "*.log") + for log in $testlogs; do + cat "${log}" + done +} + # Change to repo root cd $(dirname $0)/../../.. git submodule update --init --recursive -bazel test :protobuf_test --copt=-Werror --host_copt=-Werror + +trap print_test_logs EXIT +bazel test :build_files_updated_unittest :protobuf_test --copt=-Werror --host_copt=-Werror +trap - EXIT cd examples bazel build :all diff --git a/kokoro/release/python/linux/build_artifacts.sh b/kokoro/release/python/linux/build_artifacts.sh index c2806b704e..5f9eaa19c8 100755 --- a/kokoro/release/python/linux/build_artifacts.sh +++ b/kokoro/release/python/linux/build_artifacts.sh @@ -50,7 +50,6 @@ build_artifact_version() { } build_artifact_version 2.7 -build_artifact_version 3.4 build_artifact_version 3.5 build_artifact_version 3.6 build_artifact_version 3.7 diff --git a/kokoro/release/python/macos/build_artifacts.sh b/kokoro/release/python/macos/build_artifacts.sh index 02d666f7a2..148d1f9bab 100755 --- a/kokoro/release/python/macos/build_artifacts.sh +++ b/kokoro/release/python/macos/build_artifacts.sh @@ -51,7 +51,6 @@ build_artifact_version() { } build_artifact_version 2.7 -build_artifact_version 3.4 build_artifact_version 3.5 build_artifact_version 3.6 build_artifact_version 3.7 diff --git a/objectivec/google/protobuf/Duration.pbobjc.h b/objectivec/google/protobuf/Duration.pbobjc.h index 3e36759072..561b093419 100644 --- a/objectivec/google/protobuf/Duration.pbobjc.h +++ b/objectivec/google/protobuf/Duration.pbobjc.h @@ -77,7 +77,7 @@ typedef GPB_ENUM(GPBDuration_FieldNumber) { * if (duration.seconds < 0 && duration.nanos > 0) { * duration.seconds += 1; * duration.nanos -= 1000000000; - * } else if (durations.seconds > 0 && duration.nanos < 0) { + * } else if (duration.seconds > 0 && duration.nanos < 0) { * duration.seconds -= 1; * duration.nanos += 1000000000; * } diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index eb6610ede6..57509ee279 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -5,7 +5,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def protobuf_deps(): """Loads common dependencies needed to compile the protobuf library.""" - if "zlib" not in native.existing_rules(): + if not native.existing_rule("zlib"): http_archive( name = "zlib", build_file = "@com_google_protobuf//:third_party/zlib.BUILD", @@ -14,10 +14,34 @@ def protobuf_deps(): urls = ["https://zlib.net/zlib-1.2.11.tar.gz"], ) - if "six" not in native.existing_rules(): + if not native.existing_rule("six"): http_archive( name = "six", build_file = "@//:six.BUILD", sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"], ) + + if not native.existing_rule("rules_cc"): + http_archive( + name = "rules_cc", + sha256 = "29daf0159f0cf552fcff60b49d8bcd4f08f08506d2da6e41b07058ec50cfeaec", + strip_prefix = "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e", + urls = ["https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.tar.gz"], + ) + + if not native.existing_rule("rules_java"): + http_archive( + name = "rules_java", + sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3", + strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd", + urls = ["https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz"], + ) + + if not native.existing_rule("rules_proto"): + http_archive( + name = "rules_proto", + sha256 = "88b0a90433866b44bb4450d4c30bc5738b8c4f9c9ba14e9661deb123f56a833d", + strip_prefix = "rules_proto-b0cc14be5da05168b01db282fe93bdf17aa2b9f4", + urls = ["https://github.com/bazelbuild/rules_proto/archive/b0cc14be5da05168b01db282fe93bdf17aa2b9f4.tar.gz"], + ) diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index 9de3e7a016..86bcce8bb0 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -1998,6 +1998,13 @@ class Proto3Test(unittest.TestCase): m1.MergeFrom(m2) self.assertEqual(10, m2.map_int32_foreign_message[123].c) + # Test merge maps within different message types. + m1 = map_unittest_pb2.TestMap() + m2 = map_unittest_pb2.TestMessageMap() + m2.map_int32_message[123].optional_int32 = 10 + m1.map_int32_all_types.MergeFrom(m2.map_int32_message) + self.assertEqual(10, m1.map_int32_all_types[123].optional_int32) + def testMergeFromBadType(self): msg = map_unittest_pb2.TestMap() with self.assertRaisesRegexp( diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py index 803ae84849..8f3ec9db80 100755 --- a/python/google/protobuf/internal/python_message.py +++ b/python/google/protobuf/internal/python_message.py @@ -620,7 +620,7 @@ class _FieldProperty(property): def _AddPropertiesForRepeatedField(field, cls): """Adds a public property for a "repeated" protocol message field. Clients can use this property to get the value of the field, which will be either a - _RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see + RepeatedScalarFieldContainer or RepeatedCompositeFieldContainer (see below). Note that when clients add values to these containers, we perform diff --git a/python/google/protobuf/internal/well_known_types.py b/python/google/protobuf/internal/well_known_types.py index 7d7fe15036..308fbfef6e 100644 --- a/python/google/protobuf/internal/well_known_types.py +++ b/python/google/protobuf/internal/well_known_types.py @@ -722,10 +722,10 @@ def _SetStructValue(struct_value, value): struct_value.string_value = value elif isinstance(value, _INT_OR_FLOAT): struct_value.number_value = value - elif isinstance(value, dict): + elif isinstance(value, (dict, Struct)): struct_value.struct_value.Clear() struct_value.struct_value.update(value) - elif isinstance(value, list): + elif isinstance(value, (list, ListValue)): struct_value.list_value.Clear() struct_value.list_value.extend(value) else: diff --git a/python/google/protobuf/internal/well_known_types_test.py b/python/google/protobuf/internal/well_known_types_test.py index 61b41ec523..8089f035c6 100644 --- a/python/google/protobuf/internal/well_known_types_test.py +++ b/python/google/protobuf/internal/well_known_types_test.py @@ -871,6 +871,15 @@ class StructTest(unittest.TestCase): self.assertEqual([6, True, False, None, inner_struct], list(struct['key5'].items())) + def testStructAssignment(self): + # Tests struct assignment from another struct + s1 = struct_pb2.Struct() + s2 = struct_pb2.Struct() + for value in [1, 'a', [1], ['a'], {'a': 'b'}]: + s1['x'] = value + s2['x'] = s1['x'] + self.assertEqual(s1['x'], s2['x']) + def testMergeFrom(self): struct = struct_pb2.Struct() struct_class = struct.__class__ diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index 9c8727efab..222a0014c5 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -343,9 +343,8 @@ PyObject* MapReflectionFriend::MergeFrom(PyObject* _self, PyObject* arg) { const Reflection* other_reflection = other_message->GetReflection(); internal::MapFieldBase* field = reflection->MutableMapData( message, self->parent_field_descriptor); - const internal::MapFieldBase* other_field = - other_reflection->GetMapData(*other_message, - self->parent_field_descriptor); + const internal::MapFieldBase* other_field = other_reflection->GetMapData( + *other_message, other_map->parent_field_descriptor); field->MergeFrom(*other_field); self->version++; Py_RETURN_NONE; diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 3530a9b379..dc2f772250 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -47,7 +47,6 @@ #endif #include #include -#include #include #include #include @@ -63,14 +62,17 @@ #include #include #include -#include #include #include +#include #include #include +#include #include +// clang-format off #include +// clang-format on #if PY_MAJOR_VERSION >= 3 #define PyInt_AsLong PyLong_AsLong diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c index cf1d6e3771..fb25efeba7 100644 --- a/ruby/ext/google/protobuf_c/map.c +++ b/ruby/ext/google/protobuf_c/map.c @@ -71,6 +71,9 @@ static VALUE table_key(Map* self, VALUE key, case UPB_TYPE_BYTES: case UPB_TYPE_STRING: // Strings: use string content directly. + if (TYPE(key) == T_SYMBOL) { + key = rb_id2str(SYM2ID(key)); + } Check_Type(key, T_STRING); key = native_slot_encode_and_freeze_string(self->key_type, key); *out_key = RSTRING_PTR(key); @@ -397,6 +400,11 @@ VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) { void* mem; key = table_key(self, key, keybuf, &keyval, &length); + if (TYPE(value) == T_HASH) { + VALUE args[1] = { value }; + value = rb_class_new_instance(1, args, self->value_type_class); + } + mem = value_memory(&v); native_slot_set("", self->value_type, self->value_type_class, mem, value); diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index 2f02c35445..fd82d863b9 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -192,7 +192,7 @@ static int extract_method_call(VALUE method_name, MessageHeader* self, // Find the field name char wrapper_field_name[name_len - 8]; strncpy(wrapper_field_name, name, name_len - 9); - wrapper_field_name[name_len - 7] = '\0'; + wrapper_field_name[name_len - 9] = '\0'; // Check if field exists and is a wrapper type const upb_oneofdef* test_o_wrapper; @@ -220,7 +220,7 @@ static int extract_method_call(VALUE method_name, MessageHeader* self, // Find enum field name char enum_name[name_len - 5]; strncpy(enum_name, name, name_len - 6); - enum_name[name_len - 4] = '\0'; + enum_name[name_len - 6] = '\0'; // Check if enum field exists const upb_oneofdef* test_o_enum; diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 9ec738ba61..f1b1c6f27c 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -204,6 +204,20 @@ module BasicTest end end + def test_map_field_with_symbol + m = MapMessage.new + assert m.map_string_int32 == {} + assert m.map_string_msg == {} + + m = MapMessage.new( + :map_string_int32 => {a: 1, "b" => 2}, + :map_string_msg => {a: TestMessage2.new(:foo => 1), + b: TestMessage2.new(:foo => 10)}) + assert_equal 1, m.map_string_int32[:a] + assert_equal 2, m.map_string_int32[:b] + assert_equal 10, m.map_string_msg[:b].foo + end + def test_map_inspect m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, diff --git a/ruby/tests/well_known_types_test.rb b/ruby/tests/well_known_types_test.rb index f35f7b13de..3eafe095ad 100644 --- a/ruby/tests/well_known_types_test.rb +++ b/ruby/tests/well_known_types_test.rb @@ -139,4 +139,58 @@ class TestWellKnownTypes < Test::Unit::TestCase assert any.is(Google::Protobuf::Timestamp) assert_equal ts, any.unpack(Google::Protobuf::Timestamp) end + + def test_struct_init + s = Google::Protobuf::Struct.new(fields: {'a' => Google::Protobuf::Value.new({number_value: 4.4})}) + assert_equal 4.4, s['a'] + + s = Google::Protobuf::Struct.new(fields: {'a' => {number_value: 2.2}}) + assert_equal 2.2, s['a'] + + s = Google::Protobuf::Struct.new(fields: {a: {number_value: 1.1}}) + assert_equal 1.1, s[:a] + end + + def test_struct_nested_init + s = Google::Protobuf::Struct.new( + fields: { + 'a' => {string_value: 'A'}, + 'b' => {struct_value: { + fields: { + 'x' => {list_value: {values: [{number_value: 1.0}, {string_value: "ok"}]}}, + 'y' => {bool_value: true}}} + }, + 'c' => {struct_value: {}} + } + ) + assert_equal 'A', s['a'] + assert_equal 'A', s[:a] + expected_b_x = [Google::Protobuf::Value.new(number_value: 1.0), Google::Protobuf::Value.new(string_value: "ok")] + assert_equal expected_b_x, s['b']['x'].values + assert_equal expected_b_x, s[:b][:x].values + assert_equal expected_b_x, s['b'][:x].values + assert_equal expected_b_x, s[:b]['x'].values + assert_equal true, s['b']['y'] + assert_equal true, s[:b][:y] + assert_equal true, s[:b]['y'] + assert_equal true, s['b'][:y] + assert_equal Google::Protobuf::Struct.new, s['c'] + assert_equal Google::Protobuf::Struct.new, s[:c] + + s = Google::Protobuf::Struct.new( + fields: { + a: {string_value: 'Eh'}, + b: {struct_value: { + fields: { + y: {bool_value: false}}} + } + } + ) + assert_equal 'Eh', s['a'] + assert_equal 'Eh', s[:a] + assert_equal false, s['b']['y'] + assert_equal false, s[:b][:y] + assert_equal false, s['b'][:y] + assert_equal false, s[:b]['y'] + end end diff --git a/src/Makefile.am b/src/Makefile.am index dc5070389d..58c9cd88bd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,6 +105,7 @@ nobase_include_HEADERS = \ google/protobuf/has_bits.h \ google/protobuf/implicit_weak_message.h \ google/protobuf/inlined_string_field.h \ + google/protobuf/io/io_win32.h \ google/protobuf/map_entry.h \ google/protobuf/map_entry_lite.h \ google/protobuf/map_field.h \ @@ -184,7 +185,6 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/stubs/int128.cc \ google/protobuf/stubs/int128.h \ google/protobuf/io/io_win32.cc \ - google/protobuf/io/io_win32.h \ google/protobuf/stubs/map_util.h \ google/protobuf/stubs/mathutil.h \ google/protobuf/stubs/status.cc \ @@ -213,7 +213,6 @@ libprotobuf_lite_la_SOURCES = \ google/protobuf/repeated_field.cc \ google/protobuf/wire_format_lite.cc \ google/protobuf/io/coded_stream.cc \ - google/protobuf/io/coded_stream_inl.h \ google/protobuf/io/strtod.cc \ google/protobuf/io/zero_copy_stream.cc \ google/protobuf/io/zero_copy_stream_impl.cc \ @@ -728,6 +727,9 @@ protobuf_test_CPPFLAGS = -I$(GOOGLETEST_SRC_DIR)/include \ # since test_util.cc takes forever to compile with optimization (with GCC). # See configure.ac for more info. protobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS) +# Doesn't pass on Windows with MSVC +NON_MSVC_TEST_SOURCES = \ + google/protobuf/compiler/command_line_interface_unittest.cc protobuf_test_SOURCES = \ google/protobuf/stubs/bytestream_unittest.cc \ google/protobuf/stubs/common_unittest.cc \ @@ -773,7 +775,6 @@ protobuf_test_SOURCES = \ google/protobuf/io/zero_copy_stream_unittest.cc \ google/protobuf/compiler/annotation_test_util.h \ google/protobuf/compiler/annotation_test_util.cc \ - google/protobuf/compiler/command_line_interface_unittest.cc \ google/protobuf/compiler/importer_unittest.cc \ google/protobuf/compiler/mock_code_generator.cc \ google/protobuf/compiler/mock_code_generator.h \ @@ -805,6 +806,7 @@ protobuf_test_SOURCES = \ google/protobuf/util/message_differencer_unittest.cc \ google/protobuf/util/time_util_test.cc \ google/protobuf/util/type_resolver_util_test.cc \ + $(NON_MSVC_TEST_SOURCES) \ $(COMMON_TEST_SOURCES) nodist_protobuf_test_SOURCES = $(protoc_outputs) $(am_protobuf_test_OBJECTS): unittest_proto_middleman diff --git a/src/google/protobuf/any.pb.cc b/src/google/protobuf/any.pb.cc index bd382d1b6d..aa720e3ce1 100644 --- a/src/google/protobuf/any.pb.cc +++ b/src/google/protobuf/any.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Any_google_2fprotobuf_2fany_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Any_google_2fprotobuf_2fany_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; @@ -125,11 +125,11 @@ Any::Any(const Any& from) _any_metadata_(&type_url_, &value_) { _internal_metadata_.MergeFrom(from._internal_metadata_); type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.type_url().empty()) { + if (!from._internal_type_url().empty()) { type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url_); } value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.value().empty()) { + if (!from._internal_value().empty()) { value_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Any) @@ -182,14 +182,14 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern // string type_url = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_type_url(), ptr, ctx, "google.protobuf.Any.type_url"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_type_url(), ptr, ctx, "google.protobuf.Any.type_url"); CHK_(ptr); } else goto handle_unusual; continue; // bytes value = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(mutable_value(), ptr, ctx); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(_internal_mutable_value(), ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; @@ -227,9 +227,9 @@ bool Any::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_type_url())); + input, this->_internal_mutable_type_url())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), static_cast(this->type_url().length()), + this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Any.type_url")); } else { @@ -242,7 +242,7 @@ bool Any::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadBytes( - input, this->mutable_value())); + input, this->_internal_mutable_value())); } else { goto handle_unusual; } @@ -279,17 +279,17 @@ failure: // string type_url = 1; if (this->type_url().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), static_cast(this->type_url().length()), + this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url"); target = stream->WriteStringMaybeAliased( - 1, this->type_url(), target); + 1, this->_internal_type_url(), target); } // bytes value = 2; if (this->value().size() > 0) { target = stream->WriteBytesMaybeAliased( - 2, this->value(), target); + 2, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -312,14 +312,14 @@ size_t Any::ByteSizeLong() const { if (this->type_url().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->type_url()); + this->_internal_type_url()); } // bytes value = 2; if (this->value().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->value()); + this->_internal_value()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 7430dce819..1a69b92166 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -206,6 +206,11 @@ class PROTOBUF_EXPORT Any : std::string* mutable_type_url(); std::string* release_type_url(); void set_allocated_type_url(std::string* type_url); + private: + const std::string& _internal_type_url() const; + void _internal_set_type_url(const std::string& value); + std::string* _internal_mutable_type_url(); + public: // bytes value = 2; void clear_value(); @@ -217,6 +222,11 @@ class PROTOBUF_EXPORT Any : std::string* mutable_value(); std::string* release_value(); void set_allocated_value(std::string* value); + private: + const std::string& _internal_value() const; + void _internal_set_value(const std::string& value); + std::string* _internal_mutable_value(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.Any) private: @@ -246,12 +256,22 @@ inline void Any::clear_type_url() { } inline const std::string& Any::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url) - return type_url_.GetNoArena(); + return _internal_type_url(); } inline void Any::set_type_url(const std::string& value) { + _internal_set_type_url(value); + // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) +} +inline std::string* Any::mutable_type_url() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url) + return _internal_mutable_type_url(); +} +inline const std::string& Any::_internal_type_url() const { + return type_url_.GetNoArena(); +} +inline void Any::_internal_set_type_url(const std::string& value) { type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url) } inline void Any::set_type_url(std::string&& value) { @@ -271,9 +291,8 @@ inline void Any::set_type_url(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url) } -inline std::string* Any::mutable_type_url() { +inline std::string* Any::_internal_mutable_type_url() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url) return type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Any::release_type_url() { @@ -297,12 +316,22 @@ inline void Any::clear_value() { } inline const std::string& Any::value() const { // @@protoc_insertion_point(field_get:google.protobuf.Any.value) - return value_.GetNoArena(); + return _internal_value(); } inline void Any::set_value(const std::string& value) { + _internal_set_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.Any.value) +} +inline std::string* Any::mutable_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value) + return _internal_mutable_value(); +} +inline const std::string& Any::_internal_value() const { + return value_.GetNoArena(); +} +inline void Any::_internal_set_value(const std::string& value) { value_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Any.value) } inline void Any::set_value(std::string&& value) { @@ -322,9 +351,8 @@ inline void Any::set_value(const void* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value) } -inline std::string* Any::mutable_value() { +inline std::string* Any::_internal_mutable_value() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value) return value_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Any::release_value() { diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc index 7403ed3fda..7839381337 100644 --- a/src/google/protobuf/any_lite.cc +++ b/src/google/protobuf/any_lite.cc @@ -35,7 +35,6 @@ #include #include - namespace google { namespace protobuf { namespace internal { diff --git a/src/google/protobuf/any_test.cc b/src/google/protobuf/any_test.cc index 4fbf0b630e..0d8893f7b8 100644 --- a/src/google/protobuf/any_test.cc +++ b/src/google/protobuf/any_test.cc @@ -33,7 +33,6 @@ #include - namespace google { namespace protobuf { namespace { diff --git a/src/google/protobuf/api.pb.cc b/src/google/protobuf/api.pb.cc index 123026facf..1c943d13ad 100644 --- a/src/google/protobuf/api.pb.cc +++ b/src/google/protobuf/api.pb.cc @@ -44,7 +44,7 @@ static void InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<4> scc_info_Api_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 4, InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 4, 0, InitDefaultsscc_info_Api_google_2fprotobuf_2fapi_2eproto}, { &scc_info_Method_google_2fprotobuf_2fapi_2eproto.base, &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base, &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base, @@ -62,7 +62,7 @@ static void InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Method_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Method_google_2fprotobuf_2fapi_2eproto}, { &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}}; static void InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto() { @@ -77,7 +77,7 @@ static void InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Mixin_google_2fprotobuf_2fapi_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Mixin_google_2fprotobuf_2fapi_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; @@ -208,11 +208,11 @@ Api::Api(const Api& from) mixins_(from.mixins_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { + if (!from._internal_name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.version().empty()) { + if (!from._internal_version().empty()) { version_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.version_); } if (from.has_source_context()) { @@ -283,7 +283,7 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Api.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Api.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -296,7 +296,7 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern ptr = ctx->ParseMessage(add_methods(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.Option options = 3; @@ -308,13 +308,13 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; // string version = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_version(), ptr, ctx, "google.protobuf.Api.version"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_version(), ptr, ctx, "google.protobuf.Api.version"); CHK_(ptr); } else goto handle_unusual; continue; @@ -334,7 +334,7 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern ptr = ctx->ParseMessage(add_mixins(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 50); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; // .google.protobuf.Syntax syntax = 7; @@ -379,9 +379,9 @@ bool Api::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Api.name")); } else { @@ -416,9 +416,9 @@ bool Api::MergePartialFromCodedStream( case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (34 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_version())); + input, this->_internal_mutable_version())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->version().data(), static_cast(this->version().length()), + this->_internal_version().data(), static_cast(this->_internal_version().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Api.version")); } else { @@ -493,24 +493,24 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.Method methods = 2; - for (auto it = this->methods().pointer_begin(), - end = this->methods().pointer_end(); it < end; ++it) { + for (auto it = this->methods_.pointer_begin(), + end = this->methods_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); } // repeated .google.protobuf.Option options = 3; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(3, **it, target, stream); @@ -519,11 +519,11 @@ failure: // string version = 4; if (this->version().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->version().data(), static_cast(this->version().length()), + this->_internal_version().data(), static_cast(this->_internal_version().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version"); target = stream->WriteStringMaybeAliased( - 4, this->version(), target); + 4, this->_internal_version(), target); } // .google.protobuf.SourceContext source_context = 5; @@ -535,8 +535,8 @@ failure: } // repeated .google.protobuf.Mixin mixins = 6; - for (auto it = this->mixins().pointer_begin(), - end = this->mixins().pointer_end(); it < end; ++it) { + for (auto it = this->mixins_.pointer_begin(), + end = this->mixins_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(6, **it, target, stream); @@ -566,50 +566,38 @@ size_t Api::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Method methods = 2; - { - unsigned int count = static_cast(this->methods_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->methods(static_cast(i))); - } + total_size += 1UL * this->methods_size(); + for (const auto& msg : this->methods_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Option options = 3; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Mixin mixins = 6; - { - unsigned int count = static_cast(this->mixins_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->mixins(static_cast(i))); - } + total_size += 1UL * this->mixins_size(); + for (const auto& msg : this->mixins_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // string version = 4; if (this->version().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->version()); + this->_internal_version()); } // .google.protobuf.SourceContext source_context = 5; @@ -696,9 +684,9 @@ bool Api::IsInitialized() const { void Api::InternalSwap(Api* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&methods_)->InternalSwap(CastToBase(&other->methods_)); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); - CastToBase(&mixins_)->InternalSwap(CastToBase(&other->mixins_)); + methods_.InternalSwap(&other->methods_); + options_.InternalSwap(&other->options_); + mixins_.InternalSwap(&other->mixins_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); version_.Swap(&other->version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -734,15 +722,15 @@ Method::Method(const Method& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { + if (!from._internal_name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } request_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.request_type_url().empty()) { + if (!from._internal_request_type_url().empty()) { request_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.request_type_url_); } response_type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.response_type_url().empty()) { + if (!from._internal_response_type_url().empty()) { response_type_url_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.response_type_url_); } ::memcpy(&request_streaming_, &from.request_streaming_, @@ -808,14 +796,14 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Method.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Method.name"); CHK_(ptr); } else goto handle_unusual; continue; // string request_type_url = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_request_type_url(), ptr, ctx, "google.protobuf.Method.request_type_url"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_request_type_url(), ptr, ctx, "google.protobuf.Method.request_type_url"); CHK_(ptr); } else goto handle_unusual; continue; @@ -829,7 +817,7 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int // string response_type_url = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_response_type_url(), ptr, ctx, "google.protobuf.Method.response_type_url"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_response_type_url(), ptr, ctx, "google.protobuf.Method.response_type_url"); CHK_(ptr); } else goto handle_unusual; continue; @@ -849,7 +837,7 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 50); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; // .google.protobuf.Syntax syntax = 7; @@ -894,9 +882,9 @@ bool Method::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Method.name")); } else { @@ -909,9 +897,9 @@ bool Method::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_request_type_url())); + input, this->_internal_mutable_request_type_url())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->request_type_url().data(), static_cast(this->request_type_url().length()), + this->_internal_request_type_url().data(), static_cast(this->_internal_request_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Method.request_type_url")); } else { @@ -937,9 +925,9 @@ bool Method::MergePartialFromCodedStream( case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (34 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_response_type_url())); + input, this->_internal_mutable_response_type_url())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->response_type_url().data(), static_cast(this->response_type_url().length()), + this->_internal_response_type_url().data(), static_cast(this->_internal_response_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Method.response_type_url")); } else { @@ -1016,21 +1004,21 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // string request_type_url = 2; if (this->request_type_url().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->request_type_url().data(), static_cast(this->request_type_url().length()), + this->_internal_request_type_url().data(), static_cast(this->_internal_request_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url"); target = stream->WriteStringMaybeAliased( - 2, this->request_type_url(), target); + 2, this->_internal_request_type_url(), target); } // bool request_streaming = 3; @@ -1042,11 +1030,11 @@ failure: // string response_type_url = 4; if (this->response_type_url().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->response_type_url().data(), static_cast(this->response_type_url().length()), + this->_internal_response_type_url().data(), static_cast(this->_internal_response_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url"); target = stream->WriteStringMaybeAliased( - 4, this->response_type_url(), target); + 4, this->_internal_response_type_url(), target); } // bool response_streaming = 5; @@ -1056,8 +1044,8 @@ failure: } // repeated .google.protobuf.Option options = 6; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(6, **it, target, stream); @@ -1087,35 +1075,31 @@ size_t Method::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Option options = 6; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // string request_type_url = 2; if (this->request_type_url().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->request_type_url()); + this->_internal_request_type_url()); } // string response_type_url = 4; if (this->response_type_url().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->response_type_url()); + this->_internal_response_type_url()); } // bool request_streaming = 3; @@ -1210,7 +1194,7 @@ bool Method::IsInitialized() const { void Method::InternalSwap(Method* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + options_.InternalSwap(&other->options_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); request_type_url_.Swap(&other->request_type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -1245,11 +1229,11 @@ Mixin::Mixin(const Mixin& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { + if (!from._internal_name().empty()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.root().empty()) { + if (!from._internal_root().empty()) { root_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.root_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin) @@ -1302,14 +1286,14 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Mixin.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Mixin.name"); CHK_(ptr); } else goto handle_unusual; continue; // string root = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_root(), ptr, ctx, "google.protobuf.Mixin.root"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_root(), ptr, ctx, "google.protobuf.Mixin.root"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1347,9 +1331,9 @@ bool Mixin::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Mixin.name")); } else { @@ -1362,9 +1346,9 @@ bool Mixin::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_root())); + input, this->_internal_mutable_root())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->root().data(), static_cast(this->root().length()), + this->_internal_root().data(), static_cast(this->_internal_root().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Mixin.root")); } else { @@ -1403,21 +1387,21 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // string root = 2; if (this->root().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->root().data(), static_cast(this->root().length()), + this->_internal_root().data(), static_cast(this->_internal_root().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root"); target = stream->WriteStringMaybeAliased( - 2, this->root(), target); + 2, this->_internal_root(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1440,14 +1424,14 @@ size_t Mixin::ByteSizeLong() const { if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // string root = 2; if (this->root().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->root()); + this->_internal_root()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 836641f81c..4e2a745b56 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -238,6 +238,11 @@ class PROTOBUF_EXPORT Api : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // string version = 4; void clear_version(); @@ -249,9 +254,17 @@ class PROTOBUF_EXPORT Api : std::string* mutable_version(); std::string* release_version(); void set_allocated_version(std::string* version); + private: + const std::string& _internal_version() const; + void _internal_set_version(const std::string& value); + std::string* _internal_mutable_version(); + public: // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; + private: + bool _internal_has_source_context() const; + public: void clear_source_context(); const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); @@ -420,6 +433,11 @@ class PROTOBUF_EXPORT Method : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // string request_type_url = 2; void clear_request_type_url(); @@ -431,6 +449,11 @@ class PROTOBUF_EXPORT Method : std::string* mutable_request_type_url(); std::string* release_request_type_url(); void set_allocated_request_type_url(std::string* request_type_url); + private: + const std::string& _internal_request_type_url() const; + void _internal_set_request_type_url(const std::string& value); + std::string* _internal_mutable_request_type_url(); + public: // string response_type_url = 4; void clear_response_type_url(); @@ -442,6 +465,11 @@ class PROTOBUF_EXPORT Method : std::string* mutable_response_type_url(); std::string* release_response_type_url(); void set_allocated_response_type_url(std::string* response_type_url); + private: + const std::string& _internal_response_type_url() const; + void _internal_set_response_type_url(const std::string& value); + std::string* _internal_mutable_response_type_url(); + public: // bool request_streaming = 3; void clear_request_streaming(); @@ -599,6 +627,11 @@ class PROTOBUF_EXPORT Mixin : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // string root = 2; void clear_root(); @@ -610,6 +643,11 @@ class PROTOBUF_EXPORT Mixin : std::string* mutable_root(); std::string* release_root(); void set_allocated_root(std::string* root); + private: + const std::string& _internal_root() const; + void _internal_set_root(const std::string& value); + std::string* _internal_mutable_root(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.Mixin) private: @@ -638,12 +676,22 @@ inline void Api::clear_name() { } inline const std::string& Api::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.name) - return name_.GetNoArena(); + return _internal_name(); } inline void Api::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Api.name) +} +inline std::string* Api::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name) + return _internal_mutable_name(); +} +inline const std::string& Api::_internal_name() const { + return name_.GetNoArena(); +} +inline void Api::_internal_set_name(const std::string& value) { name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Api.name) } inline void Api::set_name(std::string&& value) { @@ -663,9 +711,8 @@ inline void Api::set_name(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name) } -inline std::string* Api::mutable_name() { +inline std::string* Api::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name) return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Api::release_name() { @@ -746,12 +793,22 @@ inline void Api::clear_version() { } inline const std::string& Api::version() const { // @@protoc_insertion_point(field_get:google.protobuf.Api.version) - return version_.GetNoArena(); + return _internal_version(); } inline void Api::set_version(const std::string& value) { + _internal_set_version(value); + // @@protoc_insertion_point(field_set:google.protobuf.Api.version) +} +inline std::string* Api::mutable_version() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version) + return _internal_mutable_version(); +} +inline const std::string& Api::_internal_version() const { + return version_.GetNoArena(); +} +inline void Api::_internal_set_version(const std::string& value) { version_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Api.version) } inline void Api::set_version(std::string&& value) { @@ -771,9 +828,8 @@ inline void Api::set_version(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version) } -inline std::string* Api::mutable_version() { +inline std::string* Api::_internal_mutable_version() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version) return version_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Api::release_version() { @@ -890,12 +946,22 @@ inline void Method::clear_name() { } inline const std::string& Method::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Method.name) - return name_.GetNoArena(); + return _internal_name(); } inline void Method::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Method.name) +} +inline std::string* Method::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name) + return _internal_mutable_name(); +} +inline const std::string& Method::_internal_name() const { + return name_.GetNoArena(); +} +inline void Method::_internal_set_name(const std::string& value) { name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.name) } inline void Method::set_name(std::string&& value) { @@ -915,9 +981,8 @@ inline void Method::set_name(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name) } -inline std::string* Method::mutable_name() { +inline std::string* Method::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name) return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Method::release_name() { @@ -941,12 +1006,22 @@ inline void Method::clear_request_type_url() { } 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(); + return _internal_request_type_url(); } inline void Method::set_request_type_url(const std::string& value) { + _internal_set_request_type_url(value); + // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) +} +inline std::string* Method::mutable_request_type_url() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url) + return _internal_mutable_request_type_url(); +} +inline const std::string& Method::_internal_request_type_url() const { + return request_type_url_.GetNoArena(); +} +inline void Method::_internal_set_request_type_url(const std::string& value) { request_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url) } inline void Method::set_request_type_url(std::string&& value) { @@ -966,9 +1041,8 @@ inline void Method::set_request_type_url(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url) } -inline std::string* Method::mutable_request_type_url() { +inline std::string* Method::_internal_mutable_request_type_url() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url) return request_type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Method::release_request_type_url() { @@ -1006,12 +1080,22 @@ inline void Method::clear_response_type_url() { } 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(); + return _internal_response_type_url(); } inline void Method::set_response_type_url(const std::string& value) { + _internal_set_response_type_url(value); + // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) +} +inline std::string* Method::mutable_response_type_url() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url) + return _internal_mutable_response_type_url(); +} +inline const std::string& Method::_internal_response_type_url() const { + return response_type_url_.GetNoArena(); +} +inline void Method::_internal_set_response_type_url(const std::string& value) { response_type_url_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url) } inline void Method::set_response_type_url(std::string&& value) { @@ -1031,9 +1115,8 @@ inline void Method::set_response_type_url(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url) } -inline std::string* Method::mutable_response_type_url() { +inline std::string* Method::_internal_mutable_response_type_url() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url) return response_type_url_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Method::release_response_type_url() { @@ -1116,12 +1199,22 @@ inline void Mixin::clear_name() { } inline const std::string& Mixin::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name) - return name_.GetNoArena(); + return _internal_name(); } inline void Mixin::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) +} +inline std::string* Mixin::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name) + return _internal_mutable_name(); +} +inline const std::string& Mixin::_internal_name() const { + return name_.GetNoArena(); +} +inline void Mixin::_internal_set_name(const std::string& value) { name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name) } inline void Mixin::set_name(std::string&& value) { @@ -1141,9 +1234,8 @@ inline void Mixin::set_name(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name) } -inline std::string* Mixin::mutable_name() { +inline std::string* Mixin::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name) return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Mixin::release_name() { @@ -1167,12 +1259,22 @@ inline void Mixin::clear_root() { } inline const std::string& Mixin::root() const { // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root) - return root_.GetNoArena(); + return _internal_root(); } inline void Mixin::set_root(const std::string& value) { + _internal_set_root(value); + // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) +} +inline std::string* Mixin::mutable_root() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root) + return _internal_mutable_root(); +} +inline const std::string& Mixin::_internal_root() const { + return root_.GetNoArena(); +} +inline void Mixin::_internal_set_root(const std::string& value) { root_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root) } inline void Mixin::set_root(std::string&& value) { @@ -1192,9 +1294,8 @@ inline void Mixin::set_root(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root) } -inline std::string* Mixin::mutable_root() { +inline std::string* Mixin::_internal_mutable_root() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root) return root_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Mixin::release_root() { diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index d38aed7d1f..620e187b60 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -50,9 +50,9 @@ using type_info = ::type_info; #include #endif -#include #include #include +#include #include diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index e544e2db8f..8222d7dcbc 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -70,7 +70,6 @@ #include #include #include -#include #include #include #include @@ -79,8 +78,7 @@ #include #include #include - - +#include #include #include diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 6ea25652d5..01e69ee38e 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -45,22 +45,21 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include #include #include - -#include #include #include +#include #include diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc index 97be5e6426..8a661ea7c9 100644 --- a/src/google/protobuf/compiler/cpp/cpp_extension.cc +++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc @@ -39,8 +39,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index 72d6fa27a6..e9b1d42165 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -38,7 +38,6 @@ #include #include #include - #include #include #include diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 3db64b4f4c..8449b3573c 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -51,8 +51,6 @@ #include #include - - #include namespace google { @@ -440,17 +438,22 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* printer) { Formatter format(printer, variables_); + MessageGenerator* generator = message_generators_[idx].get(); format( "class $1$ {\n" " public:\n" " ::$proto_ns$::internal::ExplicitlyConstructed<$2$> _instance;\n", - DefaultInstanceType(message_generators_[idx]->descriptor_, options_), - message_generators_[idx]->classname_); + DefaultInstanceType(generator->descriptor_, options_), + generator->classname_); format.Indent(); - message_generators_[idx]->GenerateExtraDefaultFields(printer); + generator->GenerateExtraDefaultFields(printer); format.Outdent(); - format("} $1$;\n", - DefaultInstanceName(message_generators_[idx]->descriptor_, options_)); + format("} $1$;\n", DefaultInstanceName(generator->descriptor_, options_)); + if (options_.lite_implicit_weak_fields) { + format("$1$DefaultTypeInternal* $2$ = &$3$;\n", generator->classname_, + DefaultInstancePtr(generator->descriptor_, options_), + DefaultInstanceName(generator->descriptor_, options_)); + } } // A list of things defined in one .pb.cc file that we need to reference from @@ -513,19 +516,43 @@ void FileGenerator::GenerateInternalForwardDeclarations( } for (auto scc : Sorted(refs.weak_sccs)) { - format( - "extern __attribute__((weak)) ::$proto_ns$::internal::SCCInfo<$1$> " - "$2$;\n", - scc->children.size(), SccInfoSymbol(scc, options_)); + // We do things a little bit differently for proto1-style weak fields versus + // lite implicit weak fields, even though they are trying to accomplish + // similar things. We need to support implicit weak fields on iOS, and the + // Apple linker only supports weak definitions, not weak declarations. For + // that reason we need a pointer type which we can weakly define to be null. + // However, code size considerations prevent us from using the same approach + // for proto1-style weak fields. + if (options_.lite_implicit_weak_fields) { + format("extern ::$proto_ns$::internal::SCCInfo<$1$> $2$;\n", + scc->children.size(), SccInfoSymbol(scc, options_)); + format( + "__attribute__((weak)) ::$proto_ns$::internal::SCCInfo<$1$>*\n" + " $2$ = nullptr;\n", + scc->children.size(), SccInfoPtrSymbol(scc, options_)); + } else { + format( + "extern __attribute__((weak)) ::$proto_ns$::internal::SCCInfo<$1$> " + "$2$;\n", + scc->children.size(), SccInfoSymbol(scc, options_)); + } } { NamespaceOpener ns(format); for (auto instance : Sorted(refs.weak_default_instances)) { ns.ChangeTo(Namespace(instance, options_)); - format("extern __attribute__((weak)) $1$ $2$;\n", - DefaultInstanceType(instance, options_), - DefaultInstanceName(instance, options_)); + if (options_.lite_implicit_weak_fields) { + format("extern $1$ $2$;\n", DefaultInstanceType(instance, options_), + DefaultInstanceName(instance, options_)); + format("__attribute__((weak)) $1$* $2$ = nullptr;\n", + DefaultInstanceType(instance, options_), + DefaultInstancePtr(instance, options_)); + } else { + format("extern __attribute__((weak)) $1$ $2$;\n", + DefaultInstanceType(instance, options_), + DefaultInstanceName(instance, options_)); + } } } @@ -555,7 +582,8 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { GenerateInternalForwardDeclarations(refs, printer); if (IsSCCRepresentative(message_generators_[idx]->descriptor_)) { - GenerateInitForSCC(GetSCC(message_generators_[idx]->descriptor_), printer); + GenerateInitForSCC(GetSCC(message_generators_[idx]->descriptor_), refs, + printer); } { // package namespace @@ -649,7 +677,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // Now generate the InitDefaults for each SCC. for (auto scc : sccs_) { - GenerateInitForSCC(scc, printer); + GenerateInitForSCC(scc, refs, printer); } if (HasDescriptorMethods(file_, options_)) { @@ -904,7 +932,9 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { } } -void FileGenerator::GenerateInitForSCC(const SCC* scc, io::Printer* printer) { +void FileGenerator::GenerateInitForSCC(const SCC* scc, + const CrossFileReferences& refs, + io::Printer* printer) { Formatter format(printer, variables_); // We use static and not anonymous namespace because symbol names are // substantially shorter. @@ -954,17 +984,46 @@ void FileGenerator::GenerateInitForSCC(const SCC* scc, io::Printer* printer) { format.Outdent(); format("}\n\n"); + // If we are using lite implicit weak fields then we need to distinguish + // between regular SCC dependencies and ones that we need to reference weakly + // through an extra pointer indirection. + std::vector regular_sccs; + std::vector implicit_weak_sccs; + for (const SCC* child : scc->children) { + if (options_.lite_implicit_weak_fields && + refs.weak_sccs.find(child) != refs.weak_sccs.end()) { + implicit_weak_sccs.push_back(child); + } else { + regular_sccs.push_back(child); + } + } + format( "$dllexport_decl $::$proto_ns$::internal::SCCInfo<$1$> $2$ =\n" " " "{{ATOMIC_VAR_INIT(::$proto_ns$::internal::SCCInfoBase::kUninitialized), " - "$1$, InitDefaults$2$}, {", + "$3$, $4$, InitDefaults$2$}, {", scc->children.size(), // 1 - SccInfoSymbol(scc, options_)); - for (const SCC* child : scc->children) { + SccInfoSymbol(scc, options_), regular_sccs.size(), + implicit_weak_sccs.size()); + for (const SCC* child : regular_sccs) { format("\n &$1$.base,", SccInfoSymbol(child, options_)); } + for (const SCC* child : implicit_weak_sccs) { + format( + "\n reinterpret_cast<::$proto_ns$::internal::SCCInfoBase**>(" + "\n &$1$),", + SccInfoPtrSymbol(child, options_)); + } format("}};\n\n"); + + if (options_.lite_implicit_weak_fields) { + format( + "$dllexport_decl $::$proto_ns$::internal::SCCInfo<$1$>*\n" + " $2$ = &$3$;\n\n", + scc->children.size(), SccInfoPtrSymbol(scc, options_), + SccInfoSymbol(scc, options_)); + } } void FileGenerator::GenerateTables(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index 33734c5418..e81af42aac 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -113,7 +113,8 @@ class FileGenerator { void GenerateSourceIncludes(io::Printer* printer); void GenerateSourceDefaultInstance(int idx, io::Printer* printer); - void GenerateInitForSCC(const SCC* scc, io::Printer* printer); + void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs, + io::Printer* printer); void GenerateTables(io::Printer* printer); void GenerateReflectionInitializationCode(io::Printer* printer); diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc index 7de07652ba..0d80ea2799 100644 --- a/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -45,8 +45,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 624bbd37a2..8f9b89c36e 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -44,7 +44,6 @@ #include #include #include - #include #include #include @@ -52,8 +51,6 @@ #include #include #include - - #include #include @@ -204,6 +201,10 @@ void SetIntVar(const Options& options, const std::string& type, (*variables)[type] = IntTypeName(options, type); } +bool HasInternalAccessors(const FieldOptions::CType ctype) { + return ctype == FieldOptions::STRING; +} + } // namespace void SetCommonVars(const Options& options, @@ -373,12 +374,22 @@ std::string DefaultInstanceName(const Descriptor* descriptor, return "_" + ClassName(descriptor, false) + "_default_instance_"; } +std::string DefaultInstancePtr(const Descriptor* descriptor, + const Options& options) { + return DefaultInstanceName(descriptor, options) + "ptr_"; +} + std::string QualifiedDefaultInstanceName(const Descriptor* descriptor, const Options& options) { return QualifiedFileLevelSymbol( descriptor->file(), DefaultInstanceName(descriptor, options), options); } +std::string QualifiedDefaultInstancePtr(const Descriptor* descriptor, + const Options& options) { + return QualifiedDefaultInstanceName(descriptor, options) + "ptr_"; +} + std::string DescriptorTableName(const FileDescriptor* file, const Options& options) { return UniqueName("descriptor_table", file, options); @@ -1125,7 +1136,7 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, MessageSCCAnalyzer* scc_analyzer) { return UsingImplicitWeakFields(field->file(), options) && field->type() == FieldDescriptor::TYPE_MESSAGE && - !field->is_required() && !field->is_map() && + !field->is_required() && !field->is_map() && !field->is_extension() && field->containing_oneof() == nullptr && !IsWellKnownMessage(field->message_type()->file()) && field->message_type()->file()->name() != @@ -1479,7 +1490,8 @@ class ParseLoopGenerator { name = "StringPieceParser" + utf8; break; } - format_("ptr = $pi_ns$::Inline$1$($2$_$3$(), ptr, ctx$4$);\n", name, + format_("ptr = $pi_ns$::Inline$1$($2$$3$_$4$(), ptr, ctx$5$);\n", name, + HasInternalAccessors(ctype) ? "_internal_" : "", field->is_repeated() && !field->is_packable() ? "add" : "mutable", FieldName(field), field_name); } @@ -1551,10 +1563,9 @@ class ParseLoopGenerator { FieldName(field)); } else { format_( - "ptr = ctx->ParseMessage(" - "CastToBase(&$1$_)->AddWeak(reinterpret_cast(&$2$::_$3$_default_instance_)), " - "ptr);\n", + "ptr = ctx->ParseMessage($1$_.AddWeak(reinterpret_cast($2$::_$3$_default_instance_ptr_)" + "), ptr);\n", FieldName(field), Namespace(field->message_type(), options_), ClassName(field->message_type())); } @@ -1757,12 +1768,11 @@ class ParseLoopGenerator { } GenerateFieldBody(wiretype, field); if (is_repeat) { - string type = tag_size == 2 ? "uint16" : "uint8"; format_.Outdent(); format_( " if (!ctx->DataAvailable(ptr)) break;\n" - "} while ($pi_ns$::UnalignedLoad<$1$>(ptr) == $2$);\n", - IntTypeName(options_, type), SmallVarintValue(tag)); + "} while ($pi_ns$::ExpectTag<$1$>(ptr));\n", + tag); } format_.Outdent(); if (fallback_tag) { diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index fd518e0780..abb3979daf 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -49,7 +49,6 @@ #include #include - #include namespace google { @@ -133,10 +132,19 @@ std::string DefaultInstanceType(const Descriptor* descriptor, std::string DefaultInstanceName(const Descriptor* descriptor, const Options& options); +// Non-qualified name of the default instance pointer. This is used only for +// implicit weak fields, where we need an extra indirection. +std::string DefaultInstancePtr(const Descriptor* descriptor, + const Options& options); + // Fully qualified name of the default_instance of this message. std::string QualifiedDefaultInstanceName(const Descriptor* descriptor, const Options& options); +// Fully qualified name of the default instance pointer. +std::string QualifiedDefaultInstancePtr(const Descriptor* descriptor, + const Options& options); + // DescriptorTable variable name. std::string DescriptorTableName(const FileDescriptor* file, const Options& options); @@ -549,6 +557,11 @@ inline std::string SccInfoSymbol(const SCC* scc, const Options& options) { scc->GetRepresentative(), options); } +inline std::string SccInfoPtrSymbol(const SCC* scc, const Options& options) { + return UniqueName("scc_info_ptr_" + ClassName(scc->GetRepresentative()), + scc->GetRepresentative(), options); +} + void ListAllFields(const Descriptor* d, std::vector* fields); void ListAllFields(const FileDescriptor* d, diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 8dba16379f..a02dd19959 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -55,8 +55,6 @@ #include #include #include - - #include @@ -738,7 +736,12 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { if (field->is_repeated()) { format("$deprecated_attr$int ${1$$name$_size$}$() const;\n", field); } else if (HasHasMethod(field)) { - format("$deprecated_attr$bool ${1$has_$name$$}$() const;\n", field); + format( + "$deprecated_attr$bool ${1$has_$name$$}$() const;\n" + "private:\n" + "bool _internal_has_$name$() const;\n" + "public:\n", + field); } else if (HasPrivateHasMethod(field)) { format( "private:\n" @@ -800,9 +803,12 @@ void MessageGenerator::GenerateSingularFieldHasBits( format.Set("has_mask", strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); format( + "inline bool $classname$::_internal_has_$name$() const {\n" + " return (_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n" + "}\n" "inline bool $classname$::has_$name$() const {\n" "$annotate_accessor$" - " return (_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\n" + " return _internal_has_$name$();\n" "}\n"); } else { // Message fields have a has_$name$() method. @@ -849,13 +855,28 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, // Oneofs also have has_$name$() but only as a private helper // method, so that generated code is slightly cleaner (vs. comparing // _oneof_case_[index] against a constant everywhere). + // + // If has_$name$() is private, there is no need to add an internal accessor. + // Only annotate public accessors. + if (HasPrivateHasMethod(field)) { + format( + "inline bool $classname$::has_$name$() const {\n" + " return $oneof_name$_case() == k$field_name$;\n" + "}\n"); + } else { + format( + "inline bool $classname$::_internal_has_$name$() const {\n" + " return $oneof_name$_case() == k$field_name$;\n" + "}\n" + "inline bool $classname$::has_$name$() const {\n" + "$annotate_accessor$" + " return _internal_has_$name$();\n" + "}\n"); + } + // set_has_$name$() for oneof fields is always private; hence should not be + // annotated. format( - "inline bool $classname$::has_$name$() const {\n" - "$annotate_accessor$" - " return $oneof_name$_case() == k$field_name$;\n" - "}\n" "inline void $classname$::set_has_$name$() {\n" - "$annotate_accessor$" " _oneof_case_[$oneof_index$] = k$field_name$;\n" "}\n"); } @@ -918,8 +939,12 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) { format( "inline int $classname$::$name$_size() const {\n" "$annotate_accessor$" - " return $name$_.size();\n" - "}\n"); + " return $name$_$1$.size();\n" + "}\n", + IsImplicitWeakField(field, options_, scc_analyzer_) && + field->message_type() + ? ".weak" + : ""); } else if (field->containing_oneof()) { format.Set("field_name", UnderscoresToCamelCase(field->name(), true)); format.Set("oneof_name", field->containing_oneof()->name()); @@ -1943,10 +1968,18 @@ void MessageGenerator::GenerateDefaultInstanceInitializer( options_)); // 1 continue; } - format( - "$package_ns$::$name$_ = const_cast< $1$*>(\n" - " $1$::internal_default_instance());\n", - FieldMessageTypeName(field, options_)); + if (IsImplicitWeakField(field, options_, scc_analyzer_)) { + format( + "$package_ns$::$name$_ = reinterpret_cast<$1$*>(\n" + " $2$);\n", + FieldMessageTypeName(field, options_), + QualifiedDefaultInstancePtr(field->message_type(), options_)); + } else { + format( + "$package_ns$::$name$_ = const_cast< $1$*>(\n" + " $1$::internal_default_instance());\n", + FieldMessageTypeName(field, options_)); + } } else if (field->containing_oneof() && HasDescriptorMethods(descriptor_->file(), options_)) { field_generators_.get(field).GenerateConstructorCode(printer); @@ -4295,7 +4328,9 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { if (field->is_repeated()) { if (IsImplicitWeakField(field, options_, scc_analyzer_)) { format( - "if (!::$proto_ns$::internal::AllAreInitializedWeak(this->$1$_))" + "if " + "(!::$proto_ns$::internal::AllAreInitializedWeak(this->$1$_.weak)" + ")" " return false;\n", FieldName(field)); } else { diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 7d621e08a6..d8d5fdbd7a 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -62,6 +62,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, (*variables)["type"] + "*", (*variables)["name"] + "_", implicit_weak); (*variables)["type_default_instance"] = QualifiedDefaultInstanceName(descriptor->message_type(), options); + (*variables)["type_default_instance_ptr"] = + QualifiedDefaultInstancePtr(descriptor->message_type(), options); (*variables)["type_reference_function"] = implicit_weak ? (" " + ReferenceFunctionName(descriptor->message_type(), options) + @@ -149,47 +151,40 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions( format( "inline const $type$& $classname$::$name$() const {\n" "$annotate_accessor$" + "$type_reference_function$" " const $type$* p = $casted_member$;\n" " // @@protoc_insertion_point(field_get:$full_name$)\n" " return p != nullptr ? *p : *reinterpret_cast(\n" " &$type_default_instance$);\n" "}\n"); - format( - "inline $type$* $classname$::$release_name$() {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_release:$full_name$)\n" - "$type_reference_function$" - " $clear_hasbit$\n" - " $type$* temp = $casted_member$;\n"); if (SupportsArenas(descriptor_)) { format( + "inline $type$* $classname$::$release_name$() {\n" + " auto temp = unsafe_arena_release_$name$();\n" " if (GetArenaNoVirtual() != nullptr) {\n" " temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n" - " }\n"); + " }\n" + " return temp;\n" + "}\n" + "inline $type$* $classname$::unsafe_arena_release_$name$() {\n"); + } else { + format("inline $type$* $classname$::$release_name$() {\n"); } format( + "$annotate_accessor$" + " // @@protoc_insertion_point(field_release:$full_name$)\n" + "$type_reference_function$" + " $clear_hasbit$\n" + " $type$* temp = $casted_member$;\n" " $name$_ = nullptr;\n" " return temp;\n" "}\n"); - if (SupportsArenas(descriptor_)) { - format( - "inline $type$* $classname$::unsafe_arena_release_$name$() {\n" - "$annotate_accessor$" - " // " - "@@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\n" - "$type_reference_function$" - " $clear_hasbit$\n" - " $type$* temp = $casted_member$;\n" - " $name$_ = nullptr;\n" - " return temp;\n" - "}\n"); - } - format( "inline $type$* $classname$::mutable_$name$() {\n" "$annotate_accessor$" + "$type_reference_function$" " $set_hasbit$\n" " if ($name$_ == nullptr) {\n" " auto* p = CreateMaybeMessage<$type$>(GetArenaNoVirtual());\n"); @@ -283,9 +278,9 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( " const $classname$* msg) {\n" " if (msg->$name$_ != nullptr) {\n" " return *msg->$name$_;\n" - " } else if (&$type_default_instance$ != nullptr) {\n" + " } else if ($type_default_instance_ptr$ != nullptr) {\n" " return *reinterpret_cast(\n" - " &$type_default_instance$);\n" + " $type_default_instance_ptr$);\n" " } else {\n" " return " "*::$proto_ns$::internal::ImplicitWeakMessage::default_instance();\n" @@ -300,14 +295,14 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( } format( " if (msg->$name$_ == nullptr) {\n" - " if (&$type_default_instance$ == nullptr) {\n" + " if ($type_default_instance_ptr$ == nullptr) {\n" " msg->$name$_ = ::$proto_ns$::Arena::CreateMessage<\n" " ::$proto_ns$::internal::ImplicitWeakMessage>(\n" " msg->GetArenaNoVirtual());\n" " } else {\n" " msg->$name$_ = reinterpret_cast(\n" - " &$type_default_instance$)->New(" + " $type_default_instance_ptr$)->New(" "msg->GetArenaNoVirtual());\n" " }\n" " }\n" @@ -322,13 +317,13 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions( } format( " if (msg->$name$_ == nullptr) {\n" - " if (&$type_default_instance$ == nullptr) {\n" + " if ($type_default_instance_ptr$ == nullptr) {\n" " msg->$name$_ = " "new ::$proto_ns$::internal::ImplicitWeakMessage;\n" " } else {\n" " msg->$name$_ = " "reinterpret_cast(\n" - " &$type_default_instance$)->New();\n" + " $type_default_instance_ptr$)->New();\n" " }\n" " }\n" " return msg->$name$_;\n" @@ -637,7 +632,11 @@ RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {} void RepeatedMessageFieldGenerator::GeneratePrivateMembers( io::Printer* printer) const { Formatter format(printer, variables_); - format("::$proto_ns$::RepeatedPtrField< $type$ > $name$_;\n"); + if (implicit_weak_field_) { + format("::$proto_ns$::WeakRepeatedPtrField< $type$ > $name$_;\n"); + } else { + format("::$proto_ns$::RepeatedPtrField< $type$ > $name$_;\n"); + } } void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations( @@ -657,20 +656,22 @@ void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations( void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( io::Printer* printer) const { Formatter format(printer, variables_); + format.Set("weak", implicit_weak_field_ ? ".weak" : ""); + format( "inline $type$* $classname$::mutable_$name$(int index) {\n" "$annotate_accessor$" // TODO(dlj): move insertion points " // @@protoc_insertion_point(field_mutable:$full_name$)\n" "$type_reference_function$" - " return $name$_.Mutable(index);\n" + " return $name$_$weak$.Mutable(index);\n" "}\n" "inline ::$proto_ns$::RepeatedPtrField< $type$ >*\n" "$classname$::mutable_$name$() {\n" "$annotate_accessor$" " // @@protoc_insertion_point(field_mutable_list:$full_name$)\n" "$type_reference_function$" - " return &$name$_;\n" + " return &$name$_$weak$;\n" "}\n"); if (options_.safe_boundary_check) { @@ -678,7 +679,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "inline const $type$& $classname$::$name$(int index) const {\n" "$annotate_accessor$" " // @@protoc_insertion_point(field_get:$full_name$)\n" - " return $name$_.InternalCheckedGet(index,\n" + " return $name$_$weak$.InternalCheckedGet(index,\n" " *reinterpret_cast(&$type_default_instance$));\n" "}\n"); } else { @@ -687,7 +688,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" " // @@protoc_insertion_point(field_get:$full_name$)\n" "$type_reference_function$" - " return $name$_.Get(index);\n" + " return $name$_$weak$.Get(index);\n" "}\n"); } @@ -695,7 +696,7 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "inline $type$* $classname$::add_$name$() {\n" "$annotate_accessor$" " // @@protoc_insertion_point(field_add:$full_name$)\n" - " return $name$_.Add();\n" + " return $name$_$weak$.Add();\n" "}\n"); format( @@ -704,39 +705,26 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions( "$annotate_accessor$" " // @@protoc_insertion_point(field_list:$full_name$)\n" "$type_reference_function$" - " return $name$_;\n" + " return $name$_$weak$;\n" "}\n"); } void RepeatedMessageFieldGenerator::GenerateClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - if (implicit_weak_field_) { - format( - "CastToBase(&$name$_)->Clear<" - "::$proto_ns$::internal::ImplicitWeakTypeHandler<$type$>>();\n"); - } else { - format("$name$_.Clear();\n"); - } + format("$name$_.Clear();\n"); } void RepeatedMessageFieldGenerator::GenerateMergingCode( io::Printer* printer) const { Formatter format(printer, variables_); - if (implicit_weak_field_) { - format( - "CastToBase(&$name$_)->MergeFrom<" - "::$proto_ns$::internal::ImplicitWeakTypeHandler<$type$>>(CastToBase(" - "from.$name$_));\n"); - } else { - format("$name$_.MergeFrom(from.$name$_);\n"); - } + format("$name$_.MergeFrom(from.$name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("CastToBase(&$name$_)->InternalSwap(CastToBase(&other->$name$_));\n"); + format("$name$_.InternalSwap(&other->$name$_);\n"); } void RepeatedMessageFieldGenerator::GenerateConstructorCode( @@ -751,9 +739,9 @@ void RepeatedMessageFieldGenerator::GenerateMergeFromCodedStream( if (implicit_weak_field_) { format( "DO_(::$proto_ns$::internal::WireFormatLite::" - "ReadMessage(input, CastToBase(&$name$_)->AddWeak(\n" + "ReadMessage(input, $name$_.AddWeak(\n" " reinterpret_cast(\n" - " &$type_default_instance$))));\n"); + " $type_default_instance_ptr$))));\n"); } else { format( "DO_(::$proto_ns$::internal::WireFormatLite::" @@ -770,55 +758,25 @@ void RepeatedMessageFieldGenerator::GenerateMergeFromCodedStream( void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); - if (implicit_weak_field_) { - format( - "for (unsigned int i = 0,\n" - " n = static_cast(this->$name$_size()); i < n; i++) " - "{\n" - " stream->EnsureSpace(&target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::\n" - " InternalWrite$declared_type$ToArray(\n" - " $number$,\n" - " CastToBase($name$_).Get<" - "::$proto_ns$::internal::ImplicitWeakTypeHandler<$type$>>(" - "static_cast(i)), target, stream);\n" - "}\n"); - } else { - format( - "for (auto it = this->$name$().pointer_begin(),\n" - " end = this->$name$().pointer_end(); it < end; ++it) {\n" - " stream->EnsureSpace(&target);\n" - " target = ::$proto_ns$::internal::WireFormatLite::\n" - " InternalWrite$declared_type$ToArray($number$, **it, target, " - "stream);\n" - "}\n"); - } + format( + "for (auto it = this->$name$_.pointer_begin(),\n" + " end = this->$name$_.pointer_end(); it < end; ++it) {\n" + " stream->EnsureSpace(&target);\n" + " target = ::$proto_ns$::internal::WireFormatLite::\n" + " InternalWrite$declared_type$ToArray($number$, **it, target, " + "stream);\n" + "}\n"); } void RepeatedMessageFieldGenerator::GenerateByteSize( io::Printer* printer) const { Formatter format(printer, variables_); format( - "{\n" - " unsigned int count = static_cast(this->$name$_size());\n"); - format.Indent(); - format( - "total_size += $tag_size$UL * count;\n" - "for (unsigned int i = 0; i < count; i++) {\n" + "total_size += $tag_size$UL * this->$name$_size();\n" + "for (const auto& msg : this->$name$_) {\n" " total_size +=\n" - " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"); - if (implicit_weak_field_) { - format( - " CastToBase($name$_).Get<" - "::$proto_ns$::internal::ImplicitWeakTypeHandler<$type$>>(" - "static_cast(i)));\n"); - } else { - format(" this->$name$(static_cast(i)));\n"); - } - format("}\n"); - format.Outdent(); - format("}\n"); + " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n" + "}\n"); } } // namespace cpp diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 62dcdcc7a1..db9a300230 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -38,7 +38,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 455ac6ed3f..76d0097357 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -39,7 +39,6 @@ #include - namespace google { namespace protobuf { namespace compiler { @@ -197,6 +196,12 @@ void StringFieldGenerator::GenerateAccessorDeclarations( descriptor_); } } + format( + "private:\n" + "const std::string& _internal_$name$() const;\n" + "void _internal_set_$name$(const std::string& value);\n" + "std::string* _internal_mutable_$name$();\n" + "public:\n"); if (unknown_ctype) { format.Outdent(); @@ -208,18 +213,31 @@ void StringFieldGenerator::GenerateAccessorDeclarations( void StringFieldGenerator::GenerateInlineAccessorDefinitions( io::Printer* printer) const { Formatter format(printer, variables_); + format( + "inline const std::string& $classname$::$name$() const {\n" + "$annotate_accessor$" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return _internal_$name$();\n" + "}\n" + "inline void $classname$::set_$name$(const std::string& value) {\n" + "$annotate_accessor$" + " _internal_set_$name$(value);\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "inline std::string* $classname$::mutable_$name$() {\n" + "$annotate_accessor$" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return _internal_mutable_$name$();\n" + "}\n"); if (SupportsArenas(descriptor_)) { format( - "inline const std::string& $classname$::$name$() const {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_get:$full_name$)\n" + "inline const std::string& $classname$::_internal_$name$() const {\n" " return $name$_.Get();\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" - "$annotate_accessor$" + "inline void $classname$::_internal_set_$name$(const std::string& " + "value) {\n" " $set_hasbit$\n" " $name$_.Set$lite$($default_variable$, value, GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(std::string&& value) {\n" "$annotate_accessor$" @@ -257,10 +275,8 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( "GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "inline std::string* $classname$::mutable_$name$() {\n" - "$annotate_accessor$" + "inline std::string* $classname$::_internal_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" @@ -324,16 +340,13 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( } else { // No-arena case. format( - "inline const std::string& $classname$::$name$() const {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_get:$full_name$)\n" + "inline const std::string& $classname$::_internal_$name$() const {\n" " return $name$_.GetNoArena();\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" - "$annotate_accessor$" + "inline void $classname$::_internal_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$(std::string&& value) {\n" "$annotate_accessor$" @@ -368,10 +381,8 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " $string_piece$(reinterpret_cast(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "inline std::string* $classname$::mutable_$name$() {\n" - "$annotate_accessor$" + "inline std::string* $classname$::_internal_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" @@ -500,7 +511,7 @@ void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { // TODO(gpike): improve this - format("set_$name$(from.$name$());\n"); + format("_internal_set_$name$(from._internal_$name$());\n"); } else { format( "$set_hasbit$\n" @@ -537,9 +548,9 @@ void StringFieldGenerator::GenerateCopyConstructorCode( GenerateConstructorCode(printer); if (HasFieldPresence(descriptor_->file())) { - format("if (from.has_$name$()) {\n"); + format("if (from._internal_has_$name$()) {\n"); } else { - format("if (!from.$name$().empty()) {\n"); + format("if (!from._internal_$name$().empty()) {\n"); } format.Indent(); @@ -547,7 +558,7 @@ void StringFieldGenerator::GenerateCopyConstructorCode( if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) { // TODO(gpike): improve this format( - "$name$_.Set$lite$($default_variable$, from.$name$(),\n" + "$name$_.Set$lite$($default_variable$, from._internal_$name$(),\n" " GetArenaNoVirtual());\n"); } else { format("$name$_.AssignWithDefault($default_variable$, from.$name$_);\n"); @@ -612,18 +623,19 @@ void StringFieldGenerator::GenerateMergeFromCodedStream( " $name$_.UnsafeSetTaggedPointer(str);\n" "} else {\n" " DO_(::$proto_ns$::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->mutable_$name$()));\n" + " input, this->_internal_mutable_$name$()));\n" "}\n"); } else { format( "DO_(::$proto_ns$::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->mutable_$name$()));\n"); + " input, this->_internal_mutable_$name$()));\n"); } if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, - "this->$name$().data(), static_cast(this->$name$().length()),\n", + "this->_internal_$name$().data(), " + "static_cast(this->_internal_$name$().length()),\n", format); } } @@ -638,12 +650,13 @@ void StringFieldGenerator::GenerateSerializeWithCachedSizesToArray( if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, false, - "this->$name$().data(), static_cast(this->$name$().length()),\n", + "this->_internal_$name$().data(), " + "static_cast(this->_internal_$name$().length()),\n", format); } format( "target = stream->Write$declared_type$MaybeAliased(\n" - " $number$, this->$name$(), target);\n"); + " $number$, this->_internal_$name$(), target);\n"); } void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const { @@ -651,7 +664,7 @@ void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const { format( "total_size += $tag_size$ +\n" " ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" - " this->$name$());\n"); + " this->_internal_$name$());\n"); } uint32 StringFieldGenerator::CalculateFieldTag() const { @@ -666,6 +679,13 @@ StringOneofFieldGenerator::StringOneofFieldGenerator( inlined_ = false; SetCommonOneofFieldVariables(descriptor, &variables_); + variables_["field_name"] = UnderscoresToCamelCase(descriptor->name(), true); + variables_["oneof_index"] = + StrCat(descriptor->containing_oneof()->index()); + // has_$name$() for oneof fields is private if has_bit is not present. In that + // case, use _has_$name$() instead of _internal_has_$name$(). + variables_["internal"] = + HasFieldPresence(descriptor->file()) ? "_internal_" : ""; } StringOneofFieldGenerator::~StringOneofFieldGenerator() {} @@ -673,26 +693,39 @@ StringOneofFieldGenerator::~StringOneofFieldGenerator() {} void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( io::Printer* printer) const { Formatter format(printer, variables_); + format( + "inline const std::string& $classname$::$name$() const {\n" + "$annotate_accessor$" + " // @@protoc_insertion_point(field_get:$full_name$)\n" + " return _internal_$name$();\n" + "}\n" + "inline void $classname$::set_$name$(const std::string& value) {\n" + "$annotate_accessor$" + " _internal_set_$name$(value);\n" + " // @@protoc_insertion_point(field_set:$full_name$)\n" + "}\n" + "inline std::string* $classname$::mutable_$name$() {\n" + "$annotate_accessor$" + " // @@protoc_insertion_point(field_mutable:$full_name$)\n" + " return _internal_mutable_$name$();\n" + "}\n"); if (SupportsArenas(descriptor_)) { format( - "inline const std::string& $classname$::$name$() const {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " if (has_$name$()) {\n" + "inline const std::string& $classname$::_internal_$name$() const {\n" + " if ($internal$has_$name$()) {\n" " return $field_member$.Get();\n" " }\n" " return *$default_variable$;\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" - "$annotate_accessor$" - " if (!has_$name$()) {\n" + "inline void $classname$::_internal_set_$name$(const std::string& " + "value) {\n" + " if (!$internal$has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " $field_member$.Set$lite$($default_variable$, value,\n" " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(std::string&& value) {\n" "$annotate_accessor$" @@ -748,16 +781,14 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " GetArenaNoVirtual());\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "inline std::string* $classname$::mutable_$name$() {\n" - "$annotate_accessor$" - " if (!has_$name$()) {\n" + "inline std::string* $classname$::_internal_mutable_$name$() {\n" + " if (!$internal$has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " return $field_member$.Mutable($default_variable$,\n" " GetArenaNoVirtual());\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" "$annotate_accessor$" @@ -816,24 +847,20 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( } else { // No-arena case. format( - "inline const std::string& $classname$::$name$() const {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_get:$full_name$)\n" - " if (has_$name$()) {\n" + "inline const std::string& $classname$::_internal_$name$() const {\n" + " if ($internal$has_$name$()) {\n" " return $field_member$.GetNoArena();\n" " }\n" " return *$default_variable$;\n" "}\n" - "inline void $classname$::set_$name$(const std::string& value) {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_set:$full_name$)\n" - " if (!has_$name$()) {\n" + "inline void $classname$::_internal_set_$name$(const std::string& " + "value) {\n" + " if (!$internal$has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" " $field_member$.SetNoArena($default_variable$, value);\n" - " // @@protoc_insertion_point(field_set:$full_name$)\n" "}\n" "inline void $classname$::set_$name$(std::string&& value) {\n" "$annotate_accessor$" @@ -885,14 +912,12 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions( " reinterpret_cast(value), size));\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "inline std::string* $classname$::mutable_$name$() {\n" - "$annotate_accessor$" - " if (!has_$name$()) {\n" + "inline std::string* $classname$::_internal_mutable_$name$() {\n" + " if (!$internal$has_$name$()) {\n" " clear_$oneof_name$();\n" " set_has_$name$();\n" " $field_member$.UnsafeSetDefault($default_variable$);\n" " }\n" - " // @@protoc_insertion_point(field_mutable:$full_name$)\n" " return $field_member$.MutableNoArena($default_variable$);\n" "}\n" "inline std::string* $classname$::$release_name$() {\n" @@ -979,18 +1004,19 @@ void StringOneofFieldGenerator::GenerateMergeFromCodedStream( " $field_member$.UnsafeSetTaggedPointer(new_value);\n" "} else {\n" " DO_(::$proto_ns$::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->mutable_$name$()));\n" + " input, this->_internal_mutable_$name$()));\n" "}\n"); } else { format( "DO_(::$proto_ns$::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->mutable_$name$()));\n"); + " input, this->_internal_mutable_$name$()));\n"); } if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, - "this->$name$().data(), static_cast(this->$name$().length()),\n", + "this->_internal_$name$().data(), " + "static_cast(this->_internal_$name$().length()),\n", format); } } @@ -1064,7 +1090,10 @@ void RepeatedStringFieldGenerator::GenerateAccessorDeclarations( "const;\n" "$deprecated_attr$::$proto_ns$::RepeatedPtrField* " "${1$mutable_$name$$}$()" - ";\n", + ";\n" + "private:\n" + "std::string* _internal_add_$name$();\n" + "public:\n", descriptor_); if (unknown_ctype) { @@ -1077,6 +1106,12 @@ void RepeatedStringFieldGenerator::GenerateAccessorDeclarations( void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( io::Printer* printer) const { Formatter format(printer, variables_); + format( + "inline std::string* $classname$::add_$name$() {\n" + "$annotate_accessor$" + " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n" + " return _internal_add_$name$();\n" + "}\n"); if (options_.safe_boundary_check) { format( "inline const std::string& $classname$::$name$(int index) const {\n" @@ -1135,9 +1170,7 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions( " reinterpret_cast(value), size);\n" " // @@protoc_insertion_point(field_set_pointer:$full_name$)\n" "}\n" - "inline std::string* $classname$::add_$name$() {\n" - "$annotate_accessor$" - " // @@protoc_insertion_point(field_add_mutable:$full_name$)\n" + "inline std::string* $classname$::_internal_add_$name$() {\n" " return $name$_.Add();\n" "}\n" "inline void $classname$::add_$name$(const std::string& value) {\n" @@ -1200,7 +1233,7 @@ void RepeatedStringFieldGenerator::GenerateMergingCode( void RepeatedStringFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { Formatter format(printer, variables_); - format("$name$_.InternalSwap(CastToBase(&other->$name$_));\n"); + format("$name$_.InternalSwap(&other->$name$_);\n"); } void RepeatedStringFieldGenerator::GenerateConstructorCode( @@ -1219,12 +1252,12 @@ void RepeatedStringFieldGenerator::GenerateMergeFromCodedStream( Formatter format(printer, variables_); format( "DO_(::$proto_ns$::internal::WireFormatLite::Read$declared_type$(\n" - " input, this->add_$name$()));\n"); + " input, this->_internal_add_$name$()));\n"); if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { GenerateUtf8CheckCodeForString( descriptor_, options_, true, - "this->$name$(this->$name$_size() - 1).data(),\n" - "static_cast(this->$name$(this->$name$_size() - 1).length()),\n", + "$name$_.Get($name$_.size() - 1).data(),\n" + "static_cast($name$_.Get($name$_.size() - 1).length()),\n", format); } } @@ -1233,8 +1266,8 @@ void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); format( - "for (auto it = this->$name$().pointer_begin(),\n" - " end = this->$name$().pointer_end(); it < end; ++it) {\n" + "for (auto it = $field_member$.pointer_begin(),\n" + " end = $field_member$.pointer_end(); it < end; ++it) {\n" " const auto& s = **it;\n"); // format("for (const std::string& s : this->$name$()) {\n"); format.Indent(); @@ -1254,11 +1287,11 @@ void RepeatedStringFieldGenerator::GenerateByteSize( Formatter format(printer, variables_); format( "total_size += $tag_size$ *\n" - " ::$proto_ns$::internal::FromIntSize(this->$name$_size());\n" - "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n" + " ::$proto_ns$::internal::FromIntSize($name$_.size());\n" + "for (int i = 0, n = $name$_.size(); i < n; i++) {\n" " total_size += " "::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n" - " this->$name$(i));\n" + " $name$_.Get(i));\n" "}\n"); } diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index fcc0aec0ac..a4e9ff4078 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc @@ -57,7 +57,7 @@ void WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) { comments = StringReplace(comments, "&", "&", true); comments = StringReplace(comments, "<", "<", true); std::vector lines; - SplitStringAllowEmpty(comments, "\n", &lines); + lines = Split(comments, "\n", false); // TODO: We really should work out which part to put in the summary and which to put in the remarks... // but that needs to be part of a bigger effort to understand the markdown better anyway. printer->Print("/// \n"); diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index df18348131..c51681edf7 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -36,7 +36,7 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__ #include -#include +#include #include #include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 0c5ade919f..fa3e245c6f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -39,7 +39,7 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ #include -#include +#include #include diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index 38a36024f9..c481f1400c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -213,7 +213,7 @@ void ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) { for (int i = 0; i < file_->extension_count(); i++) { extensions.push_back(GetFullExtensionName(file_->extension(i))); } - printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", JoinStrings(extensions, ", ")); + printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", Join(extensions, ", ")); } else { printer->Print("null, "); @@ -264,7 +264,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript for (int i = 0; i < descriptor->field_count(); i++) { fields.push_back(GetPropertyName(descriptor->field(i))); } - printer->Print("new[]{ \"$fields$\" }, ", "fields", JoinStrings(fields, "\", \"")); + printer->Print("new[]{ \"$fields$\" }, ", "fields", Join(fields, "\", \"")); } else { printer->Print("null, "); @@ -276,7 +276,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript for (int i = 0; i < descriptor->oneof_decl_count(); i++) { oneofs.push_back(UnderscoresToCamelCase(descriptor->oneof_decl(i)->name(), true)); } - printer->Print("new[]{ \"$oneofs$\" }, ", "oneofs", JoinStrings(oneofs, "\", \"")); + printer->Print("new[]{ \"$oneofs$\" }, ", "oneofs", Join(oneofs, "\", \"")); } else { printer->Print("null, "); @@ -288,7 +288,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript for (int i = 0; i < descriptor->enum_type_count(); i++) { enums.push_back(GetClassName(descriptor->enum_type(i))); } - printer->Print("new[]{ typeof($enums$) }, ", "enums", JoinStrings(enums, "), typeof(")); + printer->Print("new[]{ typeof($enums$) }, ", "enums", Join(enums, "), typeof(")); } else { printer->Print("null, "); @@ -300,7 +300,7 @@ void ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descript for (int i = 0; i < descriptor->extension_count(); i++) { extensions.push_back(GetFullExtensionName(descriptor->extension(i))); } - printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", JoinStrings(extensions, ", ")); + printer->Print("new pb::Extension[] { $extensions$ }, ", "extensions", Join(extensions, ", ")); } else { printer->Print("null, "); diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 715d999e7e..9308519470 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -46,14 +46,11 @@ #include #include - #include -#include #include #include #include - - +#include #ifdef _WIN32 #include diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc index 778d3ba1e3..d74a7ed63d 100644 --- a/src/google/protobuf/compiler/java/java_context.cc +++ b/src/google/protobuf/compiler/java/java_context.cc @@ -35,7 +35,6 @@ #include #include #include - #include namespace google { diff --git a/src/google/protobuf/compiler/java/java_doc_comment.cc b/src/google/protobuf/compiler/java/java_doc_comment.cc index 2aee232354..2376488f02 100644 --- a/src/google/protobuf/compiler/java/java_doc_comment.cc +++ b/src/google/protobuf/compiler/java/java_doc_comment.cc @@ -174,7 +174,8 @@ void WriteMessageDocComment(io::Printer* printer, const Descriptor* message) { void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) { // We start the comment with the main body based on the comments from the - // .proto file (if present). We then continue with the field declaration, e.g.: + // .proto file (if present). We then continue with the field declaration, + // e.g.: // optional string foo = 5; // And then we end with the javadoc tags if applicable. // If the field is a group, the debug string might end with {. @@ -185,17 +186,17 @@ void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) { printer->Print(" */\n"); } -void WriteFieldAccessorDocComment(io::Printer* printer, +void WriteFieldAccessorDocComment(io::Printer* printer, const FieldDescriptor* field, const FieldAccessorType type, const bool builder) { printer->Print("/**\n"); WriteDocCommentBody(printer, field); - printer->Print(" * $def$\n", "def", + printer->Print(" * $def$\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); switch (type) { case HAZZER: - printer->Print(" * @return Whether the $name$ field is set.\n", "name", + printer->Print(" * @return Whether the $name$ field is set.\n", "name", field->camelcase_name()); break; case GETTER: @@ -211,16 +212,16 @@ void WriteFieldAccessorDocComment(io::Printer* printer, break; // Repeated case LIST_COUNT: - printer->Print(" * @return The number of $name$(s).\n", "name", - field->camelcase_name()); + printer->Print(" * @return The count of $name$.\n", "name", + field->camelcase_name()); break; case LIST_GETTER: - printer->Print(" * @return A list containing the $name$(s).\n", "name", + printer->Print(" * @return A list containing the $name$.\n", "name", field->camelcase_name()); break; case LIST_INDEXED_GETTER: printer->Print(" * @param index The index of the element to return.\n"); - printer->Print(" * @return The $name$(s) at the given index.\n", "name", + printer->Print(" * @return The $name$ at the given index.\n", "name", field->camelcase_name()); break; case LIST_INDEXED_SETTER: @@ -233,8 +234,8 @@ void WriteFieldAccessorDocComment(io::Printer* printer, field->camelcase_name()); break; case LIST_MULTI_ADDER: - printer->Print(" * @param values The $name$(s) to add.\n", "name", - field->camelcase_name()); + printer->Print(" * @param values The $name$ to add.\n", "name", + field->camelcase_name()); break; } if (builder) { @@ -243,25 +244,28 @@ void WriteFieldAccessorDocComment(io::Printer* printer, printer->Print(" */\n"); } -void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, +void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, const FieldDescriptor* field, const FieldAccessorType type, const bool builder) { printer->Print("/**\n"); WriteDocCommentBody(printer, field); - printer->Print(" * $def$\n", "def", + printer->Print(" * $def$\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); switch (type) { case HAZZER: // Should never happen break; case GETTER: - printer->Print(" * @return The enum value for $name$.\n", "name", - field->camelcase_name()); + printer->Print( + " * @return The enum numeric value on the wire for $name$.\n", "name", + field->camelcase_name()); break; case SETTER: - printer->Print(" * @param value The enum value for $name$ to set.\n", - "name", field->camelcase_name()); + printer->Print( + " * @param value The enum numeric value on the wire for $name$ to " + "set.\n", + "name", field->camelcase_name()); break; case CLEARER: // Print nothing @@ -271,26 +275,36 @@ void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, // Should never happen break; case LIST_GETTER: - printer->Print(" * @return A list containing the enum values for " - "$name$(s).\n", "name", field->camelcase_name()); + printer->Print( + " * @return A list containing the enum numeric values on the wire " + "for $name$.\n", + "name", field->camelcase_name()); break; case LIST_INDEXED_GETTER: printer->Print(" * @param index The index of the value to return.\n"); - printer->Print(" * @return The enum value of the $name$ at the given " - "index.\n", "name", field->camelcase_name()); + printer->Print( + " * @return The enum numeric value on the wire of $name$ at the " + "given index.\n", + "name", field->camelcase_name()); break; case LIST_INDEXED_SETTER: printer->Print(" * @param index The index to set the value at.\n"); - printer->Print(" * @param value The enum value of the $name$ to set.\n", - "name", field->camelcase_name()); + printer->Print( + " * @param value The enum numeric value on the wire for $name$ to " + "set.\n", + "name", field->camelcase_name()); break; case LIST_ADDER: - printer->Print(" * @param value The enum value of the $name$ to add.\n", - "name", field->camelcase_name()); + printer->Print( + " * @param value The enum numeric value on the wire for $name$ to " + "add.\n", + "name", field->camelcase_name()); break; case LIST_MULTI_ADDER: - printer->Print(" * @param values The enum values of the $name$(s) to " - "add.\n", "name", field->camelcase_name()); + printer->Print( + " * @param values The enum numeric values on the wire for $name$ to " + "add.\n", + "name", field->camelcase_name()); break; } if (builder) { @@ -299,13 +313,13 @@ void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, printer->Print(" */\n"); } -void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, +void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, const FieldDescriptor* field, const FieldAccessorType type, const bool builder) { printer->Print("/**\n"); WriteDocCommentBody(printer, field); - printer->Print(" * $def$\n", "def", + printer->Print(" * $def$\n", "def", EscapeJavadoc(FirstLineOf(field->DebugString()))); switch (type) { case HAZZER: @@ -313,11 +327,11 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, break; case GETTER: printer->Print(" * @return The bytes for $name$.\n", "name", - field->camelcase_name()); + field->camelcase_name()); break; case SETTER: - printer->Print(" * @param value The bytes for $name$ to set.\n", - "name", field->camelcase_name()); + printer->Print(" * @param value The bytes for $name$ to set.\n", "name", + field->camelcase_name()); break; case CLEARER: // Print nothing @@ -327,7 +341,7 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, // Should never happen break; case LIST_GETTER: - printer->Print(" * @return A list containing the bytes for $name$(s).\n", + printer->Print(" * @return A list containing the bytes for $name$.\n", "name", field->camelcase_name()); break; case LIST_INDEXED_GETTER: @@ -345,7 +359,7 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, "name", field->camelcase_name()); break; case LIST_MULTI_ADDER: - printer->Print(" * @param values The bytes of the $name$(s) to add.\n", + printer->Print(" * @param values The bytes of the $name$ to add.\n", "name", field->camelcase_name()); break; } diff --git a/src/google/protobuf/compiler/java/java_doc_comment.h b/src/google/protobuf/compiler/java/java_doc_comment.h index a5ef09690c..b7de877670 100644 --- a/src/google/protobuf/compiler/java/java_doc_comment.h +++ b/src/google/protobuf/compiler/java/java_doc_comment.h @@ -53,35 +53,33 @@ namespace compiler { namespace java { enum FieldAccessorType { - - HAZZER, - GETTER, - SETTER, - CLEARER, - // Repeated - LIST_COUNT, - LIST_GETTER, - LIST_INDEXED_GETTER, - LIST_INDEXED_SETTER, - LIST_ADDER, - LIST_MULTI_ADDER - + HAZZER, + GETTER, + SETTER, + CLEARER, + // Repeated + LIST_COUNT, + LIST_GETTER, + LIST_INDEXED_GETTER, + LIST_INDEXED_SETTER, + LIST_ADDER, + LIST_MULTI_ADDER }; void WriteMessageDocComment(io::Printer* printer, const Descriptor* message); void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field); void WriteFieldAccessorDocComment(io::Printer* printer, - const FieldDescriptor* field, - const FieldAccessorType type, - const bool builder = false); + const FieldDescriptor* field, + const FieldAccessorType type, + const bool builder = false); void WriteFieldEnumValueAccessorDocComment(io::Printer* printer, - const FieldDescriptor* field, - const FieldAccessorType type, - const bool builder = false); + const FieldDescriptor* field, + const FieldAccessorType type, + const bool builder = false); void WriteFieldStringBytesAccessorDocComment(io::Printer* printer, - const FieldDescriptor* field, - const FieldAccessorType type, - const bool builder = false); + const FieldDescriptor* field, + const FieldAccessorType type, + const bool builder = false); void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_); void WriteEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value); diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc index bf911be4b9..9415eb5d21 100644 --- a/src/google/protobuf/compiler/java/java_enum.cc +++ b/src/google/protobuf/compiler/java/java_enum.cc @@ -44,7 +44,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { @@ -175,8 +174,9 @@ void EnumGenerator::Generate(io::Printer* printer) { "}\n" "\n" "/**\n" - " * @param value The number of the enum to look for.\n" - " * @return The enum associated with the given number.\n" + " * @param value The numeric wire value of the corresponding enum " + "entry.\n" + " * @return The enum associated with the given numeric wire value.\n" " * @deprecated Use {@link #forNumber(int)} instead.\n" " */\n" "@java.lang.Deprecated\n" @@ -184,6 +184,11 @@ void EnumGenerator::Generate(io::Printer* printer) { " return forNumber(value);\n" "}\n" "\n" + "/**\n" + " * @param value The numeric wire value of the corresponding enum " + "entry.\n" + " * @return The enum associated with the given numeric wire value.\n" + " */\n" "public static $classname$ forNumber(int value) {\n" " switch (value) {\n", "classname", descriptor_->name()); diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc index 5ae51ffe67..5f77f042c3 100644 --- a/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/src/google/protobuf/compiler/java/java_enum_field.cc @@ -46,7 +46,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { @@ -221,7 +220,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( "}\n"); printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, - /* builder */ true); + /* builder */ true); printer->Print(variables_, "$deprecation$public Builder " "${$set$capitalized_name$Value$}$(int value) {\n" 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 b3b4c3c842..e4b97e6349 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -46,7 +46,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc index f8e0653d23..69bd26c3f9 100644 --- a/src/google/protobuf/compiler/java/java_enum_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_lite.cc @@ -43,7 +43,6 @@ #include #include #include - #include namespace google { diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc index 3ad64e061b..db210fb3e5 100644 --- a/src/google/protobuf/compiler/java/java_extension.cc +++ b/src/google/protobuf/compiler/java/java_extension.cc @@ -41,7 +41,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index 18a86bad04..96ed23401a 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -55,7 +55,6 @@ #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 5bc847c369..076f30a04a 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -54,7 +54,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc index ac0e9cd3db..bdc43acae6 100644 --- a/src/google/protobuf/compiler/java/java_helpers.cc +++ b/src/google/protobuf/compiler/java/java_helpers.cc @@ -44,9 +44,6 @@ #include #include #include - - - #include // for hash namespace google { diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 63bbe02016..941e8380d3 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -55,8 +55,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc index aa00a66f4c..16e63afc6c 100644 --- a/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/src/google/protobuf/compiler/java/java_message_builder.cc @@ -53,8 +53,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { 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 ae34499131..6e78fb7371 100644 --- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc @@ -53,7 +53,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { 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 1a055fea12..b111099152 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -44,7 +44,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index c356f15310..cb09997854 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -55,8 +55,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_name_resolver.cc b/src/google/protobuf/compiler/java/java_name_resolver.cc index d07c628e50..09fedd1459 100644 --- a/src/google/protobuf/compiler/java/java_name_resolver.cc +++ b/src/google/protobuf/compiler/java/java_name_resolver.cc @@ -33,11 +33,9 @@ #include #include - #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc index 8b51e792df..d06b534bf7 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -46,7 +46,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { 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 833be233bc..918bdb95c9 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -46,7 +46,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc index 17d8e707c0..e30d155e47 100644 --- a/src/google/protobuf/compiler/java/java_service.cc +++ b/src/google/protobuf/compiler/java/java_service.cc @@ -41,7 +41,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc index 2a828816cd..c976885e02 100644 --- a/src/google/protobuf/compiler/java/java_string_field.cc +++ b/src/google/protobuf/compiler/java/java_string_field.cc @@ -47,7 +47,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { 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 1e856f253d..77cea92360 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -47,7 +47,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { @@ -295,7 +294,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER, - /* builder */ true); + /* builder */ true); printer->Print( variables_, "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" @@ -476,7 +475,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER, - /* builder */ true); + /* builder */ true); printer->Print( variables_, "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index fa7e98ef5c..2a797e9b57 100644 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -43,7 +43,6 @@ #include #include #include - #include #include #include @@ -51,7 +50,6 @@ #include #include - namespace google { namespace protobuf { namespace compiler { @@ -1118,9 +1116,6 @@ std::string JSBinaryWriterMethodName(const GeneratorOptions& options, JSBinaryReadWriteMethodName(field, /* is_writer = */ true); } -std::string JSReturnClause(const FieldDescriptor* desc) { - return ""; -} std::string JSTypeTag(const FieldDescriptor* desc) { switch (desc->type()) { @@ -1156,10 +1151,6 @@ std::string JSTypeTag(const FieldDescriptor* desc) { return ""; } -std::string JSReturnDoc(const GeneratorOptions& options, - const FieldDescriptor* desc) { - return ""; -} bool HasRepeatedFields(const GeneratorOptions& options, const Descriptor* desc) { @@ -1426,11 +1417,6 @@ bool HasFieldPresence(const GeneratorOptions& options, return false; } - if (UseBrokenPresenceSemantics(options, field)) { - // Proto3 files with broken presence semantics have field presence. - return true; - } - return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || field->containing_oneof() != NULL || field->file()->syntax() == FileDescriptor::SYNTAX_PROTO2; @@ -2393,7 +2379,7 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && // Repeated fields get initialized to their default in the constructor // (why?), so we emit a plain getField() call for them. - !field->is_repeated() && !UseBrokenPresenceSemantics(options, field)) { + !field->is_repeated()) { // Proto3 puts all defaults (including implicit defaults) in toObject(). // But for proto2 we leave the existing semantics unchanged: unset fields // without default are unset. @@ -2677,30 +2663,31 @@ void Generator::GenerateClassField(const GeneratorOptions& options, (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); printer->Annotate("gettername", field); printer->Print( - "/** @param {$optionaltype$} value$returndoc$ */\n" + "/**\n" + " * @param {$optionaltype$} value\n" + " * @return {!$class$} returns this\n" + "*/\n" "$class$.prototype.$settername$ = function(value) {\n" - " jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", + " return jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", "optionaltype", JSFieldTypeAnnotation(options, field, /* is_setter_argument = */ true, /* force_present = */ false, /* singular_if_not_packed = */ false), - "returndoc", JSReturnDoc(options, field), "class", - GetMessagePath(options, field->containing_type()), "settername", - "set" + JSGetterName(options, field), "oneoftag", + "class", GetMessagePath(options, field->containing_type()), + "settername", "set" + JSGetterName(options, field), "oneoftag", (field->containing_oneof() ? "Oneof" : ""), "repeatedtag", (field->is_repeated() ? "Repeated" : "")); printer->Annotate("settername", field); printer->Print( - "this, $index$$oneofgroup$, value);$returnvalue$\n" + "this, $index$$oneofgroup$, value);\n" "};\n" "\n" "\n", "index", JSFieldIndex(field), "oneofgroup", (field->containing_oneof() ? (", " + JSOneofArray(options, field)) - : ""), - "returnvalue", JSReturnClause(field)); + : "")); if (field->is_repeated()) { GenerateRepeatedMessageHelperMethods(options, printer, field); @@ -2787,21 +2774,18 @@ void Generator::GenerateClassField(const GeneratorOptions& options, GenerateBytesWrapper(options, printer, field, BYTES_U8); } - if (untyped) { - printer->Print( - "/**\n" - " * @param {*} value$returndoc$\n" - " */\n", - "returndoc", JSReturnDoc(options, field)); - } else { - printer->Print( - "/** @param {$optionaltype$} value$returndoc$ */\n", "optionaltype", - JSFieldTypeAnnotation(options, field, - /* is_setter_argument = */ true, - /* force_present = */ false, - /* singular_if_not_packed = */ false), - "returndoc", JSReturnDoc(options, field)); - } + printer->Print( + "/**\n" + " * @param {$optionaltype$} value\n" + " * @return {!$class$} returns this\n" + " */\n", + "class", GetMessagePath(options, field->containing_type()), + "optionaltype", + untyped ? "*" + : JSFieldTypeAnnotation(options, field, + /* is_setter_argument = */ true, + /* force_present = */ false, + /* singular_if_not_packed = */ false)); if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 && !field->is_repeated() && !field->is_map() && @@ -2810,28 +2794,28 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // setProto3*Field function. printer->Print( "$class$.prototype.$settername$ = function(value) {\n" - " jspb.Message.setProto3$typetag$Field(this, $index$, " - "value);$returnvalue$\n" + " return jspb.Message.setProto3$typetag$Field(this, $index$, " + "value);" + "\n" "};\n" "\n" "\n", "class", GetMessagePath(options, field->containing_type()), "settername", "set" + JSGetterName(options, field), "typetag", - JSTypeTag(field), "index", JSFieldIndex(field), "returnvalue", - JSReturnClause(field)); + JSTypeTag(field), "index", JSFieldIndex(field)); printer->Annotate("settername", field); } else { // Otherwise, use the regular setField function. printer->Print( "$class$.prototype.$settername$ = function(value) {\n" - " jspb.Message.set$oneoftag$Field(this, $index$", + " return jspb.Message.set$oneoftag$Field(this, $index$", "class", GetMessagePath(options, field->containing_type()), "settername", "set" + JSGetterName(options, field), "oneoftag", (field->containing_oneof() ? "Oneof" : ""), "index", JSFieldIndex(field)); printer->Annotate("settername", field); printer->Print( - "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);$returnvalue$\n" + "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);\n" "};\n" "\n" "\n", @@ -2840,16 +2824,16 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "typeclose", untyped ? ")" : "", "oneofgroup", (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), - "returnvalue", JSReturnClause(field), "rptvalueinit", - (field->is_repeated() ? " || []" : "")); + "rptvalueinit", (field->is_repeated() ? " || []" : "")); } if (untyped) { printer->Print( "/**\n" - " * Clears the value.$returndoc$\n" + " * Clears the value.\n" + " * @return {!$class$} returns this\n" " */\n", - "returndoc", JSReturnDoc(options, field)); + "class", GetMessagePath(options, field->containing_type())); } if (field->is_repeated()) { @@ -2863,19 +2847,18 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // clang-format off printer->Print( "/**\n" - " * Clears values from the map. The map will be non-null." - "$returndoc$\n" + " * Clears values from the map. The map will be non-null.\n" + " * @return {!$class$} returns this\n" " */\n" "$class$.prototype.$clearername$ = function() {\n" - " this.$gettername$().clear();$returnvalue$\n" + " this.$gettername$().clear();\n" + " return this;" "};\n" "\n" "\n", - "returndoc", JSReturnDoc(options, field), "class", GetMessagePath(options, field->containing_type()), "clearername", "clear" + JSGetterName(options, field), - "gettername", "get" + JSGetterName(options, field), - "returnvalue", JSReturnClause(field)); + "gettername", "get" + JSGetterName(options, field)); // clang-format on printer->Annotate("clearername", field); } else if (field->is_repeated() || @@ -2885,22 +2868,21 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // clang-format off printer->Print( "/**\n" - " * $jsdoc$$returndoc$\n" + " * $jsdoc$\n" + " * @return {!$class$} returns this\n" " */\n" "$class$.prototype.$clearername$ = function() {\n" - " this.$settername$($clearedvalue$);$returnvalue$\n" + " return this.$settername$($clearedvalue$);\n" "};\n" "\n" "\n", "jsdoc", field->is_repeated() ? "Clears the list making it empty but non-null." : "Clears the message field making it undefined.", - "returndoc", JSReturnDoc(options, field), "class", GetMessagePath(options, field->containing_type()), "clearername", "clear" + JSGetterName(options, field), "settername", "set" + JSGetterName(options, field), - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + "clearedvalue", (field->is_repeated() ? "[]" : "undefined")); // clang-format on printer->Annotate("clearername", field); } else if (HasFieldPresence(options, field)) { @@ -2909,12 +2891,12 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // clang-format off printer->Print( "/**\n" - " * Clears the field making it undefined.$returndoc$\n" + " * Clears the field making it undefined.\n" + " * @return {!$class$} returns this\n" " */\n" "$class$.prototype.$clearername$ = function() {\n" - " jspb.Message.set$maybeoneof$Field(this, " - "$index$$maybeoneofgroup$, ", - "returndoc", JSReturnDoc(options, field), + " return jspb.Message.set$maybeoneof$Field(this, " + "$index$$maybeoneofgroup$, ", "class", GetMessagePath(options, field->containing_type()), "clearername", "clear" + JSGetterName(options, field), "maybeoneof", (field->containing_oneof() ? "Oneof" : ""), @@ -2925,12 +2907,11 @@ void Generator::GenerateClassField(const GeneratorOptions& options, // clang-format on printer->Annotate("clearername", field); printer->Print( - "$clearedvalue$);$returnvalue$\n" + "$clearedvalue$);\n" "};\n" "\n" "\n", - "clearedvalue", (field->is_repeated() ? "[]" : "undefined"), - "returnvalue", JSReturnClause(field)); + "clearedvalue", (field->is_repeated() ? "[]" : "undefined")); } if (HasFieldPresence(options, field)) { @@ -2957,10 +2938,12 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods( printer->Print( "/**\n" " * @param {$optionaltype$} value\n" - " * @param {number=} opt_index$returndoc$\n" + " * @param {number=} opt_index\n" + " * @return {!$class$} returns this\n" " */\n" "$class$.prototype.$addername$ = function(value, opt_index) {\n" - " jspb.Message.addToRepeatedField(this, $index$", + " return jspb.Message.addToRepeatedField(this, " + "$index$", "class", GetMessagePath(options, field->containing_type()), "addername", "add" + JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true), @@ -2972,20 +2955,18 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods( /* singular_if_not_packed = */ false, BYTES_DEFAULT, /* force_singular = */ true), - "index", JSFieldIndex(field), - "returndoc", JSReturnDoc(options, field)); + "index", JSFieldIndex(field)); printer->Annotate("addername", field); printer->Print( "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, " - "opt_index);$returnvalue$\n" + "opt_index);\n" "};\n" "\n" "\n", "type", untyped ? "/** @type{string|number|boolean|!Uint8Array} */(" : "", "typeclose", untyped ? ")" : "", "oneofgroup", (field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""), - "rptvalueinit", "", - "returnvalue", JSReturnClause(field)); + "rptvalueinit", ""); // clang-format on } @@ -3161,6 +3142,7 @@ void Generator::GenerateClassDeserializeBinaryField( printer->Print(", null"); } printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field)); + printer->Print(", $defaultValue$", "defaultValue", JSFieldDefault(value_field)); printer->Print(");\n"); printer->Print(" });\n"); } else { @@ -3374,12 +3356,21 @@ void Generator::GenerateEnum(const GeneratorOptions& options, enumdesc->name()); printer->Annotate("name", enumdesc); + std::set used_name; + std::vector valid_index; for (int i = 0; i < enumdesc->value_count(); i++) { + if (enumdesc->options().allow_alias() && + !used_name.insert(ToEnumCase(enumdesc->value(i)->name())).second) { + continue; + } + valid_index.push_back(i); + } + for (auto i : valid_index) { const EnumValueDescriptor* value = enumdesc->value(i); printer->Print(" $name$: $value$$comma$\n", "name", ToEnumCase(value->name()), "value", StrCat(value->number()), "comma", - (i == enumdesc->value_count() - 1) ? "" : ","); + (i == valid_index.back()) ? "" : ","); printer->Annotate("name", value); } diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index 07760649f2..038e6f530f 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -39,7 +39,6 @@ #include - #include #include #include diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index e8d6d9e1cb..206739fdf8 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some @@ -931,7 +931,7 @@ string BuildCommentsString(const SourceLocation& location, ? location.trailing_comments : location.leading_comments; std::vector lines; - SplitStringAllowEmpty(comments, "\n", &lines); + lines = Split(comments, "\n", false); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 1c0efda18d..0576b64a4c 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -38,7 +38,6 @@ #include #include - #include #include @@ -903,10 +902,8 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field, const LocationRecorder& field_location, const FileDescriptorProto* containing_file) { { - LocationRecorder location(field_location, - FieldDescriptorProto::kLabelFieldNumber); FieldDescriptorProto::Label label; - if (ParseLabel(&label, containing_file)) { + if (ParseLabel(&label, field_location, containing_file)) { field->set_label(label); if (label == FieldDescriptorProto::LABEL_OPTIONAL && syntax_identifier_ == "proto3") { @@ -2207,18 +2204,22 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location, // ------------------------------------------------------------------- bool Parser::ParseLabel(FieldDescriptorProto::Label* label, + const LocationRecorder& field_location, const FileDescriptorProto* containing_file) { + if (!LookingAt("optional") && !LookingAt("repeated") && !LookingAt("required")) { + return false; + } + LocationRecorder location(field_location, + FieldDescriptorProto::kLabelFieldNumber); if (TryConsume("optional")) { *label = FieldDescriptorProto::LABEL_OPTIONAL; - return true; } else if (TryConsume("repeated")) { *label = FieldDescriptorProto::LABEL_REPEATED; - return true; - } else if (TryConsume("required")) { + } else { + Consume("required"); *label = FieldDescriptorProto::LABEL_REQUIRED; - return true; } - return false; + return true; } bool Parser::ParseType(FieldDescriptorProto::Type* type, diff --git a/src/google/protobuf/compiler/parser.h b/src/google/protobuf/compiler/parser.h index 9e2dc5f532..45d433dc2b 100644 --- a/src/google/protobuf/compiler/parser.h +++ b/src/google/protobuf/compiler/parser.h @@ -440,6 +440,7 @@ class PROTOBUF_EXPORT Parser { // Parse "required", "optional", or "repeated" and fill in "label" // with the value. Returns true if such a label is consumed. bool ParseLabel(FieldDescriptorProto::Label* label, + const LocationRecorder& field_location, const FileDescriptorProto* containing_file); // Parse a type name and fill in "type" (if it is a primitive) or diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc index 43784cb321..2070ab9052 100644 --- a/src/google/protobuf/compiler/parser_unittest.cc +++ b/src/google/protobuf/compiler/parser_unittest.cc @@ -48,7 +48,6 @@ #include #include #include - #include #include @@ -2809,6 +2808,35 @@ TEST_F(SourceInfoTest, Fields) { EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); } +TEST_F(SourceInfoTest, Proto3Fields) { + EXPECT_TRUE( + Parse("syntax = \"proto3\";\n" + "message Foo {\n" + " $a$int32$b$ $c$bar$d$ = $e$1$f$;$g$\n" + " $h$repeated$i$ $j$X.Y$k$ $l$baz$m$ = $n$2$o$;$p$\n" + "}\n")); + + const FieldDescriptorProto& field1 = file_.message_type(0).field(0); + const FieldDescriptorProto& field2 = file_.message_type(0).field(1); + + EXPECT_TRUE(HasSpan('a', 'g', field1)); + EXPECT_TRUE(HasSpan('a', 'b', field1, "type")); + EXPECT_TRUE(HasSpan('c', 'd', field1, "name")); + EXPECT_TRUE(HasSpan('e', 'f', field1, "number")); + + EXPECT_TRUE(HasSpan('h', 'p', field2)); + EXPECT_TRUE(HasSpan('h', 'i', field2, "label")); + EXPECT_TRUE(HasSpan('j', 'k', field2, "type_name")); + EXPECT_TRUE(HasSpan('l', 'm', field2, "name")); + EXPECT_TRUE(HasSpan('n', 'o', field2, "number")); + + // Ignore these. + EXPECT_TRUE(HasSpan(file_)); + EXPECT_TRUE(HasSpan(file_, "syntax")); + EXPECT_TRUE(HasSpan(file_.message_type(0))); + EXPECT_TRUE(HasSpan(file_.message_type(0), "name")); +} + TEST_F(SourceInfoTest, Extensions) { EXPECT_TRUE( Parse("$a$extend $b$Foo$c$ {\n" diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 232db80b50..a16cbc25d7 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -1463,7 +1463,7 @@ static void GenerateDocCommentBodyForLocation( // HTML-escape them so that they don't accidentally close the doc comment. comments = EscapePhpdoc(comments); - std::vector lines = Split(comments, "\n"); + std::vector lines = Split(comments, "\n", true); while (!lines.empty() && lines.back().empty()) { lines.pop_back(); } diff --git a/src/google/protobuf/compiler/plugin.cc b/src/google/protobuf/compiler/plugin.cc index ac383f88ed..7de3985c53 100644 --- a/src/google/protobuf/compiler/plugin.cc +++ b/src/google/protobuf/compiler/plugin.cc @@ -45,9 +45,9 @@ #include #include #include -#include #include #include +#include namespace google { diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index dcfaca3545..b42254b7c5 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -49,7 +49,7 @@ static void InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompil } PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_CodeGeneratorRequest_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { &scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}}; @@ -65,7 +65,7 @@ static void InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompi } PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_CodeGeneratorResponse_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, { &scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto.base,}}; static void InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { @@ -80,7 +80,7 @@ static void InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2f } PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_CodeGeneratorResponse_File_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -94,7 +94,7 @@ static void InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2 } PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Version_google_2fprotobuf_2fcompiler_2fplugin_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; @@ -235,7 +235,7 @@ Version::Version(const Version& from) _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_suffix()) { + if (from._internal_has_suffix()) { suffix_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.suffix_); } ::memcpy(&major_, &from.major_, @@ -325,7 +325,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in // optional string suffix = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_suffix(), ptr, ctx, "google.protobuf.compiler.Version.suffix"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_suffix(), ptr, ctx, "google.protobuf.compiler.Version.suffix"); CHK_(ptr); } else goto handle_unusual; continue; @@ -403,9 +403,9 @@ bool Version::MergePartialFromCodedStream( case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (34 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_suffix())); + input, this->_internal_mutable_suffix())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->suffix().data(), static_cast(this->suffix().length()), + this->_internal_suffix().data(), static_cast(this->_internal_suffix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.Version.suffix"); } else { @@ -463,11 +463,11 @@ failure: // optional string suffix = 4; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->suffix().data(), static_cast(this->suffix().length()), + this->_internal_suffix().data(), static_cast(this->_internal_suffix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.Version.suffix"); target = stream->WriteStringMaybeAliased( - 4, this->suffix(), target); + 4, this->_internal_suffix(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -492,7 +492,7 @@ size_t Version::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->suffix()); + this->_internal_suffix()); } // optional int32 major = 1; @@ -639,7 +639,7 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) proto_file_(from.proto_file_) { _internal_metadata_.MergeFrom(from._internal_metadata_); parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_parameter()) { + if (from._internal_has_parameter()) { parameter_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.parameter_); } if (from.has_compiler_version()) { @@ -712,16 +712,16 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(add_file_to_generate(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_add_file_to_generate(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; // optional string parameter = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_parameter(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_parameter(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); CHK_(ptr); } else goto handle_unusual; continue; @@ -741,7 +741,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM ptr = ctx->ParseMessage(add_proto_file(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 122); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr)); } else goto handle_unusual; continue; default: { @@ -779,10 +779,10 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_file_to_generate())); + input, this->_internal_add_file_to_generate())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->file_to_generate(this->file_to_generate_size() - 1).data(), - static_cast(this->file_to_generate(this->file_to_generate_size() - 1).length()), + file_to_generate_.Get(file_to_generate_.size() - 1).data(), + static_cast(file_to_generate_.Get(file_to_generate_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate"); } else { @@ -795,9 +795,9 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_parameter())); + input, this->_internal_mutable_parameter())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->parameter().data(), static_cast(this->parameter().length()), + this->_internal_parameter().data(), static_cast(this->_internal_parameter().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); } else { @@ -856,8 +856,8 @@ failure: (void) cached_has_bits; // repeated string file_to_generate = 1; - for (auto it = this->file_to_generate().pointer_begin(), - end = this->file_to_generate().pointer_end(); it < end; ++it) { + for (auto it = file_to_generate_.pointer_begin(), + end = file_to_generate_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( s.data(), static_cast(s.length()), @@ -870,11 +870,11 @@ failure: // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->parameter().data(), static_cast(this->parameter().length()), + this->_internal_parameter().data(), static_cast(this->_internal_parameter().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorRequest.parameter"); target = stream->WriteStringMaybeAliased( - 2, this->parameter(), target); + 2, this->_internal_parameter(), target); } // optional .google.protobuf.compiler.Version compiler_version = 3; @@ -886,8 +886,8 @@ failure: } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (auto it = this->proto_file().pointer_begin(), - end = this->proto_file().pointer_end(); it < end; ++it) { + for (auto it = this->proto_file_.pointer_begin(), + end = this->proto_file_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(15, **it, target, stream); @@ -911,21 +911,17 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { // repeated string file_to_generate = 1; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->file_to_generate_size()); - for (int i = 0, n = this->file_to_generate_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(file_to_generate_.size()); + for (int i = 0, n = file_to_generate_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->file_to_generate(i)); + file_to_generate_.Get(i)); } // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - { - unsigned int count = static_cast(this->proto_file_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->proto_file(static_cast(i))); - } + total_size += 1UL * this->proto_file_size(); + for (const auto& msg : this->proto_file_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -934,7 +930,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->parameter()); + this->_internal_parameter()); } // optional .google.protobuf.compiler.Version compiler_version = 3; @@ -1013,8 +1009,8 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - file_to_generate_.InternalSwap(CastToBase(&other->file_to_generate_)); - CastToBase(&proto_file_)->InternalSwap(CastToBase(&other->proto_file_)); + file_to_generate_.InternalSwap(&other->file_to_generate_); + proto_file_.InternalSwap(&other->proto_file_); parameter_.Swap(&other->parameter_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(compiler_version_, other->compiler_version_); @@ -1054,15 +1050,15 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { + if (from._internal_has_name()) { name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_); } insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_insertion_point()) { + if (from._internal_has_insertion_point()) { insertion_point_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.insertion_point_); } content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_content()) { + if (from._internal_has_content()) { content_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.content_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1129,21 +1125,21 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); CHK_(ptr); } else goto handle_unusual; continue; // optional string insertion_point = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_insertion_point(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_insertion_point(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); CHK_(ptr); } else goto handle_unusual; continue; // optional string content = 15; case 15: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_content(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_content(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1182,9 +1178,9 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); } else { @@ -1197,9 +1193,9 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_insertion_point())); + input, this->_internal_mutable_insertion_point())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->insertion_point().data(), static_cast(this->insertion_point().length()), + this->_internal_insertion_point().data(), static_cast(this->_internal_insertion_point().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); } else { @@ -1212,9 +1208,9 @@ bool CodeGeneratorResponse_File::MergePartialFromCodedStream( case 15: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (122 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_content())); + input, this->_internal_mutable_content())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->content().data(), static_cast(this->content().length()), + this->_internal_content().data(), static_cast(this->_internal_content().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); } else { @@ -1254,31 +1250,31 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional string insertion_point = 2; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->insertion_point().data(), static_cast(this->insertion_point().length()), + this->_internal_insertion_point().data(), static_cast(this->_internal_insertion_point().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point"); target = stream->WriteStringMaybeAliased( - 2, this->insertion_point(), target); + 2, this->_internal_insertion_point(), target); } // optional string content = 15; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->content().data(), static_cast(this->content().length()), + this->_internal_content().data(), static_cast(this->_internal_content().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.File.content"); target = stream->WriteStringMaybeAliased( - 15, this->content(), target); + 15, this->_internal_content(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1303,21 +1299,21 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional string insertion_point = 2; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->insertion_point()); + this->_internal_insertion_point()); } // optional string content = 15; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->content()); + this->_internal_content()); } } @@ -1428,7 +1424,7 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) file_(from.file_) { _internal_metadata_.MergeFrom(from._internal_metadata_); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_error()) { + if (from._internal_has_error()) { error_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.error_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) @@ -1484,7 +1480,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA // optional string error = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_error(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.error"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_error(), ptr, ctx, "google.protobuf.compiler.CodeGeneratorResponse.error"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1497,7 +1493,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA ptr = ctx->ParseMessage(add_file(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 122); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr)); } else goto handle_unusual; continue; default: { @@ -1535,9 +1531,9 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_error())); + input, this->_internal_mutable_error())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->error().data(), static_cast(this->error().length()), + this->_internal_error().data(), static_cast(this->_internal_error().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.compiler.CodeGeneratorResponse.error"); } else { @@ -1588,16 +1584,16 @@ failure: // optional string error = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->error().data(), static_cast(this->error().length()), + this->_internal_error().data(), static_cast(this->_internal_error().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.compiler.CodeGeneratorResponse.error"); target = stream->WriteStringMaybeAliased( - 1, this->error(), target); + 1, this->_internal_error(), target); } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (auto it = this->file().pointer_begin(), - end = this->file().pointer_end(); it < end; ++it) { + for (auto it = this->file_.pointer_begin(), + end = this->file_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(15, **it, target, stream); @@ -1620,14 +1616,10 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - { - unsigned int count = static_cast(this->file_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->file(static_cast(i))); - } + total_size += 1UL * this->file_size(); + for (const auto& msg : this->file_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // optional string error = 1; @@ -1635,7 +1627,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->error()); + this->_internal_error()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1698,7 +1690,7 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&file_)->InternalSwap(CastToBase(&other->file_)); + file_.InternalSwap(&other->file_); error_.Swap(&other->error_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 5055df2e15..511abee2a3 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -213,6 +213,9 @@ class PROTOC_EXPORT Version : }; // optional string suffix = 4; bool has_suffix() const; + private: + bool _internal_has_suffix() const; + public: void clear_suffix(); const std::string& suffix() const; void set_suffix(const std::string& value); @@ -222,21 +225,35 @@ class PROTOC_EXPORT Version : std::string* mutable_suffix(); std::string* release_suffix(); void set_allocated_suffix(std::string* suffix); + private: + const std::string& _internal_suffix() const; + void _internal_set_suffix(const std::string& value); + std::string* _internal_mutable_suffix(); + public: // optional int32 major = 1; bool has_major() const; + private: + bool _internal_has_major() const; + public: void clear_major(); ::PROTOBUF_NAMESPACE_ID::int32 major() const; void set_major(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 minor = 2; bool has_minor() const; + private: + bool _internal_has_minor() const; + public: void clear_minor(); ::PROTOBUF_NAMESPACE_ID::int32 minor() const; void set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 patch = 3; bool has_patch() const; + private: + bool _internal_has_patch() const; + public: void clear_patch(); ::PROTOBUF_NAMESPACE_ID::int32 patch() const; void set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -395,6 +412,9 @@ class PROTOC_EXPORT CodeGeneratorRequest : void add_file_to_generate(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& file_to_generate() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_file_to_generate(); + private: + std::string* _internal_add_file_to_generate(); + public: // repeated .google.protobuf.FileDescriptorProto proto_file = 15; int proto_file_size() const; @@ -409,6 +429,9 @@ class PROTOC_EXPORT CodeGeneratorRequest : // optional string parameter = 2; bool has_parameter() const; + private: + bool _internal_has_parameter() const; + public: void clear_parameter(); const std::string& parameter() const; void set_parameter(const std::string& value); @@ -418,9 +441,17 @@ class PROTOC_EXPORT CodeGeneratorRequest : std::string* mutable_parameter(); std::string* release_parameter(); void set_allocated_parameter(std::string* parameter); + private: + const std::string& _internal_parameter() const; + void _internal_set_parameter(const std::string& value); + std::string* _internal_mutable_parameter(); + public: // optional .google.protobuf.compiler.Version compiler_version = 3; bool has_compiler_version() const; + private: + bool _internal_has_compiler_version() const; + public: void clear_compiler_version(); const PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const; PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); @@ -566,6 +597,9 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : }; // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -575,9 +609,17 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_name(); std::string* release_name(); void set_allocated_name(std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional string insertion_point = 2; bool has_insertion_point() const; + private: + bool _internal_has_insertion_point() const; + public: void clear_insertion_point(); const std::string& insertion_point() const; void set_insertion_point(const std::string& value); @@ -587,9 +629,17 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_insertion_point(); std::string* release_insertion_point(); void set_allocated_insertion_point(std::string* insertion_point); + private: + const std::string& _internal_insertion_point() const; + void _internal_set_insertion_point(const std::string& value); + std::string* _internal_mutable_insertion_point(); + public: // optional string content = 15; bool has_content() const; + private: + bool _internal_has_content() const; + public: void clear_content(); const std::string& content() const; void set_content(const std::string& value); @@ -599,6 +649,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File : std::string* mutable_content(); std::string* release_content(); void set_allocated_content(std::string* content); + private: + const std::string& _internal_content() const; + void _internal_set_content(const std::string& value); + std::string* _internal_mutable_content(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File) private: @@ -750,6 +805,9 @@ class PROTOC_EXPORT CodeGeneratorResponse : // optional string error = 1; bool has_error() const; + private: + bool _internal_has_error() const; + public: void clear_error(); const std::string& error() const; void set_error(const std::string& value); @@ -759,6 +817,11 @@ class PROTOC_EXPORT CodeGeneratorResponse : std::string* mutable_error(); std::string* release_error(); void set_allocated_error(std::string* error); + private: + const std::string& _internal_error() const; + void _internal_set_error(const std::string& value); + std::string* _internal_mutable_error(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: @@ -783,9 +846,12 @@ class PROTOC_EXPORT CodeGeneratorResponse : // Version // optional int32 major = 1; -inline bool Version::has_major() const { +inline bool Version::_internal_has_major() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool Version::has_major() const { + return _internal_has_major(); +} inline void Version::clear_major() { major_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -801,9 +867,12 @@ inline void Version::set_major(::PROTOBUF_NAMESPACE_ID::int32 value) { } // optional int32 minor = 2; -inline bool Version::has_minor() const { +inline bool Version::_internal_has_minor() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool Version::has_minor() const { + return _internal_has_minor(); +} inline void Version::clear_minor() { minor_ = 0; _has_bits_[0] &= ~0x00000004u; @@ -819,9 +888,12 @@ inline void Version::set_minor(::PROTOBUF_NAMESPACE_ID::int32 value) { } // optional int32 patch = 3; -inline bool Version::has_patch() const { +inline bool Version::_internal_has_patch() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool Version::has_patch() const { + return _internal_has_patch(); +} inline void Version::clear_patch() { patch_ = 0; _has_bits_[0] &= ~0x00000008u; @@ -837,21 +909,34 @@ inline void Version::set_patch(::PROTOBUF_NAMESPACE_ID::int32 value) { } // optional string suffix = 4; -inline bool Version::has_suffix() const { +inline bool Version::_internal_has_suffix() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool Version::has_suffix() const { + return _internal_has_suffix(); +} inline void Version::clear_suffix() { suffix_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& Version::suffix() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) - return suffix_.GetNoArena(); + return _internal_suffix(); } inline void Version::set_suffix(const std::string& value) { + _internal_set_suffix(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} +inline std::string* Version::mutable_suffix() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) + return _internal_mutable_suffix(); +} +inline const std::string& Version::_internal_suffix() const { + return suffix_.GetNoArena(); +} +inline void Version::_internal_set_suffix(const std::string& value) { _has_bits_[0] |= 0x00000001u; suffix_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) } inline void Version::set_suffix(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -871,9 +956,8 @@ inline void Version::set_suffix(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.Version.suffix) } -inline std::string* Version::mutable_suffix() { +inline std::string* Version::_internal_mutable_suffix() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) return suffix_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* Version::release_suffix() { @@ -905,6 +989,10 @@ inline int CodeGeneratorRequest::file_to_generate_size() const { inline void CodeGeneratorRequest::clear_file_to_generate() { file_to_generate_.Clear(); } +inline std::string* CodeGeneratorRequest::add_file_to_generate() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) + return _internal_add_file_to_generate(); +} inline const std::string& CodeGeneratorRequest::file_to_generate(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) return file_to_generate_.Get(index); @@ -931,8 +1019,7 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* va reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } -inline std::string* CodeGeneratorRequest::add_file_to_generate() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +inline std::string* CodeGeneratorRequest::_internal_add_file_to_generate() { return file_to_generate_.Add(); } inline void CodeGeneratorRequest::add_file_to_generate(const std::string& value) { @@ -964,21 +1051,34 @@ CodeGeneratorRequest::mutable_file_to_generate() { } // optional string parameter = 2; -inline bool CodeGeneratorRequest::has_parameter() const { +inline bool CodeGeneratorRequest::_internal_has_parameter() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool CodeGeneratorRequest::has_parameter() const { + return _internal_has_parameter(); +} inline void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) - return parameter_.GetNoArena(); + return _internal_parameter(); } inline void CodeGeneratorRequest::set_parameter(const std::string& value) { + _internal_set_parameter(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) +} +inline std::string* CodeGeneratorRequest::mutable_parameter() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter) + return _internal_mutable_parameter(); +} +inline const std::string& CodeGeneratorRequest::_internal_parameter() const { + return parameter_.GetNoArena(); +} +inline void CodeGeneratorRequest::_internal_set_parameter(const std::string& value) { _has_bits_[0] |= 0x00000001u; parameter_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter) } inline void CodeGeneratorRequest::set_parameter(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -998,9 +1098,8 @@ inline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter) } -inline std::string* CodeGeneratorRequest::mutable_parameter() { +inline std::string* CodeGeneratorRequest::_internal_mutable_parameter() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter) return parameter_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* CodeGeneratorRequest::release_parameter() { @@ -1049,9 +1148,12 @@ CodeGeneratorRequest::proto_file() const { } // optional .google.protobuf.compiler.Version compiler_version = 3; -inline bool CodeGeneratorRequest::has_compiler_version() const { +inline bool CodeGeneratorRequest::_internal_has_compiler_version() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool CodeGeneratorRequest::has_compiler_version() const { + return _internal_has_compiler_version(); +} inline void CodeGeneratorRequest::clear_compiler_version() { if (compiler_version_ != nullptr) compiler_version_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -1102,21 +1204,34 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESP // CodeGeneratorResponse_File // optional string name = 1; -inline bool CodeGeneratorResponse_File::has_name() const { +inline bool CodeGeneratorResponse_File::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool CodeGeneratorResponse_File::has_name() const { + return _internal_has_name(); +} inline void CodeGeneratorResponse_File::clear_name() { name_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse_File::name() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name) - return name_.GetNoArena(); + return _internal_name(); } inline void CodeGeneratorResponse_File::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) +} +inline std::string* CodeGeneratorResponse_File::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) + return _internal_mutable_name(); +} +inline const std::string& CodeGeneratorResponse_File::_internal_name() const { + return name_.GetNoArena(); +} +inline void CodeGeneratorResponse_File::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name) } inline void CodeGeneratorResponse_File::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -1136,9 +1251,8 @@ inline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name) } -inline std::string* CodeGeneratorResponse_File::mutable_name() { +inline std::string* CodeGeneratorResponse_File::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name) return name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* CodeGeneratorResponse_File::release_name() { @@ -1160,21 +1274,34 @@ inline void CodeGeneratorResponse_File::set_allocated_name(std::string* name) { } // optional string insertion_point = 2; -inline bool CodeGeneratorResponse_File::has_insertion_point() const { +inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool CodeGeneratorResponse_File::has_insertion_point() const { + return _internal_has_insertion_point(); +} inline void CodeGeneratorResponse_File::clear_insertion_point() { insertion_point_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000002u; } 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(); + return _internal_insertion_point(); } inline void CodeGeneratorResponse_File::set_insertion_point(const std::string& value) { + _internal_set_insertion_point(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) +} +inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) + return _internal_mutable_insertion_point(); +} +inline const std::string& CodeGeneratorResponse_File::_internal_insertion_point() const { + return insertion_point_.GetNoArena(); +} +inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const std::string& value) { _has_bits_[0] |= 0x00000002u; insertion_point_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } inline void CodeGeneratorResponse_File::set_insertion_point(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -1194,9 +1321,8 @@ inline void CodeGeneratorResponse_File::set_insertion_point(const char* value, s ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) } -inline std::string* CodeGeneratorResponse_File::mutable_insertion_point() { +inline std::string* CodeGeneratorResponse_File::_internal_mutable_insertion_point() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point) return insertion_point_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* CodeGeneratorResponse_File::release_insertion_point() { @@ -1218,21 +1344,34 @@ inline void CodeGeneratorResponse_File::set_allocated_insertion_point(std::strin } // optional string content = 15; -inline bool CodeGeneratorResponse_File::has_content() const { +inline bool CodeGeneratorResponse_File::_internal_has_content() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool CodeGeneratorResponse_File::has_content() const { + return _internal_has_content(); +} inline void CodeGeneratorResponse_File::clear_content() { content_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& CodeGeneratorResponse_File::content() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content) - return content_.GetNoArena(); + return _internal_content(); } inline void CodeGeneratorResponse_File::set_content(const std::string& value) { + _internal_set_content(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) +} +inline std::string* CodeGeneratorResponse_File::mutable_content() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) + return _internal_mutable_content(); +} +inline const std::string& CodeGeneratorResponse_File::_internal_content() const { + return content_.GetNoArena(); +} +inline void CodeGeneratorResponse_File::_internal_set_content(const std::string& value) { _has_bits_[0] |= 0x00000004u; content_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content) } inline void CodeGeneratorResponse_File::set_content(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -1252,9 +1391,8 @@ inline void CodeGeneratorResponse_File::set_content(const char* value, size_t si ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content) } -inline std::string* CodeGeneratorResponse_File::mutable_content() { +inline std::string* CodeGeneratorResponse_File::_internal_mutable_content() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content) return content_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* CodeGeneratorResponse_File::release_content() { @@ -1280,21 +1418,34 @@ inline void CodeGeneratorResponse_File::set_allocated_content(std::string* conte // CodeGeneratorResponse // optional string error = 1; -inline bool CodeGeneratorResponse::has_error() const { +inline bool CodeGeneratorResponse::_internal_has_error() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool CodeGeneratorResponse::has_error() const { + return _internal_has_error(); +} inline void CodeGeneratorResponse::clear_error() { error_.ClearToEmptyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& CodeGeneratorResponse::error() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error) - return error_.GetNoArena(); + return _internal_error(); } inline void CodeGeneratorResponse::set_error(const std::string& value) { + _internal_set_error(value); + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) +} +inline std::string* CodeGeneratorResponse::mutable_error() { + // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error) + return _internal_mutable_error(); +} +inline const std::string& CodeGeneratorResponse::_internal_error() const { + return error_.GetNoArena(); +} +inline void CodeGeneratorResponse::_internal_set_error(const std::string& value) { _has_bits_[0] |= 0x00000001u; error_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error) } inline void CodeGeneratorResponse::set_error(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -1314,9 +1465,8 @@ inline void CodeGeneratorResponse::set_error(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error) } -inline std::string* CodeGeneratorResponse::mutable_error() { +inline std::string* CodeGeneratorResponse::_internal_mutable_error() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error) return error_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* CodeGeneratorResponse::release_error() { diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index ec0704a18c..cddad3ea2c 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -64,8 +64,6 @@ #include #include - - namespace google { namespace protobuf { namespace compiler { diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index 67b5538cd7..092cbc37a2 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -537,7 +537,8 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer, } // TODO: Remove this when ruby supports extensions for proto2 syntax. - if (file->extension_count() > 0) { + if (file->syntax() == FileDescriptor::SYNTAX_PROTO2 && + file->extension_count() > 0) { *error = "Extensions are not yet supported for proto2 .proto files."; return false; } diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 5bc64f1fda..df25ac9cd6 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -32,6 +32,8 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include #include @@ -48,11 +50,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -61,9 +61,7 @@ #include #include #include - - - +#include #include #include #include @@ -4696,7 +4694,7 @@ void DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto, // `ErrorCollector` interface to extend them to handle the new // error location type properly. DescriptorPool::ErrorCollector::TYPE, - "Message extensions cannot have required fields."); + "The extension " + result->full_name() + " cannot be required."); } // Some of these may be filled in when cross-linking. diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 8feecb88a1..092be42854 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -161,7 +161,7 @@ static void InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_ } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, 0, InitDefaultsscc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto.base, @@ -181,7 +181,7 @@ static void InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobu } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_DescriptorProto_ExtensionRange_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto() { @@ -196,7 +196,7 @@ static void InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_DescriptorProto_ReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; static void InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -210,7 +210,7 @@ static void InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescrip } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto.base,}}; @@ -227,7 +227,7 @@ static void InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2f } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_EnumDescriptorProto_EnumReservedRange_google_2fprotobuf_2fdescriptor_2eproto}, {}}; static void InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -241,7 +241,7 @@ static void InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2epr } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -256,7 +256,7 @@ static void InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fde } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumValueDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -271,7 +271,7 @@ static void InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumValueOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -286,7 +286,7 @@ static void InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescr } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ExtensionRangeOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -301,7 +301,7 @@ static void InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescri } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FieldDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -316,7 +316,7 @@ static void InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2ep } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FieldOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -331,7 +331,7 @@ static void InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescrip } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<6> scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 6, 0, InitDefaultsscc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_DescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_EnumDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, @@ -351,7 +351,7 @@ static void InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescripto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FileDescriptorSet_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_FileDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -366,7 +366,7 @@ static void InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2epr } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_FileOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() { @@ -381,7 +381,7 @@ static void InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescripto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_GeneratedCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto() { @@ -396,7 +396,7 @@ static void InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_ } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_GeneratedCodeInfo_Annotation_google_2fprotobuf_2fdescriptor_2eproto}, {}}; static void InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -410,7 +410,7 @@ static void InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2 } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MessageOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -425,7 +425,7 @@ static void InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescr } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -440,7 +440,7 @@ static void InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2e } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MethodOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -455,7 +455,7 @@ static void InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescri } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OneofDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto() { @@ -470,7 +470,7 @@ static void InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2ep } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_OneofOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto() { @@ -485,7 +485,7 @@ static void InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdesc } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ServiceDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_MethodDescriptorProto_google_2fprotobuf_2fdescriptor_2eproto.base, &scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto.base,}}; @@ -501,7 +501,7 @@ static void InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2 } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_ServiceOptions_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto() { @@ -516,7 +516,7 @@ static void InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2 } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_SourceCodeInfo_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto() { @@ -531,7 +531,7 @@ static void InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdes } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_SourceCodeInfo_Location_google_2fprotobuf_2fdescriptor_2eproto}, {}}; static void InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -545,7 +545,7 @@ static void InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescrip } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_UninterpretedOption_google_2fprotobuf_2fdescriptor_2eproto}, { &scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto.base,}}; static void InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto() { @@ -560,7 +560,7 @@ static void InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_ } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_UninterpretedOption_NamePart_google_2fprotobuf_2fdescriptor_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[6]; @@ -1464,7 +1464,7 @@ const char* FileDescriptorSet::_InternalParse(const char* ptr, ::PROTOBUF_NAMESP ptr = ctx->ParseMessage(add_file(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -1536,8 +1536,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.FileDescriptorProto file = 1; - for (auto it = this->file().pointer_begin(), - end = this->file().pointer_end(); it < end; ++it) { + for (auto it = this->file_.pointer_begin(), + end = this->file_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(1, **it, target, stream); @@ -1560,14 +1560,10 @@ size_t FileDescriptorSet::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.FileDescriptorProto file = 1; - { - unsigned int count = static_cast(this->file_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->file(static_cast(i))); - } + total_size += 1UL * this->file_size(); + for (const auto& msg : this->file_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1627,7 +1623,7 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&file_)->InternalSwap(CastToBase(&other->file_)); + file_.InternalSwap(&other->file_); } ::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const { @@ -1731,18 +1727,18 @@ FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) weak_dependency_(from.weak_dependency_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_package()) { - package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.package(), + if (from._internal_has_package()) { + package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_package(), GetArenaNoVirtual()); } syntax_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_syntax()) { - syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.syntax(), + if (from._internal_has_syntax()) { + syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_syntax(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -1847,14 +1843,14 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.FileDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.FileDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; // optional string package = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_package(), ptr, ctx, "google.protobuf.FileDescriptorProto.package"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_package(), ptr, ctx, "google.protobuf.FileDescriptorProto.package"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1864,10 +1860,10 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(add_dependency(), ptr, ctx, "google.protobuf.FileDescriptorProto.dependency"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_add_dependency(), ptr, ctx, "google.protobuf.FileDescriptorProto.dependency"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.DescriptorProto message_type = 4; @@ -1879,7 +1875,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_message_type(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 34); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; @@ -1891,7 +1887,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_enum_type(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 42); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.ServiceDescriptorProto service = 6; @@ -1903,7 +1899,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_service(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 50); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.FieldDescriptorProto extension = 7; @@ -1915,7 +1911,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_extension(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 58); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(ptr)); } else goto handle_unusual; continue; // optional .google.protobuf.FileOptions options = 8; @@ -1941,7 +1937,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME add_public_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr)); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 80); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<80>(ptr)); } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82) { ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(mutable_public_dependency(), ptr, ctx); CHK_(ptr); @@ -1956,7 +1952,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME add_weak_dependency(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr)); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 88); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<88>(ptr)); } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90) { ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(mutable_weak_dependency(), ptr, ctx); CHK_(ptr); @@ -1965,7 +1961,7 @@ const char* FileDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional string syntax = 12; case 12: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 98)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_syntax(), ptr, ctx, "google.protobuf.FileDescriptorProto.syntax"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_syntax(), ptr, ctx, "google.protobuf.FileDescriptorProto.syntax"); CHK_(ptr); } else goto handle_unusual; continue; @@ -2004,9 +2000,9 @@ bool FileDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.name"); } else { @@ -2019,9 +2015,9 @@ bool FileDescriptorProto::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_package())); + input, this->_internal_mutable_package())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->package().data(), static_cast(this->package().length()), + this->_internal_package().data(), static_cast(this->_internal_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.package"); } else { @@ -2034,10 +2030,10 @@ bool FileDescriptorProto::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_dependency())); + input, this->_internal_add_dependency())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->dependency(this->dependency_size() - 1).data(), - static_cast(this->dependency(this->dependency_size() - 1).length()), + dependency_.Get(dependency_.size() - 1).data(), + static_cast(dependency_.Get(dependency_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.dependency"); } else { @@ -2148,9 +2144,9 @@ bool FileDescriptorProto::MergePartialFromCodedStream( case 12: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (98 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_syntax())); + input, this->_internal_mutable_syntax())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->syntax().data(), static_cast(this->syntax().length()), + this->_internal_syntax().data(), static_cast(this->_internal_syntax().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileDescriptorProto.syntax"); } else { @@ -2190,26 +2186,26 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional string package = 2; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->package().data(), static_cast(this->package().length()), + this->_internal_package().data(), static_cast(this->_internal_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.package"); target = stream->WriteStringMaybeAliased( - 2, this->package(), target); + 2, this->_internal_package(), target); } // repeated string dependency = 3; - for (auto it = this->dependency().pointer_begin(), - end = this->dependency().pointer_end(); it < end; ++it) { + for (auto it = dependency_.pointer_begin(), + end = dependency_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( s.data(), static_cast(s.length()), @@ -2219,32 +2215,32 @@ failure: } // repeated .google.protobuf.DescriptorProto message_type = 4; - for (auto it = this->message_type().pointer_begin(), - end = this->message_type().pointer_end(); it < end; ++it) { + for (auto it = this->message_type_.pointer_begin(), + end = this->message_type_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(4, **it, target, stream); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - for (auto it = this->enum_type().pointer_begin(), - end = this->enum_type().pointer_end(); it < end; ++it) { + for (auto it = this->enum_type_.pointer_begin(), + end = this->enum_type_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(5, **it, target, stream); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - for (auto it = this->service().pointer_begin(), - end = this->service().pointer_end(); it < end; ++it) { + for (auto it = this->service_.pointer_begin(), + end = this->service_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(6, **it, target, stream); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - for (auto it = this->extension().pointer_begin(), - end = this->extension().pointer_end(); it < end; ++it) { + for (auto it = this->extension_.pointer_begin(), + end = this->extension_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(7, **it, target, stream); @@ -2281,11 +2277,11 @@ failure: // optional string syntax = 12; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->syntax().data(), static_cast(this->syntax().length()), + this->_internal_syntax().data(), static_cast(this->_internal_syntax().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileDescriptorProto.syntax"); target = stream->WriteStringMaybeAliased( - 12, this->syntax(), target); + 12, this->_internal_syntax(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -2306,54 +2302,38 @@ size_t FileDescriptorProto::ByteSizeLong() const { // repeated string dependency = 3; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->dependency_size()); - for (int i = 0, n = this->dependency_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(dependency_.size()); + for (int i = 0, n = dependency_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->dependency(i)); + dependency_.Get(i)); } // repeated .google.protobuf.DescriptorProto message_type = 4; - { - unsigned int count = static_cast(this->message_type_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->message_type(static_cast(i))); - } + total_size += 1UL * this->message_type_size(); + for (const auto& msg : this->message_type_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; - { - unsigned int count = static_cast(this->enum_type_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->enum_type(static_cast(i))); - } + total_size += 1UL * this->enum_type_size(); + for (const auto& msg : this->enum_type_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.ServiceDescriptorProto service = 6; - { - unsigned int count = static_cast(this->service_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->service(static_cast(i))); - } + total_size += 1UL * this->service_size(); + for (const auto& msg : this->service_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.FieldDescriptorProto extension = 7; - { - unsigned int count = static_cast(this->extension_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->extension(static_cast(i))); - } + total_size += 1UL * this->extension_size(); + for (const auto& msg : this->extension_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated int32 public_dependency = 10; @@ -2380,21 +2360,21 @@ size_t FileDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional string package = 2; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->package()); + this->_internal_package()); } // optional string syntax = 12; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->syntax()); + this->_internal_syntax()); } // optional .google.protobuf.FileOptions options = 8; @@ -2453,13 +2433,13 @@ void FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - set_package(from.package()); + _internal_set_package(from._internal_package()); } if (cached_has_bits & 0x00000004u) { - set_syntax(from.syntax()); + _internal_set_syntax(from._internal_syntax()); } if (cached_has_bits & 0x00000008u) { mutable_options()->PROTOBUF_NAMESPACE_ID::FileOptions::MergeFrom(from.options()); @@ -2499,11 +2479,11 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - dependency_.InternalSwap(CastToBase(&other->dependency_)); - CastToBase(&message_type_)->InternalSwap(CastToBase(&other->message_type_)); - CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_)); - CastToBase(&service_)->InternalSwap(CastToBase(&other->service_)); - CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_)); + dependency_.InternalSwap(&other->dependency_); + message_type_.InternalSwap(&other->message_type_); + enum_type_.InternalSwap(&other->enum_type_); + service_.InternalSwap(&other->service_); + extension_.InternalSwap(&other->extension_); public_dependency_.InternalSwap(&other->public_dependency_); weak_dependency_.InternalSwap(&other->weak_dependency_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -3292,8 +3272,8 @@ DescriptorProto::DescriptorProto(const DescriptorProto& from) reserved_name_(from.reserved_name_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -3377,7 +3357,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.DescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.DescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -3390,7 +3370,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_field(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.DescriptorProto nested_type = 3; @@ -3402,7 +3382,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_nested_type(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; @@ -3414,7 +3394,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_enum_type(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 34); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; @@ -3426,7 +3406,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_extension_range(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 42); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.FieldDescriptorProto extension = 6; @@ -3438,7 +3418,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_extension(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 50); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; // optional .google.protobuf.MessageOptions options = 7; @@ -3457,7 +3437,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_oneof_decl(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 66); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; @@ -3469,7 +3449,7 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr = ctx->ParseMessage(add_reserved_range(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 74); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<74>(ptr)); } else goto handle_unusual; continue; // repeated string reserved_name = 10; @@ -3478,10 +3458,10 @@ const char* DescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPAC ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(add_reserved_name(), ptr, ctx, "google.protobuf.DescriptorProto.reserved_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_add_reserved_name(), ptr, ctx, "google.protobuf.DescriptorProto.reserved_name"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 82); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr)); } else goto handle_unusual; continue; default: { @@ -3519,9 +3499,9 @@ bool DescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.DescriptorProto.name"); } else { @@ -3622,10 +3602,10 @@ bool DescriptorProto::MergePartialFromCodedStream( case 10: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (82 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_reserved_name())); + input, this->_internal_add_reserved_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->reserved_name(this->reserved_name_size() - 1).data(), - static_cast(this->reserved_name(this->reserved_name_size() - 1).length()), + reserved_name_.Get(reserved_name_.size() - 1).data(), + static_cast(reserved_name_.Get(reserved_name_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.DescriptorProto.reserved_name"); } else { @@ -3665,48 +3645,48 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.DescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.FieldDescriptorProto field = 2; - for (auto it = this->field().pointer_begin(), - end = this->field().pointer_end(); it < end; ++it) { + for (auto it = this->field_.pointer_begin(), + end = this->field_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); } // repeated .google.protobuf.DescriptorProto nested_type = 3; - for (auto it = this->nested_type().pointer_begin(), - end = this->nested_type().pointer_end(); it < end; ++it) { + for (auto it = this->nested_type_.pointer_begin(), + end = this->nested_type_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(3, **it, target, stream); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - for (auto it = this->enum_type().pointer_begin(), - end = this->enum_type().pointer_end(); it < end; ++it) { + for (auto it = this->enum_type_.pointer_begin(), + end = this->enum_type_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(4, **it, target, stream); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - for (auto it = this->extension_range().pointer_begin(), - end = this->extension_range().pointer_end(); it < end; ++it) { + for (auto it = this->extension_range_.pointer_begin(), + end = this->extension_range_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(5, **it, target, stream); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - for (auto it = this->extension().pointer_begin(), - end = this->extension().pointer_end(); it < end; ++it) { + for (auto it = this->extension_.pointer_begin(), + end = this->extension_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(6, **it, target, stream); @@ -3721,24 +3701,24 @@ failure: } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - for (auto it = this->oneof_decl().pointer_begin(), - end = this->oneof_decl().pointer_end(); it < end; ++it) { + for (auto it = this->oneof_decl_.pointer_begin(), + end = this->oneof_decl_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(8, **it, target, stream); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - for (auto it = this->reserved_range().pointer_begin(), - end = this->reserved_range().pointer_end(); it < end; ++it) { + for (auto it = this->reserved_range_.pointer_begin(), + end = this->reserved_range_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(9, **it, target, stream); } // repeated string reserved_name = 10; - for (auto it = this->reserved_name().pointer_begin(), - end = this->reserved_name().pointer_end(); it < end; ++it) { + for (auto it = reserved_name_.pointer_begin(), + end = reserved_name_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( s.data(), static_cast(s.length()), @@ -3764,88 +3744,60 @@ size_t DescriptorProto::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.FieldDescriptorProto field = 2; - { - unsigned int count = static_cast(this->field_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->field(static_cast(i))); - } + total_size += 1UL * this->field_size(); + for (const auto& msg : this->field_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto nested_type = 3; - { - unsigned int count = static_cast(this->nested_type_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->nested_type(static_cast(i))); - } + total_size += 1UL * this->nested_type_size(); + for (const auto& msg : this->nested_type_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; - { - unsigned int count = static_cast(this->enum_type_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->enum_type(static_cast(i))); - } + total_size += 1UL * this->enum_type_size(); + for (const auto& msg : this->enum_type_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; - { - unsigned int count = static_cast(this->extension_range_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->extension_range(static_cast(i))); - } + total_size += 1UL * this->extension_range_size(); + for (const auto& msg : this->extension_range_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.FieldDescriptorProto extension = 6; - { - unsigned int count = static_cast(this->extension_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->extension(static_cast(i))); - } + total_size += 1UL * this->extension_size(); + for (const auto& msg : this->extension_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; - { - unsigned int count = static_cast(this->oneof_decl_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->oneof_decl(static_cast(i))); - } + total_size += 1UL * this->oneof_decl_size(); + for (const auto& msg : this->oneof_decl_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; - { - unsigned int count = static_cast(this->reserved_range_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->reserved_range(static_cast(i))); - } + total_size += 1UL * this->reserved_range_size(); + for (const auto& msg : this->reserved_range_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string reserved_name = 10; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->reserved_name_size()); - for (int i = 0, n = this->reserved_name_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(reserved_name_.size()); + for (int i = 0, n = reserved_name_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->reserved_name(i)); + reserved_name_.Get(i)); } cached_has_bits = _has_bits_[0]; @@ -3854,7 +3806,7 @@ size_t DescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional .google.protobuf.MessageOptions options = 7; @@ -3907,7 +3859,7 @@ void DescriptorProto::MergeFrom(const DescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->PROTOBUF_NAMESPACE_ID::MessageOptions::MergeFrom(from.options()); @@ -3946,14 +3898,14 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&field_)->InternalSwap(CastToBase(&other->field_)); - CastToBase(&nested_type_)->InternalSwap(CastToBase(&other->nested_type_)); - CastToBase(&enum_type_)->InternalSwap(CastToBase(&other->enum_type_)); - CastToBase(&extension_range_)->InternalSwap(CastToBase(&other->extension_range_)); - CastToBase(&extension_)->InternalSwap(CastToBase(&other->extension_)); - CastToBase(&oneof_decl_)->InternalSwap(CastToBase(&other->oneof_decl_)); - CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_)); - reserved_name_.InternalSwap(CastToBase(&other->reserved_name_)); + field_.InternalSwap(&other->field_); + nested_type_.InternalSwap(&other->nested_type_); + enum_type_.InternalSwap(&other->enum_type_); + extension_range_.InternalSwap(&other->extension_range_); + extension_.InternalSwap(&other->extension_); + oneof_decl_.InternalSwap(&other->oneof_decl_); + reserved_range_.InternalSwap(&other->reserved_range_); + reserved_name_.InternalSwap(&other->reserved_name_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(options_, other->options_); @@ -4055,7 +4007,7 @@ const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::PROTOBUF_NA ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -4139,8 +4091,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -4169,14 +4121,10 @@ size_t ExtensionRangeOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -4242,7 +4190,7 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); } ::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const { @@ -4327,28 +4275,28 @@ FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } extendee_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_extendee()) { - extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.extendee(), + if (from._internal_has_extendee()) { + extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_extendee(), GetArenaNoVirtual()); } type_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_type_name()) { - type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_name(), + if (from._internal_has_type_name()) { + type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type_name(), GetArenaNoVirtual()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_default_value()) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.default_value(), + if (from._internal_has_default_value()) { + default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_default_value(), GetArenaNoVirtual()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_json_name()) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.json_name(), + if (from._internal_has_json_name()) { + json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_json_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -4460,14 +4408,14 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; // optional string extendee = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_extendee(), ptr, ctx, "google.protobuf.FieldDescriptorProto.extendee"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_extendee(), ptr, ctx, "google.protobuf.FieldDescriptorProto.extendee"); CHK_(ptr); } else goto handle_unusual; continue; @@ -4506,14 +4454,14 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional string type_name = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_type_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.type_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_type_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.type_name"); CHK_(ptr); } else goto handle_unusual; continue; // optional string default_value = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_default_value(), ptr, ctx, "google.protobuf.FieldDescriptorProto.default_value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_default_value(), ptr, ctx, "google.protobuf.FieldDescriptorProto.default_value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -4535,7 +4483,7 @@ const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional string json_name = 10; case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_json_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.json_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_json_name(), ptr, ctx, "google.protobuf.FieldDescriptorProto.json_name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -4574,9 +4522,9 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.name"); } else { @@ -4589,9 +4537,9 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_extendee())); + input, this->_internal_mutable_extendee())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->extendee().data(), static_cast(this->extendee().length()), + this->_internal_extendee().data(), static_cast(this->_internal_extendee().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.extendee"); } else { @@ -4655,9 +4603,9 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (50 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_type_name())); + input, this->_internal_mutable_type_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->type_name().data(), static_cast(this->type_name().length()), + this->_internal_type_name().data(), static_cast(this->_internal_type_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.type_name"); } else { @@ -4670,9 +4618,9 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 7: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (58 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_default_value())); + input, this->_internal_mutable_default_value())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->default_value().data(), static_cast(this->default_value().length()), + this->_internal_default_value().data(), static_cast(this->_internal_default_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.default_value"); } else { @@ -4709,9 +4657,9 @@ bool FieldDescriptorProto::MergePartialFromCodedStream( case 10: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (82 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_json_name())); + input, this->_internal_mutable_json_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->json_name().data(), static_cast(this->json_name().length()), + this->_internal_json_name().data(), static_cast(this->_internal_json_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FieldDescriptorProto.json_name"); } else { @@ -4751,21 +4699,21 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional string extendee = 2; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->extendee().data(), static_cast(this->extendee().length()), + this->_internal_extendee().data(), static_cast(this->_internal_extendee().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.extendee"); target = stream->WriteStringMaybeAliased( - 2, this->extendee(), target); + 2, this->_internal_extendee(), target); } // optional int32 number = 3; @@ -4791,21 +4739,21 @@ failure: // optional string type_name = 6; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->type_name().data(), static_cast(this->type_name().length()), + this->_internal_type_name().data(), static_cast(this->_internal_type_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.type_name"); target = stream->WriteStringMaybeAliased( - 6, this->type_name(), target); + 6, this->_internal_type_name(), target); } // optional string default_value = 7; if (cached_has_bits & 0x00000008u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->default_value().data(), static_cast(this->default_value().length()), + this->_internal_default_value().data(), static_cast(this->_internal_default_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.default_value"); target = stream->WriteStringMaybeAliased( - 7, this->default_value(), target); + 7, this->_internal_default_value(), target); } // optional .google.protobuf.FieldOptions options = 8; @@ -4825,11 +4773,11 @@ failure: // optional string json_name = 10; if (cached_has_bits & 0x00000010u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->json_name().data(), static_cast(this->json_name().length()), + this->_internal_json_name().data(), static_cast(this->_internal_json_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FieldDescriptorProto.json_name"); target = stream->WriteStringMaybeAliased( - 10, this->json_name(), target); + 10, this->_internal_json_name(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -4854,35 +4802,35 @@ size_t FieldDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional string extendee = 2; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->extendee()); + this->_internal_extendee()); } // optional string type_name = 6; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->type_name()); + this->_internal_type_name()); } // optional string default_value = 7; if (cached_has_bits & 0x00000008u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->default_value()); + this->_internal_default_value()); } // optional string json_name = 10; if (cached_has_bits & 0x00000010u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->json_name()); + this->_internal_json_name()); } // optional .google.protobuf.FieldOptions options = 8; @@ -4955,19 +4903,19 @@ void FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - set_extendee(from.extendee()); + _internal_set_extendee(from._internal_extendee()); } if (cached_has_bits & 0x00000004u) { - set_type_name(from.type_name()); + _internal_set_type_name(from._internal_type_name()); } if (cached_has_bits & 0x00000008u) { - set_default_value(from.default_value()); + _internal_set_default_value(from._internal_default_value()); } if (cached_has_bits & 0x00000010u) { - set_json_name(from.json_name()); + _internal_set_json_name(from._internal_json_name()); } if (cached_has_bits & 0x00000020u) { mutable_options()->PROTOBUF_NAMESPACE_ID::FieldOptions::MergeFrom(from.options()); @@ -5091,8 +5039,8 @@ OneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from) _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -5168,7 +5116,7 @@ const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAM // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.OneofDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.OneofDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -5214,9 +5162,9 @@ bool OneofDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.OneofDescriptorProto.name"); } else { @@ -5267,11 +5215,11 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.OneofDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional .google.protobuf.OneofOptions options = 2; @@ -5304,7 +5252,7 @@ size_t OneofDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional .google.protobuf.OneofOptions options = 2; @@ -5349,7 +5297,7 @@ void OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->PROTOBUF_NAMESPACE_ID::OneofOptions::MergeFrom(from.options()); @@ -5765,8 +5713,8 @@ EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) reserved_name_(from.reserved_name_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -5845,7 +5793,7 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.EnumDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.EnumDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -5858,7 +5806,7 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_value(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // optional .google.protobuf.EnumOptions options = 3; @@ -5877,7 +5825,7 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_reserved_range(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 34); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; // repeated string reserved_name = 5; @@ -5886,10 +5834,10 @@ const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(add_reserved_name(), ptr, ctx, "google.protobuf.EnumDescriptorProto.reserved_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_add_reserved_name(), ptr, ctx, "google.protobuf.EnumDescriptorProto.reserved_name"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 42); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<42>(ptr)); } else goto handle_unusual; continue; default: { @@ -5927,9 +5875,9 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.EnumDescriptorProto.name"); } else { @@ -5975,10 +5923,10 @@ bool EnumDescriptorProto::MergePartialFromCodedStream( case 5: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (42 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_reserved_name())); + input, this->_internal_add_reserved_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->reserved_name(this->reserved_name_size() - 1).data(), - static_cast(this->reserved_name(this->reserved_name_size() - 1).length()), + reserved_name_.Get(reserved_name_.size() - 1).data(), + static_cast(reserved_name_.Get(reserved_name_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.EnumDescriptorProto.reserved_name"); } else { @@ -6018,16 +5966,16 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.EnumDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - for (auto it = this->value().pointer_begin(), - end = this->value().pointer_end(); it < end; ++it) { + for (auto it = this->value_.pointer_begin(), + end = this->value_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); @@ -6042,16 +5990,16 @@ failure: } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; - for (auto it = this->reserved_range().pointer_begin(), - end = this->reserved_range().pointer_end(); it < end; ++it) { + for (auto it = this->reserved_range_.pointer_begin(), + end = this->reserved_range_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(4, **it, target, stream); } // repeated string reserved_name = 5; - for (auto it = this->reserved_name().pointer_begin(), - end = this->reserved_name().pointer_end(); it < end; ++it) { + for (auto it = reserved_name_.pointer_begin(), + end = reserved_name_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( s.data(), static_cast(s.length()), @@ -6077,33 +6025,25 @@ size_t EnumDescriptorProto::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.EnumValueDescriptorProto value = 2; - { - unsigned int count = static_cast(this->value_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->value(static_cast(i))); - } + total_size += 1UL * this->value_size(); + for (const auto& msg : this->value_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.EnumDescriptorProto.EnumReservedRange reserved_range = 4; - { - unsigned int count = static_cast(this->reserved_range_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->reserved_range(static_cast(i))); - } + total_size += 1UL * this->reserved_range_size(); + for (const auto& msg : this->reserved_range_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string reserved_name = 5; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->reserved_name_size()); - for (int i = 0, n = this->reserved_name_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(reserved_name_.size()); + for (int i = 0, n = reserved_name_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->reserved_name(i)); + reserved_name_.Get(i)); } cached_has_bits = _has_bits_[0]; @@ -6112,7 +6052,7 @@ size_t EnumDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional .google.protobuf.EnumOptions options = 3; @@ -6160,7 +6100,7 @@ void EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->PROTOBUF_NAMESPACE_ID::EnumOptions::MergeFrom(from.options()); @@ -6194,9 +6134,9 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&value_)->InternalSwap(CastToBase(&other->value_)); - CastToBase(&reserved_range_)->InternalSwap(CastToBase(&other->reserved_range_)); - reserved_name_.InternalSwap(CastToBase(&other->reserved_name_)); + value_.InternalSwap(&other->value_); + reserved_range_.InternalSwap(&other->reserved_range_); + reserved_name_.InternalSwap(&other->reserved_name_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(options_, other->options_); @@ -6263,8 +6203,8 @@ EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProt _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -6344,7 +6284,7 @@ const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.EnumValueDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.EnumValueDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -6398,9 +6338,9 @@ bool EnumValueDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.EnumValueDescriptorProto.name"); } else { @@ -6464,11 +6404,11 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.EnumValueDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional int32 number = 2; @@ -6507,7 +6447,7 @@ size_t EnumValueDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional .google.protobuf.EnumValueOptions options = 3; @@ -6559,7 +6499,7 @@ void EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->PROTOBUF_NAMESPACE_ID::EnumValueOptions::MergeFrom(from.options()); @@ -6662,8 +6602,8 @@ ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& fro method_(from.method_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -6740,7 +6680,7 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_N // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.ServiceDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.ServiceDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -6753,7 +6693,7 @@ const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_N ptr = ctx->ParseMessage(add_method(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // optional .google.protobuf.ServiceOptions options = 3; @@ -6798,9 +6738,9 @@ bool ServiceDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.ServiceDescriptorProto.name"); } else { @@ -6862,16 +6802,16 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.ServiceDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.MethodDescriptorProto method = 2; - for (auto it = this->method().pointer_begin(), - end = this->method().pointer_end(); it < end; ++it) { + for (auto it = this->method_.pointer_begin(), + end = this->method_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); @@ -6902,14 +6842,10 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.MethodDescriptorProto method = 2; - { - unsigned int count = static_cast(this->method_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->method(static_cast(i))); - } + total_size += 1UL * this->method_size(); + for (const auto& msg : this->method_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -6918,7 +6854,7 @@ size_t ServiceDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional .google.protobuf.ServiceOptions options = 3; @@ -6964,7 +6900,7 @@ void ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { mutable_options()->PROTOBUF_NAMESPACE_ID::ServiceOptions::MergeFrom(from.options()); @@ -6998,7 +6934,7 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&method_)->InternalSwap(CastToBase(&other->method_)); + method_.InternalSwap(&other->method_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(options_, other->options_); @@ -7074,18 +7010,18 @@ MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (from._internal_has_name()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } input_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_input_type()) { - input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.input_type(), + if (from._internal_has_input_type()) { + input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_input_type(), GetArenaNoVirtual()); } output_type_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_output_type()) { - output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.output_type(), + if (from._internal_has_output_type()) { + output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_output_type(), GetArenaNoVirtual()); } if (from.has_options()) { @@ -7179,21 +7115,21 @@ const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::PROTOBUF_NA // optional string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name(), ptr, ctx, "google.protobuf.MethodDescriptorProto.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name(), ptr, ctx, "google.protobuf.MethodDescriptorProto.name"); CHK_(ptr); } else goto handle_unusual; continue; // optional string input_type = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_input_type(), ptr, ctx, "google.protobuf.MethodDescriptorProto.input_type"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_input_type(), ptr, ctx, "google.protobuf.MethodDescriptorProto.input_type"); CHK_(ptr); } else goto handle_unusual; continue; // optional string output_type = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_output_type(), ptr, ctx, "google.protobuf.MethodDescriptorProto.output_type"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_output_type(), ptr, ctx, "google.protobuf.MethodDescriptorProto.output_type"); CHK_(ptr); } else goto handle_unusual; continue; @@ -7255,9 +7191,9 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.name"); } else { @@ -7270,9 +7206,9 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_input_type())); + input, this->_internal_mutable_input_type())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->input_type().data(), static_cast(this->input_type().length()), + this->_internal_input_type().data(), static_cast(this->_internal_input_type().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.input_type"); } else { @@ -7285,9 +7221,9 @@ bool MethodDescriptorProto::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_output_type())); + input, this->_internal_mutable_output_type())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->output_type().data(), static_cast(this->output_type().length()), + this->_internal_output_type().data(), static_cast(this->_internal_output_type().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.MethodDescriptorProto.output_type"); } else { @@ -7364,31 +7300,31 @@ failure: // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // optional string input_type = 2; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->input_type().data(), static_cast(this->input_type().length()), + this->_internal_input_type().data(), static_cast(this->_internal_input_type().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.input_type"); target = stream->WriteStringMaybeAliased( - 2, this->input_type(), target); + 2, this->_internal_input_type(), target); } // optional string output_type = 3; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->output_type().data(), static_cast(this->output_type().length()), + this->_internal_output_type().data(), static_cast(this->_internal_output_type().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.MethodDescriptorProto.output_type"); target = stream->WriteStringMaybeAliased( - 3, this->output_type(), target); + 3, this->_internal_output_type(), target); } // optional .google.protobuf.MethodOptions options = 4; @@ -7433,21 +7369,21 @@ size_t MethodDescriptorProto::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // optional string input_type = 2; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->input_type()); + this->_internal_input_type()); } // optional string output_type = 3; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->output_type()); + this->_internal_output_type()); } // optional .google.protobuf.MethodOptions options = 4; @@ -7502,13 +7438,13 @@ void MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (cached_has_bits & 0x00000002u) { - set_input_type(from.input_type()); + _internal_set_input_type(from._internal_input_type()); } if (cached_has_bits & 0x00000004u) { - set_output_type(from.output_type()); + _internal_set_output_type(from._internal_output_type()); } if (cached_has_bits & 0x00000008u) { mutable_options()->PROTOBUF_NAMESPACE_ID::MethodOptions::MergeFrom(from.options()); @@ -7655,53 +7591,53 @@ FileOptions::FileOptions(const FileOptions& from) _internal_metadata_.MergeFrom(from._internal_metadata_); _extensions_.MergeFrom(from._extensions_); java_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_java_package()) { - java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.java_package(), + if (from._internal_has_java_package()) { + java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_java_package(), GetArenaNoVirtual()); } java_outer_classname_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_java_outer_classname()) { - java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname(), + if (from._internal_has_java_outer_classname()) { + java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_java_outer_classname(), GetArenaNoVirtual()); } go_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_go_package()) { - go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.go_package(), + if (from._internal_has_go_package()) { + go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_go_package(), GetArenaNoVirtual()); } objc_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_objc_class_prefix()) { - objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix(), + if (from._internal_has_objc_class_prefix()) { + objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_objc_class_prefix(), GetArenaNoVirtual()); } csharp_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_csharp_namespace()) { - csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace(), + if (from._internal_has_csharp_namespace()) { + csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_csharp_namespace(), GetArenaNoVirtual()); } swift_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_swift_prefix()) { - swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.swift_prefix(), + if (from._internal_has_swift_prefix()) { + swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_swift_prefix(), GetArenaNoVirtual()); } php_class_prefix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_php_class_prefix()) { - php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.php_class_prefix(), + if (from._internal_has_php_class_prefix()) { + php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_class_prefix(), GetArenaNoVirtual()); } php_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_php_namespace()) { - php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.php_namespace(), + if (from._internal_has_php_namespace()) { + php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_namespace(), GetArenaNoVirtual()); } php_metadata_namespace_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_php_metadata_namespace()) { - php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.php_metadata_namespace(), + if (from._internal_has_php_metadata_namespace()) { + php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_php_metadata_namespace(), GetArenaNoVirtual()); } ruby_package_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_ruby_package()) { - ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.ruby_package(), + if (from._internal_has_ruby_package()) { + ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_ruby_package(), GetArenaNoVirtual()); } ::memcpy(&java_multiple_files_, &from.java_multiple_files_, @@ -7833,14 +7769,14 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional string java_package = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_java_package(), ptr, ctx, "google.protobuf.FileOptions.java_package"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_java_package(), ptr, ctx, "google.protobuf.FileOptions.java_package"); CHK_(ptr); } else goto handle_unusual; continue; // optional string java_outer_classname = 8; case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_java_outer_classname(), ptr, ctx, "google.protobuf.FileOptions.java_outer_classname"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_java_outer_classname(), ptr, ctx, "google.protobuf.FileOptions.java_outer_classname"); CHK_(ptr); } else goto handle_unusual; continue; @@ -7867,7 +7803,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional string go_package = 11; case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_go_package(), ptr, ctx, "google.protobuf.FileOptions.go_package"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_go_package(), ptr, ctx, "google.protobuf.FileOptions.go_package"); CHK_(ptr); } else goto handle_unusual; continue; @@ -7930,35 +7866,35 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional string objc_class_prefix = 36; case 36: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_objc_class_prefix(), ptr, ctx, "google.protobuf.FileOptions.objc_class_prefix"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_objc_class_prefix(), ptr, ctx, "google.protobuf.FileOptions.objc_class_prefix"); CHK_(ptr); } else goto handle_unusual; continue; // optional string csharp_namespace = 37; case 37: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_csharp_namespace(), ptr, ctx, "google.protobuf.FileOptions.csharp_namespace"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_csharp_namespace(), ptr, ctx, "google.protobuf.FileOptions.csharp_namespace"); CHK_(ptr); } else goto handle_unusual; continue; // optional string swift_prefix = 39; case 39: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_swift_prefix(), ptr, ctx, "google.protobuf.FileOptions.swift_prefix"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_swift_prefix(), ptr, ctx, "google.protobuf.FileOptions.swift_prefix"); CHK_(ptr); } else goto handle_unusual; continue; // optional string php_class_prefix = 40; case 40: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_php_class_prefix(), ptr, ctx, "google.protobuf.FileOptions.php_class_prefix"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_php_class_prefix(), ptr, ctx, "google.protobuf.FileOptions.php_class_prefix"); CHK_(ptr); } else goto handle_unusual; continue; // optional string php_namespace = 41; case 41: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_php_namespace(), ptr, ctx, "google.protobuf.FileOptions.php_namespace"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_php_namespace(), ptr, ctx, "google.protobuf.FileOptions.php_namespace"); CHK_(ptr); } else goto handle_unusual; continue; @@ -7973,14 +7909,14 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // optional string php_metadata_namespace = 44; case 44: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 98)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_php_metadata_namespace(), ptr, ctx, "google.protobuf.FileOptions.php_metadata_namespace"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_php_metadata_namespace(), ptr, ctx, "google.protobuf.FileOptions.php_metadata_namespace"); CHK_(ptr); } else goto handle_unusual; continue; // optional string ruby_package = 45; case 45: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 106)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_ruby_package(), ptr, ctx, "google.protobuf.FileOptions.ruby_package"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_ruby_package(), ptr, ctx, "google.protobuf.FileOptions.ruby_package"); CHK_(ptr); } else goto handle_unusual; continue; @@ -7993,7 +7929,7 @@ const char* FileOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -8037,9 +7973,9 @@ bool FileOptions::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_java_package())); + input, this->_internal_mutable_java_package())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_package().data(), static_cast(this->java_package().length()), + this->_internal_java_package().data(), static_cast(this->_internal_java_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.java_package"); } else { @@ -8052,9 +7988,9 @@ bool FileOptions::MergePartialFromCodedStream( case 8: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (66 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_java_outer_classname())); + input, this->_internal_mutable_java_outer_classname())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_outer_classname().data(), static_cast(this->java_outer_classname().length()), + this->_internal_java_outer_classname().data(), static_cast(this->_internal_java_outer_classname().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.java_outer_classname"); } else { @@ -8099,9 +8035,9 @@ bool FileOptions::MergePartialFromCodedStream( case 11: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (90 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_go_package())); + input, this->_internal_mutable_go_package())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->go_package().data(), static_cast(this->go_package().length()), + this->_internal_go_package().data(), static_cast(this->_internal_go_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.go_package"); } else { @@ -8205,9 +8141,9 @@ bool FileOptions::MergePartialFromCodedStream( case 36: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (290 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_objc_class_prefix())); + input, this->_internal_mutable_objc_class_prefix())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->objc_class_prefix().data(), static_cast(this->objc_class_prefix().length()), + this->_internal_objc_class_prefix().data(), static_cast(this->_internal_objc_class_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.objc_class_prefix"); } else { @@ -8220,9 +8156,9 @@ bool FileOptions::MergePartialFromCodedStream( case 37: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (298 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_csharp_namespace())); + input, this->_internal_mutable_csharp_namespace())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_namespace().data(), static_cast(this->csharp_namespace().length()), + this->_internal_csharp_namespace().data(), static_cast(this->_internal_csharp_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.csharp_namespace"); } else { @@ -8235,9 +8171,9 @@ bool FileOptions::MergePartialFromCodedStream( case 39: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (314 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_swift_prefix())); + input, this->_internal_mutable_swift_prefix())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->swift_prefix().data(), static_cast(this->swift_prefix().length()), + this->_internal_swift_prefix().data(), static_cast(this->_internal_swift_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.swift_prefix"); } else { @@ -8250,9 +8186,9 @@ bool FileOptions::MergePartialFromCodedStream( case 40: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (322 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_php_class_prefix())); + input, this->_internal_mutable_php_class_prefix())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_class_prefix().data(), static_cast(this->php_class_prefix().length()), + this->_internal_php_class_prefix().data(), static_cast(this->_internal_php_class_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.php_class_prefix"); } else { @@ -8265,9 +8201,9 @@ bool FileOptions::MergePartialFromCodedStream( case 41: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (330 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_php_namespace())); + input, this->_internal_mutable_php_namespace())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_namespace().data(), static_cast(this->php_namespace().length()), + this->_internal_php_namespace().data(), static_cast(this->_internal_php_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.php_namespace"); } else { @@ -8293,9 +8229,9 @@ bool FileOptions::MergePartialFromCodedStream( case 44: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (354 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_php_metadata_namespace())); + input, this->_internal_mutable_php_metadata_namespace())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_metadata_namespace().data(), static_cast(this->php_metadata_namespace().length()), + this->_internal_php_metadata_namespace().data(), static_cast(this->_internal_php_metadata_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.php_metadata_namespace"); } else { @@ -8308,9 +8244,9 @@ bool FileOptions::MergePartialFromCodedStream( case 45: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (362 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_ruby_package())); + input, this->_internal_mutable_ruby_package())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->ruby_package().data(), static_cast(this->ruby_package().length()), + this->_internal_ruby_package().data(), static_cast(this->_internal_ruby_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.FileOptions.ruby_package"); } else { @@ -8367,21 +8303,21 @@ failure: // optional string java_package = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_package().data(), static_cast(this->java_package().length()), + this->_internal_java_package().data(), static_cast(this->_internal_java_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_package"); target = stream->WriteStringMaybeAliased( - 1, this->java_package(), target); + 1, this->_internal_java_package(), target); } // optional string java_outer_classname = 8; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->java_outer_classname().data(), static_cast(this->java_outer_classname().length()), + this->_internal_java_outer_classname().data(), static_cast(this->_internal_java_outer_classname().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.java_outer_classname"); target = stream->WriteStringMaybeAliased( - 8, this->java_outer_classname(), target); + 8, this->_internal_java_outer_classname(), target); } // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; @@ -8400,11 +8336,11 @@ failure: // optional string go_package = 11; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->go_package().data(), static_cast(this->go_package().length()), + this->_internal_go_package().data(), static_cast(this->_internal_go_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.go_package"); target = stream->WriteStringMaybeAliased( - 11, this->go_package(), target); + 11, this->_internal_go_package(), target); } // optional bool cc_generic_services = 16 [default = false]; @@ -8452,51 +8388,51 @@ failure: // optional string objc_class_prefix = 36; if (cached_has_bits & 0x00000008u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->objc_class_prefix().data(), static_cast(this->objc_class_prefix().length()), + this->_internal_objc_class_prefix().data(), static_cast(this->_internal_objc_class_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.objc_class_prefix"); target = stream->WriteStringMaybeAliased( - 36, this->objc_class_prefix(), target); + 36, this->_internal_objc_class_prefix(), target); } // optional string csharp_namespace = 37; if (cached_has_bits & 0x00000010u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->csharp_namespace().data(), static_cast(this->csharp_namespace().length()), + this->_internal_csharp_namespace().data(), static_cast(this->_internal_csharp_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.csharp_namespace"); target = stream->WriteStringMaybeAliased( - 37, this->csharp_namespace(), target); + 37, this->_internal_csharp_namespace(), target); } // optional string swift_prefix = 39; if (cached_has_bits & 0x00000020u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->swift_prefix().data(), static_cast(this->swift_prefix().length()), + this->_internal_swift_prefix().data(), static_cast(this->_internal_swift_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.swift_prefix"); target = stream->WriteStringMaybeAliased( - 39, this->swift_prefix(), target); + 39, this->_internal_swift_prefix(), target); } // optional string php_class_prefix = 40; if (cached_has_bits & 0x00000040u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_class_prefix().data(), static_cast(this->php_class_prefix().length()), + this->_internal_php_class_prefix().data(), static_cast(this->_internal_php_class_prefix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_class_prefix"); target = stream->WriteStringMaybeAliased( - 40, this->php_class_prefix(), target); + 40, this->_internal_php_class_prefix(), target); } // optional string php_namespace = 41; if (cached_has_bits & 0x00000080u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_namespace().data(), static_cast(this->php_namespace().length()), + this->_internal_php_namespace().data(), static_cast(this->_internal_php_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_namespace"); target = stream->WriteStringMaybeAliased( - 41, this->php_namespace(), target); + 41, this->_internal_php_namespace(), target); } // optional bool php_generic_services = 42 [default = false]; @@ -8508,26 +8444,26 @@ failure: // optional string php_metadata_namespace = 44; if (cached_has_bits & 0x00000100u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->php_metadata_namespace().data(), static_cast(this->php_metadata_namespace().length()), + this->_internal_php_metadata_namespace().data(), static_cast(this->_internal_php_metadata_namespace().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.php_metadata_namespace"); target = stream->WriteStringMaybeAliased( - 44, this->php_metadata_namespace(), target); + 44, this->_internal_php_metadata_namespace(), target); } // optional string ruby_package = 45; if (cached_has_bits & 0x00000200u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->ruby_package().data(), static_cast(this->ruby_package().length()), + this->_internal_ruby_package().data(), static_cast(this->_internal_ruby_package().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.FileOptions.ruby_package"); target = stream->WriteStringMaybeAliased( - 45, this->ruby_package(), target); + 45, this->_internal_ruby_package(), target); } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -8556,14 +8492,10 @@ size_t FileOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -8572,56 +8504,56 @@ size_t FileOptions::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->java_package()); + this->_internal_java_package()); } // optional string java_outer_classname = 8; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->java_outer_classname()); + this->_internal_java_outer_classname()); } // optional string go_package = 11; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->go_package()); + this->_internal_go_package()); } // optional string objc_class_prefix = 36; if (cached_has_bits & 0x00000008u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->objc_class_prefix()); + this->_internal_objc_class_prefix()); } // optional string csharp_namespace = 37; if (cached_has_bits & 0x00000010u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->csharp_namespace()); + this->_internal_csharp_namespace()); } // optional string swift_prefix = 39; if (cached_has_bits & 0x00000020u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->swift_prefix()); + this->_internal_swift_prefix()); } // optional string php_class_prefix = 40; if (cached_has_bits & 0x00000040u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->php_class_prefix()); + this->_internal_php_class_prefix()); } // optional string php_namespace = 41; if (cached_has_bits & 0x00000080u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->php_namespace()); + this->_internal_php_namespace()); } } @@ -8630,14 +8562,14 @@ size_t FileOptions::ByteSizeLong() const { if (cached_has_bits & 0x00000100u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->php_metadata_namespace()); + this->_internal_php_metadata_namespace()); } // optional string ruby_package = 45; if (cached_has_bits & 0x00000200u) { total_size += 2 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->ruby_package()); + this->_internal_ruby_package()); } // optional bool java_multiple_files = 10 [default = false]; @@ -8730,36 +8662,36 @@ void FileOptions::MergeFrom(const FileOptions& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { - set_java_package(from.java_package()); + _internal_set_java_package(from._internal_java_package()); } if (cached_has_bits & 0x00000002u) { - set_java_outer_classname(from.java_outer_classname()); + _internal_set_java_outer_classname(from._internal_java_outer_classname()); } if (cached_has_bits & 0x00000004u) { - set_go_package(from.go_package()); + _internal_set_go_package(from._internal_go_package()); } if (cached_has_bits & 0x00000008u) { - set_objc_class_prefix(from.objc_class_prefix()); + _internal_set_objc_class_prefix(from._internal_objc_class_prefix()); } if (cached_has_bits & 0x00000010u) { - set_csharp_namespace(from.csharp_namespace()); + _internal_set_csharp_namespace(from._internal_csharp_namespace()); } if (cached_has_bits & 0x00000020u) { - set_swift_prefix(from.swift_prefix()); + _internal_set_swift_prefix(from._internal_swift_prefix()); } if (cached_has_bits & 0x00000040u) { - set_php_class_prefix(from.php_class_prefix()); + _internal_set_php_class_prefix(from._internal_php_class_prefix()); } if (cached_has_bits & 0x00000080u) { - set_php_namespace(from.php_namespace()); + _internal_set_php_namespace(from._internal_php_namespace()); } } if (cached_has_bits & 0x0000ff00u) { if (cached_has_bits & 0x00000100u) { - set_php_metadata_namespace(from.php_metadata_namespace()); + _internal_set_php_metadata_namespace(from._internal_php_metadata_namespace()); } if (cached_has_bits & 0x00000200u) { - set_ruby_package(from.ruby_package()); + _internal_set_ruby_package(from._internal_ruby_package()); } if (cached_has_bits & 0x00000400u) { java_multiple_files_ = from.java_multiple_files_; @@ -8826,7 +8758,7 @@ void FileOptions::InternalSwap(FileOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); java_package_.Swap(&other->java_package_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); java_outer_classname_.Swap(&other->java_outer_classname_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -9009,7 +8941,7 @@ const char* MessageOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -9171,8 +9103,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -9201,14 +9133,10 @@ size_t MessageOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -9313,7 +9241,7 @@ void MessageOptions::InternalSwap(MessageOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(message_set_wire_format_, other->message_set_wire_format_); swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_); swap(deprecated_, other->deprecated_); @@ -9503,7 +9431,7 @@ const char* FieldOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -9717,8 +9645,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -9747,14 +9675,10 @@ size_t FieldOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -9877,7 +9801,7 @@ void FieldOptions::InternalSwap(FieldOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(ctype_, other->ctype_); swap(packed_, other->packed_); swap(lazy_, other->lazy_); @@ -9982,7 +9906,7 @@ const char* OneofOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_I ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -10066,8 +9990,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -10096,14 +10020,10 @@ size_t OneofOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -10169,7 +10089,7 @@ void OneofOptions::InternalSwap(OneofOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); } ::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const { @@ -10300,7 +10220,7 @@ const char* EnumOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -10424,8 +10344,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -10454,14 +10374,10 @@ size_t EnumOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -10550,7 +10466,7 @@ void EnumOptions::InternalSwap(EnumOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(allow_alias_, other->allow_alias_); swap(deprecated_, other->deprecated_); } @@ -10666,7 +10582,7 @@ const char* EnumValueOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPA ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -10771,8 +10687,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -10801,14 +10717,10 @@ size_t EnumValueOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // optional bool deprecated = 1 [default = false]; @@ -10883,7 +10795,7 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(deprecated_, other->deprecated_); } @@ -10998,7 +10910,7 @@ const char* ServiceOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -11103,8 +11015,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -11133,14 +11045,10 @@ size_t ServiceOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // optional bool deprecated = 33 [default = false]; @@ -11215,7 +11123,7 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(deprecated_, other->deprecated_); } @@ -11354,7 +11262,7 @@ const char* MethodOptions::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ ptr = ctx->ParseMessage(add_uninterpreted_option(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint16>(ptr) == 16058); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<7994>(ptr)); } else goto handle_unusual; continue; default: { @@ -11485,8 +11393,8 @@ failure: } // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - for (auto it = this->uninterpreted_option().pointer_begin(), - end = this->uninterpreted_option().pointer_end(); it < end; ++it) { + for (auto it = this->uninterpreted_option_.pointer_begin(), + end = this->uninterpreted_option_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(999, **it, target, stream); @@ -11515,14 +11423,10 @@ size_t MethodOptions::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; - { - unsigned int count = static_cast(this->uninterpreted_option_size()); - total_size += 2UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->uninterpreted_option(static_cast(i))); - } + total_size += 2UL * this->uninterpreted_option_size(); + for (const auto& msg : this->uninterpreted_option_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -11612,7 +11516,7 @@ void MethodOptions::InternalSwap(MethodOptions* other) { _extensions_.Swap(&other->_extensions_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&uninterpreted_option_)->InternalSwap(CastToBase(&other->uninterpreted_option_)); + uninterpreted_option_.InternalSwap(&other->uninterpreted_option_); swap(deprecated_, other->deprecated_); swap(idempotency_level_, other->idempotency_level_); } @@ -11655,8 +11559,8 @@ UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOp _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_part_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_name_part()) { - name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name_part(), + if (from._internal_has_name_part()) { + name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name_part(), GetArenaNoVirtual()); } is_extension_ = from.is_extension_; @@ -11722,7 +11626,7 @@ const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::PROT // required string name_part = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_name_part(), ptr, ctx, "google.protobuf.UninterpretedOption.NamePart.name_part"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_name_part(), ptr, ctx, "google.protobuf.UninterpretedOption.NamePart.name_part"); CHK_(ptr); } else goto handle_unusual; continue; @@ -11769,9 +11673,9 @@ bool UninterpretedOption_NamePart::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name_part())); + input, this->_internal_mutable_name_part())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name_part().data(), static_cast(this->name_part().length()), + this->_internal_name_part().data(), static_cast(this->_internal_name_part().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.NamePart.name_part"); } else { @@ -11824,11 +11728,11 @@ failure: // required string name_part = 1; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->name_part().data(), static_cast(this->name_part().length()), + this->_internal_name_part().data(), static_cast(this->_internal_name_part().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.NamePart.name_part"); target = stream->WriteStringMaybeAliased( - 1, this->name_part(), target); + 1, this->_internal_name_part(), target); } // required bool is_extension = 2; @@ -11853,7 +11757,7 @@ size_t UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const { // required string name_part = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name_part()); + this->_internal_name_part()); } if (has_is_extension()) { @@ -11871,7 +11775,7 @@ size_t UninterpretedOption_NamePart::ByteSizeLong() const { // required string name_part = 1; total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name_part()); + this->_internal_name_part()); // required bool is_extension = 2; total_size += 1 + 1; @@ -11917,7 +11821,7 @@ void UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_name_part(from.name_part()); + _internal_set_name_part(from._internal_name_part()); } if (cached_has_bits & 0x00000002u) { is_extension_ = from.is_extension_; @@ -12006,18 +11910,18 @@ UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) name_(from.name_) { _internal_metadata_.MergeFrom(from._internal_metadata_); identifier_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_identifier_value()) { - identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.identifier_value(), + if (from._internal_has_identifier_value()) { + identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_identifier_value(), GetArenaNoVirtual()); } string_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_string_value()) { - string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.string_value(), + if (from._internal_has_string_value()) { + string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_string_value(), GetArenaNoVirtual()); } aggregate_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_aggregate_value()) { - aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.aggregate_value(), + if (from._internal_has_aggregate_value()) { + aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_aggregate_value(), GetArenaNoVirtual()); } ::memcpy(&positive_int_value_, &from.positive_int_value_, @@ -12110,13 +12014,13 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME ptr = ctx->ParseMessage(add_name(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // optional string identifier_value = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_identifier_value(), ptr, ctx, "google.protobuf.UninterpretedOption.identifier_value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_identifier_value(), ptr, ctx, "google.protobuf.UninterpretedOption.identifier_value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -12147,14 +12051,14 @@ const char* UninterpretedOption::_InternalParse(const char* ptr, ::PROTOBUF_NAME // optional bytes string_value = 7; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(mutable_string_value(), ptr, ctx); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(_internal_mutable_string_value(), ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; // optional string aggregate_value = 8; case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_aggregate_value(), ptr, ctx, "google.protobuf.UninterpretedOption.aggregate_value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_aggregate_value(), ptr, ctx, "google.protobuf.UninterpretedOption.aggregate_value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -12204,9 +12108,9 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_identifier_value())); + input, this->_internal_mutable_identifier_value())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->identifier_value().data(), static_cast(this->identifier_value().length()), + this->_internal_identifier_value().data(), static_cast(this->_internal_identifier_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.identifier_value"); } else { @@ -12258,7 +12162,7 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 7: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (58 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadBytes( - input, this->mutable_string_value())); + input, this->_internal_mutable_string_value())); } else { goto handle_unusual; } @@ -12269,9 +12173,9 @@ bool UninterpretedOption::MergePartialFromCodedStream( case 8: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (66 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_aggregate_value())); + input, this->_internal_mutable_aggregate_value())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->aggregate_value().data(), static_cast(this->aggregate_value().length()), + this->_internal_aggregate_value().data(), static_cast(this->_internal_aggregate_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.UninterpretedOption.aggregate_value"); } else { @@ -12308,8 +12212,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - for (auto it = this->name().pointer_begin(), - end = this->name().pointer_end(); it < end; ++it) { + for (auto it = this->name_.pointer_begin(), + end = this->name_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); @@ -12319,11 +12223,11 @@ failure: // optional string identifier_value = 3; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->identifier_value().data(), static_cast(this->identifier_value().length()), + this->_internal_identifier_value().data(), static_cast(this->_internal_identifier_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.identifier_value"); target = stream->WriteStringMaybeAliased( - 3, this->identifier_value(), target); + 3, this->_internal_identifier_value(), target); } // optional uint64 positive_int_value = 4; @@ -12347,17 +12251,17 @@ failure: // optional bytes string_value = 7; if (cached_has_bits & 0x00000002u) { target = stream->WriteBytesMaybeAliased( - 7, this->string_value(), target); + 7, this->_internal_string_value(), target); } // optional string aggregate_value = 8; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->aggregate_value().data(), static_cast(this->aggregate_value().length()), + this->_internal_aggregate_value().data(), static_cast(this->_internal_aggregate_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.UninterpretedOption.aggregate_value"); target = stream->WriteStringMaybeAliased( - 8, this->aggregate_value(), target); + 8, this->_internal_aggregate_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -12377,14 +12281,10 @@ size_t UninterpretedOption::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; - { - unsigned int count = static_cast(this->name_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->name(static_cast(i))); - } + total_size += 1UL * this->name_size(); + for (const auto& msg : this->name_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } cached_has_bits = _has_bits_[0]; @@ -12393,21 +12293,21 @@ size_t UninterpretedOption::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->identifier_value()); + this->_internal_identifier_value()); } // optional bytes string_value = 7; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->string_value()); + this->_internal_string_value()); } // optional string aggregate_value = 8; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->aggregate_value()); + this->_internal_aggregate_value()); } // optional uint64 positive_int_value = 4; @@ -12465,13 +12365,13 @@ void UninterpretedOption::MergeFrom(const UninterpretedOption& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000003fu) { if (cached_has_bits & 0x00000001u) { - set_identifier_value(from.identifier_value()); + _internal_set_identifier_value(from._internal_identifier_value()); } if (cached_has_bits & 0x00000002u) { - set_string_value(from.string_value()); + _internal_set_string_value(from._internal_string_value()); } if (cached_has_bits & 0x00000004u) { - set_aggregate_value(from.aggregate_value()); + _internal_set_aggregate_value(from._internal_aggregate_value()); } if (cached_has_bits & 0x00000008u) { positive_int_value_ = from.positive_int_value_; @@ -12509,7 +12409,7 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&name_)->InternalSwap(CastToBase(&other->name_)); + name_.InternalSwap(&other->name_); identifier_value_.Swap(&other->identifier_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); string_value_.Swap(&other->string_value_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -12565,13 +12465,13 @@ SourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& leading_detached_comments_(from.leading_detached_comments_) { _internal_metadata_.MergeFrom(from._internal_metadata_); leading_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_leading_comments()) { - leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.leading_comments(), + if (from._internal_has_leading_comments()) { + leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_leading_comments(), GetArenaNoVirtual()); } trailing_comments_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_trailing_comments()) { - trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.trailing_comments(), + if (from._internal_has_trailing_comments()) { + trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_trailing_comments(), GetArenaNoVirtual()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location) @@ -12664,14 +12564,14 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ // optional string leading_comments = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_leading_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.leading_comments"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_leading_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.leading_comments"); CHK_(ptr); } else goto handle_unusual; continue; // optional string trailing_comments = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_trailing_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_trailing_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); CHK_(ptr); } else goto handle_unusual; continue; @@ -12681,10 +12581,10 @@ const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::PROTOBUF_ ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(add_leading_detached_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_add_leading_detached_comments(), ptr, ctx, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 50); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } else goto handle_unusual; continue; default: { @@ -12754,9 +12654,9 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_leading_comments())); + input, this->_internal_mutable_leading_comments())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_comments().data(), static_cast(this->leading_comments().length()), + this->_internal_leading_comments().data(), static_cast(this->_internal_leading_comments().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.leading_comments"); } else { @@ -12769,9 +12669,9 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (34 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_trailing_comments())); + input, this->_internal_mutable_trailing_comments())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->trailing_comments().data(), static_cast(this->trailing_comments().length()), + this->_internal_trailing_comments().data(), static_cast(this->_internal_trailing_comments().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); } else { @@ -12784,10 +12684,10 @@ bool SourceCodeInfo_Location::MergePartialFromCodedStream( case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (50 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_leading_detached_comments())); + input, this->_internal_add_leading_detached_comments())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_detached_comments(this->leading_detached_comments_size() - 1).data(), - static_cast(this->leading_detached_comments(this->leading_detached_comments_size() - 1).length()), + leading_detached_comments_.Get(leading_detached_comments_.size() - 1).data(), + static_cast(leading_detached_comments_.Get(leading_detached_comments_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"); } else { @@ -12845,26 +12745,26 @@ failure: // optional string leading_comments = 3; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->leading_comments().data(), static_cast(this->leading_comments().length()), + this->_internal_leading_comments().data(), static_cast(this->_internal_leading_comments().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.leading_comments"); target = stream->WriteStringMaybeAliased( - 3, this->leading_comments(), target); + 3, this->_internal_leading_comments(), target); } // optional string trailing_comments = 4; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->trailing_comments().data(), static_cast(this->trailing_comments().length()), + this->_internal_trailing_comments().data(), static_cast(this->_internal_trailing_comments().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.SourceCodeInfo.Location.trailing_comments"); target = stream->WriteStringMaybeAliased( - 4, this->trailing_comments(), target); + 4, this->_internal_trailing_comments(), target); } // repeated string leading_detached_comments = 6; - for (auto it = this->leading_detached_comments().pointer_begin(), - end = this->leading_detached_comments().pointer_end(); it < end; ++it) { + for (auto it = leading_detached_comments_.pointer_begin(), + end = leading_detached_comments_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( s.data(), static_cast(s.length()), @@ -12921,10 +12821,10 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { // repeated string leading_detached_comments = 6; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->leading_detached_comments_size()); - for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(leading_detached_comments_.size()); + for (int i = 0, n = leading_detached_comments_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->leading_detached_comments(i)); + leading_detached_comments_.Get(i)); } cached_has_bits = _has_bits_[0]; @@ -12933,14 +12833,14 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->leading_comments()); + this->_internal_leading_comments()); } // optional string trailing_comments = 4; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->trailing_comments()); + this->_internal_trailing_comments()); } } @@ -12981,10 +12881,10 @@ void SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) { cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - set_leading_comments(from.leading_comments()); + _internal_set_leading_comments(from._internal_leading_comments()); } if (cached_has_bits & 0x00000002u) { - set_trailing_comments(from.trailing_comments()); + _internal_set_trailing_comments(from._internal_trailing_comments()); } } } @@ -13013,7 +12913,7 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { swap(_has_bits_[0], other->_has_bits_[0]); path_.InternalSwap(&other->path_); span_.InternalSwap(&other->span_); - leading_detached_comments_.InternalSwap(CastToBase(&other->leading_detached_comments_)); + leading_detached_comments_.InternalSwap(&other->leading_detached_comments_); leading_comments_.Swap(&other->leading_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); trailing_comments_.Swap(&other->trailing_comments_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -13113,7 +13013,7 @@ const char* SourceCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE ptr = ctx->ParseMessage(add_location(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -13185,8 +13085,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - for (auto it = this->location().pointer_begin(), - end = this->location().pointer_end(); it < end; ++it) { + for (auto it = this->location_.pointer_begin(), + end = this->location_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(1, **it, target, stream); @@ -13209,14 +13109,10 @@ size_t SourceCodeInfo::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.SourceCodeInfo.Location location = 1; - { - unsigned int count = static_cast(this->location_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->location(static_cast(i))); - } + total_size += 1UL * this->location_size(); + for (const auto& msg : this->location_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -13275,7 +13171,7 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&location_)->InternalSwap(CastToBase(&other->location_)); + location_.InternalSwap(&other->location_); } ::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const { @@ -13321,8 +13217,8 @@ GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeIn path_(from.path_) { _internal_metadata_.MergeFrom(from._internal_metadata_); source_file_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (from.has_source_file()) { - source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.source_file(), + if (from._internal_has_source_file()) { + source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_source_file(), GetArenaNoVirtual()); } ::memcpy(&begin_, &from.begin_, @@ -13407,7 +13303,7 @@ const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::PROT // optional string source_file = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_source_file(), ptr, ctx, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(_internal_mutable_source_file(), ptr, ctx, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); CHK_(ptr); } else goto handle_unusual; continue; @@ -13478,9 +13374,9 @@ bool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream( case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_source_file())); + input, this->_internal_mutable_source_file())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->source_file().data(), static_cast(this->source_file().length()), + this->_internal_source_file().data(), static_cast(this->_internal_source_file().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); } else { @@ -13555,11 +13451,11 @@ failure: // optional string source_file = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( - this->source_file().data(), static_cast(this->source_file().length()), + this->_internal_source_file().data(), static_cast(this->_internal_source_file().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "google.protobuf.GeneratedCodeInfo.Annotation.source_file"); target = stream->WriteStringMaybeAliased( - 2, this->source_file(), target); + 2, this->_internal_source_file(), target); } // optional int32 begin = 3; @@ -13611,7 +13507,7 @@ size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const { if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->source_file()); + this->_internal_source_file()); } // optional int32 begin = 3; @@ -13664,7 +13560,7 @@ void GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { - set_source_file(from.source_file()); + _internal_set_source_file(from._internal_source_file()); } if (cached_has_bits & 0x00000002u) { begin_ = from.begin_; @@ -13798,7 +13694,7 @@ const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::PROTOBUF_NAMESP ptr = ctx->ParseMessage(add_annotation(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -13870,8 +13766,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - for (auto it = this->annotation().pointer_begin(), - end = this->annotation().pointer_end(); it < end; ++it) { + for (auto it = this->annotation_.pointer_begin(), + end = this->annotation_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(1, **it, target, stream); @@ -13894,14 +13790,10 @@ size_t GeneratedCodeInfo::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; - { - unsigned int count = static_cast(this->annotation_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->annotation(static_cast(i))); - } + total_size += 1UL * this->annotation_size(); + for (const auto& msg : this->annotation_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -13960,7 +13852,7 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - CastToBase(&annotation_)->InternalSwap(CastToBase(&other->annotation_)); + annotation_.InternalSwap(&other->annotation_); } ::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const { diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index d2601e3b58..cebbe9e0cd 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -663,6 +663,9 @@ class PROTOBUF_EXPORT FileDescriptorProto : void add_dependency(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& dependency() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_dependency(); + private: + std::string* _internal_add_dependency(); + public: // repeated .google.protobuf.DescriptorProto message_type = 4; int message_type_size() const; @@ -732,6 +735,9 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -750,9 +756,17 @@ class PROTOBUF_EXPORT FileDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional string package = 2; bool has_package() const; + private: + bool _internal_has_package() const; + public: void clear_package(); const std::string& package() const; void set_package(const std::string& value); @@ -771,9 +785,17 @@ class PROTOBUF_EXPORT FileDescriptorProto : " future release.") void unsafe_arena_set_allocated_package( std::string* package); + private: + const std::string& _internal_package() const; + void _internal_set_package(const std::string& value); + std::string* _internal_mutable_package(); + public: // optional string syntax = 12; bool has_syntax() const; + private: + bool _internal_has_syntax() const; + public: void clear_syntax(); const std::string& syntax() const; void set_syntax(const std::string& value); @@ -792,9 +814,17 @@ class PROTOBUF_EXPORT FileDescriptorProto : " future release.") void unsafe_arena_set_allocated_syntax( std::string* syntax); + private: + const std::string& _internal_syntax() const; + void _internal_set_syntax(const std::string& value); + std::string* _internal_mutable_syntax(); + public: // optional .google.protobuf.FileOptions options = 8; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::FileOptions& options() const; PROTOBUF_NAMESPACE_ID::FileOptions* release_options(); @@ -806,6 +836,9 @@ class PROTOBUF_EXPORT FileDescriptorProto : // optional .google.protobuf.SourceCodeInfo source_code_info = 9; bool has_source_code_info() const; + private: + bool _internal_has_source_code_info() const; + public: void clear_source_code_info(); const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& source_code_info() const; PROTOBUF_NAMESPACE_ID::SourceCodeInfo* release_source_code_info(); @@ -985,6 +1018,9 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : }; // optional .google.protobuf.ExtensionRangeOptions options = 3; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& options() const; PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* release_options(); @@ -996,12 +1032,18 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange : // optional int32 start = 1; bool has_start() const; + private: + bool _internal_has_start() const; + public: void clear_start(); ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; + private: + bool _internal_has_end() const; + public: void clear_end(); ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -1166,12 +1208,18 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange : }; // optional int32 start = 1; bool has_start() const; + private: + bool _internal_has_start() const; + public: void clear_start(); ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; + private: + bool _internal_has_end() const; + public: void clear_end(); ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -1437,9 +1485,15 @@ class PROTOBUF_EXPORT DescriptorProto : void add_reserved_name(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& reserved_name() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_reserved_name(); + private: + std::string* _internal_add_reserved_name(); + public: // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -1458,9 +1512,17 @@ class PROTOBUF_EXPORT DescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional .google.protobuf.MessageOptions options = 7; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::MessageOptions& options() const; PROTOBUF_NAMESPACE_ID::MessageOptions* release_options(); @@ -1908,6 +1970,9 @@ class PROTOBUF_EXPORT FieldDescriptorProto : }; // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -1926,9 +1991,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional string extendee = 2; bool has_extendee() const; + private: + bool _internal_has_extendee() const; + public: void clear_extendee(); const std::string& extendee() const; void set_extendee(const std::string& value); @@ -1947,9 +2020,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : " future release.") void unsafe_arena_set_allocated_extendee( std::string* extendee); + private: + const std::string& _internal_extendee() const; + void _internal_set_extendee(const std::string& value); + std::string* _internal_mutable_extendee(); + public: // optional string type_name = 6; bool has_type_name() const; + private: + bool _internal_has_type_name() const; + public: void clear_type_name(); const std::string& type_name() const; void set_type_name(const std::string& value); @@ -1968,9 +2049,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : " future release.") void unsafe_arena_set_allocated_type_name( std::string* type_name); + private: + const std::string& _internal_type_name() const; + void _internal_set_type_name(const std::string& value); + std::string* _internal_mutable_type_name(); + public: // optional string default_value = 7; bool has_default_value() const; + private: + bool _internal_has_default_value() const; + public: void clear_default_value(); const std::string& default_value() const; void set_default_value(const std::string& value); @@ -1989,9 +2078,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : " future release.") void unsafe_arena_set_allocated_default_value( std::string* default_value); + private: + const std::string& _internal_default_value() const; + void _internal_set_default_value(const std::string& value); + std::string* _internal_mutable_default_value(); + public: // optional string json_name = 10; bool has_json_name() const; + private: + bool _internal_has_json_name() const; + public: void clear_json_name(); const std::string& json_name() const; void set_json_name(const std::string& value); @@ -2010,9 +2107,17 @@ class PROTOBUF_EXPORT FieldDescriptorProto : " future release.") void unsafe_arena_set_allocated_json_name( std::string* json_name); + private: + const std::string& _internal_json_name() const; + void _internal_set_json_name(const std::string& value); + std::string* _internal_mutable_json_name(); + public: // optional .google.protobuf.FieldOptions options = 8; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::FieldOptions& options() const; PROTOBUF_NAMESPACE_ID::FieldOptions* release_options(); @@ -2024,24 +2129,36 @@ class PROTOBUF_EXPORT FieldDescriptorProto : // optional int32 number = 3; bool has_number() const; + private: + bool _internal_has_number() const; + public: void clear_number(); ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 oneof_index = 9; bool has_oneof_index() const; + private: + bool _internal_has_oneof_index() const; + public: void clear_oneof_index(); ::PROTOBUF_NAMESPACE_ID::int32 oneof_index() const; void set_oneof_index(::PROTOBUF_NAMESPACE_ID::int32 value); // optional .google.protobuf.FieldDescriptorProto.Label label = 4; bool has_label() const; + private: + bool _internal_has_label() const; + public: void clear_label(); PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label label() const; void set_label(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Label value); // optional .google.protobuf.FieldDescriptorProto.Type type = 5; bool has_type() const; + private: + bool _internal_has_type() const; + public: void clear_type(); PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type type() const; void set_type(PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type value); @@ -2213,6 +2330,9 @@ class PROTOBUF_EXPORT OneofDescriptorProto : }; // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -2231,9 +2351,17 @@ class PROTOBUF_EXPORT OneofDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional .google.protobuf.OneofOptions options = 2; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::OneofOptions& options() const; PROTOBUF_NAMESPACE_ID::OneofOptions* release_options(); @@ -2402,12 +2530,18 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange : }; // optional int32 start = 1; bool has_start() const; + private: + bool _internal_has_start() const; + public: void clear_start(); ::PROTOBUF_NAMESPACE_ID::int32 start() const; void set_start(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 2; bool has_end() const; + private: + bool _internal_has_end() const; + public: void clear_end(); ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -2612,9 +2746,15 @@ class PROTOBUF_EXPORT EnumDescriptorProto : void add_reserved_name(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& reserved_name() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_reserved_name(); + private: + std::string* _internal_add_reserved_name(); + public: // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -2633,9 +2773,17 @@ class PROTOBUF_EXPORT EnumDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional .google.protobuf.EnumOptions options = 3; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::EnumOptions& options() const; PROTOBUF_NAMESPACE_ID::EnumOptions* release_options(); @@ -2808,6 +2956,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : }; // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -2826,9 +2977,17 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional .google.protobuf.EnumValueOptions options = 3; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::EnumValueOptions& options() const; PROTOBUF_NAMESPACE_ID::EnumValueOptions* release_options(); @@ -2840,6 +2999,9 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto : // optional int32 number = 2; bool has_number() const; + private: + bool _internal_has_number() const; + public: void clear_number(); ::PROTOBUF_NAMESPACE_ID::int32 number() const; void set_number(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -3016,6 +3178,9 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -3034,9 +3199,17 @@ class PROTOBUF_EXPORT ServiceDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional .google.protobuf.ServiceOptions options = 3; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::ServiceOptions& options() const; PROTOBUF_NAMESPACE_ID::ServiceOptions* release_options(); @@ -3210,6 +3383,9 @@ class PROTOBUF_EXPORT MethodDescriptorProto : }; // optional string name = 1; bool has_name() const; + private: + bool _internal_has_name() const; + public: void clear_name(); const std::string& name() const; void set_name(const std::string& value); @@ -3228,9 +3404,17 @@ class PROTOBUF_EXPORT MethodDescriptorProto : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // optional string input_type = 2; bool has_input_type() const; + private: + bool _internal_has_input_type() const; + public: void clear_input_type(); const std::string& input_type() const; void set_input_type(const std::string& value); @@ -3249,9 +3433,17 @@ class PROTOBUF_EXPORT MethodDescriptorProto : " future release.") void unsafe_arena_set_allocated_input_type( std::string* input_type); + private: + const std::string& _internal_input_type() const; + void _internal_set_input_type(const std::string& value); + std::string* _internal_mutable_input_type(); + public: // optional string output_type = 3; bool has_output_type() const; + private: + bool _internal_has_output_type() const; + public: void clear_output_type(); const std::string& output_type() const; void set_output_type(const std::string& value); @@ -3270,9 +3462,17 @@ class PROTOBUF_EXPORT MethodDescriptorProto : " future release.") void unsafe_arena_set_allocated_output_type( std::string* output_type); + private: + const std::string& _internal_output_type() const; + void _internal_set_output_type(const std::string& value); + std::string* _internal_mutable_output_type(); + public: // optional .google.protobuf.MethodOptions options = 4; bool has_options() const; + private: + bool _internal_has_options() const; + public: void clear_options(); const PROTOBUF_NAMESPACE_ID::MethodOptions& options() const; PROTOBUF_NAMESPACE_ID::MethodOptions* release_options(); @@ -3284,12 +3484,18 @@ class PROTOBUF_EXPORT MethodDescriptorProto : // optional bool client_streaming = 5 [default = false]; bool has_client_streaming() const; + private: + bool _internal_has_client_streaming() const; + public: void clear_client_streaming(); bool client_streaming() const; void set_client_streaming(bool value); // optional bool server_streaming = 6 [default = false]; bool has_server_streaming() const; + private: + bool _internal_has_server_streaming() const; + public: void clear_server_streaming(); bool server_streaming() const; void set_server_streaming(bool value); @@ -3519,6 +3725,9 @@ class PROTOBUF_EXPORT FileOptions : // optional string java_package = 1; bool has_java_package() const; + private: + bool _internal_has_java_package() const; + public: void clear_java_package(); const std::string& java_package() const; void set_java_package(const std::string& value); @@ -3537,9 +3746,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_java_package( std::string* java_package); + private: + const std::string& _internal_java_package() const; + void _internal_set_java_package(const std::string& value); + std::string* _internal_mutable_java_package(); + public: // optional string java_outer_classname = 8; bool has_java_outer_classname() const; + private: + bool _internal_has_java_outer_classname() const; + public: void clear_java_outer_classname(); const std::string& java_outer_classname() const; void set_java_outer_classname(const std::string& value); @@ -3558,9 +3775,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_java_outer_classname( std::string* java_outer_classname); + private: + const std::string& _internal_java_outer_classname() const; + void _internal_set_java_outer_classname(const std::string& value); + std::string* _internal_mutable_java_outer_classname(); + public: // optional string go_package = 11; bool has_go_package() const; + private: + bool _internal_has_go_package() const; + public: void clear_go_package(); const std::string& go_package() const; void set_go_package(const std::string& value); @@ -3579,9 +3804,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_go_package( std::string* go_package); + private: + const std::string& _internal_go_package() const; + void _internal_set_go_package(const std::string& value); + std::string* _internal_mutable_go_package(); + public: // optional string objc_class_prefix = 36; bool has_objc_class_prefix() const; + private: + bool _internal_has_objc_class_prefix() const; + public: void clear_objc_class_prefix(); const std::string& objc_class_prefix() const; void set_objc_class_prefix(const std::string& value); @@ -3600,9 +3833,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_objc_class_prefix( std::string* objc_class_prefix); + private: + const std::string& _internal_objc_class_prefix() const; + void _internal_set_objc_class_prefix(const std::string& value); + std::string* _internal_mutable_objc_class_prefix(); + public: // optional string csharp_namespace = 37; bool has_csharp_namespace() const; + private: + bool _internal_has_csharp_namespace() const; + public: void clear_csharp_namespace(); const std::string& csharp_namespace() const; void set_csharp_namespace(const std::string& value); @@ -3621,9 +3862,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_csharp_namespace( std::string* csharp_namespace); + private: + const std::string& _internal_csharp_namespace() const; + void _internal_set_csharp_namespace(const std::string& value); + std::string* _internal_mutable_csharp_namespace(); + public: // optional string swift_prefix = 39; bool has_swift_prefix() const; + private: + bool _internal_has_swift_prefix() const; + public: void clear_swift_prefix(); const std::string& swift_prefix() const; void set_swift_prefix(const std::string& value); @@ -3642,9 +3891,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_swift_prefix( std::string* swift_prefix); + private: + const std::string& _internal_swift_prefix() const; + void _internal_set_swift_prefix(const std::string& value); + std::string* _internal_mutable_swift_prefix(); + public: // optional string php_class_prefix = 40; bool has_php_class_prefix() const; + private: + bool _internal_has_php_class_prefix() const; + public: void clear_php_class_prefix(); const std::string& php_class_prefix() const; void set_php_class_prefix(const std::string& value); @@ -3663,9 +3920,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_php_class_prefix( std::string* php_class_prefix); + private: + const std::string& _internal_php_class_prefix() const; + void _internal_set_php_class_prefix(const std::string& value); + std::string* _internal_mutable_php_class_prefix(); + public: // optional string php_namespace = 41; bool has_php_namespace() const; + private: + bool _internal_has_php_namespace() const; + public: void clear_php_namespace(); const std::string& php_namespace() const; void set_php_namespace(const std::string& value); @@ -3684,9 +3949,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_php_namespace( std::string* php_namespace); + private: + const std::string& _internal_php_namespace() const; + void _internal_set_php_namespace(const std::string& value); + std::string* _internal_mutable_php_namespace(); + public: // optional string php_metadata_namespace = 44; bool has_php_metadata_namespace() const; + private: + bool _internal_has_php_metadata_namespace() const; + public: void clear_php_metadata_namespace(); const std::string& php_metadata_namespace() const; void set_php_metadata_namespace(const std::string& value); @@ -3705,9 +3978,17 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_php_metadata_namespace( std::string* php_metadata_namespace); + private: + const std::string& _internal_php_metadata_namespace() const; + void _internal_set_php_metadata_namespace(const std::string& value); + std::string* _internal_mutable_php_metadata_namespace(); + public: // optional string ruby_package = 45; bool has_ruby_package() const; + private: + bool _internal_has_ruby_package() const; + public: void clear_ruby_package(); const std::string& ruby_package() const; void set_ruby_package(const std::string& value); @@ -3726,63 +4007,98 @@ class PROTOBUF_EXPORT FileOptions : " future release.") void unsafe_arena_set_allocated_ruby_package( std::string* ruby_package); + private: + const std::string& _internal_ruby_package() const; + void _internal_set_ruby_package(const std::string& value); + std::string* _internal_mutable_ruby_package(); + public: // optional bool java_multiple_files = 10 [default = false]; bool has_java_multiple_files() const; + private: + bool _internal_has_java_multiple_files() const; + public: void clear_java_multiple_files(); bool java_multiple_files() const; void set_java_multiple_files(bool value); // optional bool java_generate_equals_and_hash = 20 [deprecated = true]; PROTOBUF_DEPRECATED bool has_java_generate_equals_and_hash() const; + private: + bool _internal_has_java_generate_equals_and_hash() const; + public: PROTOBUF_DEPRECATED void clear_java_generate_equals_and_hash(); PROTOBUF_DEPRECATED bool java_generate_equals_and_hash() const; PROTOBUF_DEPRECATED void set_java_generate_equals_and_hash(bool value); // optional bool java_string_check_utf8 = 27 [default = false]; bool has_java_string_check_utf8() const; + private: + bool _internal_has_java_string_check_utf8() const; + public: void clear_java_string_check_utf8(); bool java_string_check_utf8() const; void set_java_string_check_utf8(bool value); // optional bool cc_generic_services = 16 [default = false]; bool has_cc_generic_services() const; + private: + bool _internal_has_cc_generic_services() const; + public: void clear_cc_generic_services(); bool cc_generic_services() const; void set_cc_generic_services(bool value); // optional bool java_generic_services = 17 [default = false]; bool has_java_generic_services() const; + private: + bool _internal_has_java_generic_services() const; + public: void clear_java_generic_services(); bool java_generic_services() const; void set_java_generic_services(bool value); // optional bool py_generic_services = 18 [default = false]; bool has_py_generic_services() const; + private: + bool _internal_has_py_generic_services() const; + public: void clear_py_generic_services(); bool py_generic_services() const; void set_py_generic_services(bool value); // optional bool php_generic_services = 42 [default = false]; bool has_php_generic_services() const; + private: + bool _internal_has_php_generic_services() const; + public: void clear_php_generic_services(); bool php_generic_services() const; void set_php_generic_services(bool value); // optional bool deprecated = 23 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); // optional bool cc_enable_arenas = 31 [default = false]; bool has_cc_enable_arenas() const; + private: + bool _internal_has_cc_enable_arenas() const; + public: void clear_cc_enable_arenas(); bool cc_enable_arenas() const; void set_cc_enable_arenas(bool value); // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; bool has_optimize_for() const; + private: + bool _internal_has_optimize_for() const; + public: void clear_optimize_for(); PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode optimize_for() const; void set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_OptimizeMode value); @@ -3982,24 +4298,36 @@ class PROTOBUF_EXPORT MessageOptions : // optional bool message_set_wire_format = 1 [default = false]; bool has_message_set_wire_format() const; + private: + bool _internal_has_message_set_wire_format() const; + public: void clear_message_set_wire_format(); bool message_set_wire_format() const; void set_message_set_wire_format(bool value); // optional bool no_standard_descriptor_accessor = 2 [default = false]; bool has_no_standard_descriptor_accessor() const; + private: + bool _internal_has_no_standard_descriptor_accessor() const; + public: void clear_no_standard_descriptor_accessor(); bool no_standard_descriptor_accessor() const; void set_no_standard_descriptor_accessor(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); // optional bool map_entry = 7; bool has_map_entry() const; + private: + bool _internal_has_map_entry() const; + public: void clear_map_entry(); bool map_entry() const; void set_map_entry(bool value); @@ -4249,36 +4577,54 @@ class PROTOBUF_EXPORT FieldOptions : // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; bool has_ctype() const; + private: + bool _internal_has_ctype() const; + public: void clear_ctype(); PROTOBUF_NAMESPACE_ID::FieldOptions_CType ctype() const; void set_ctype(PROTOBUF_NAMESPACE_ID::FieldOptions_CType value); // optional bool packed = 2; bool has_packed() const; + private: + bool _internal_has_packed() const; + public: void clear_packed(); bool packed() const; void set_packed(bool value); // optional bool lazy = 5 [default = false]; bool has_lazy() const; + private: + bool _internal_has_lazy() const; + public: void clear_lazy(); bool lazy() const; void set_lazy(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); // optional bool weak = 10 [default = false]; bool has_weak() const; + private: + bool _internal_has_weak() const; + public: void clear_weak(); bool weak() const; void set_weak(bool value); // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; bool has_jstype() const; + private: + bool _internal_has_jstype() const; + public: void clear_jstype(); PROTOBUF_NAMESPACE_ID::FieldOptions_JSType jstype() const; void set_jstype(PROTOBUF_NAMESPACE_ID::FieldOptions_JSType value); @@ -4631,12 +4977,18 @@ class PROTOBUF_EXPORT EnumOptions : // optional bool allow_alias = 2; bool has_allow_alias() const; + private: + bool _internal_has_allow_alias() const; + public: void clear_allow_alias(); bool allow_alias() const; void set_allow_alias(bool value); // optional bool deprecated = 3 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); @@ -4815,6 +5167,9 @@ class PROTOBUF_EXPORT EnumValueOptions : // optional bool deprecated = 1 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); @@ -4992,6 +5347,9 @@ class PROTOBUF_EXPORT ServiceOptions : // optional bool deprecated = 33 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); @@ -5202,12 +5560,18 @@ class PROTOBUF_EXPORT MethodOptions : // optional bool deprecated = 33 [default = false]; bool has_deprecated() const; + private: + bool _internal_has_deprecated() const; + public: void clear_deprecated(); bool deprecated() const; void set_deprecated(bool value); // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; bool has_idempotency_level() const; + private: + bool _internal_has_idempotency_level() const; + public: void clear_idempotency_level(); PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel idempotency_level() const; void set_idempotency_level(PROTOBUF_NAMESPACE_ID::MethodOptions_IdempotencyLevel value); @@ -5375,6 +5739,9 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : }; // required string name_part = 1; bool has_name_part() const; + private: + bool _internal_has_name_part() const; + public: void clear_name_part(); const std::string& name_part() const; void set_name_part(const std::string& value); @@ -5393,9 +5760,17 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart : " future release.") void unsafe_arena_set_allocated_name_part( std::string* name_part); + private: + const std::string& _internal_name_part() const; + void _internal_set_name_part(const std::string& value); + std::string* _internal_mutable_name_part(); + public: // required bool is_extension = 2; bool has_is_extension() const; + private: + bool _internal_has_is_extension() const; + public: void clear_is_extension(); bool is_extension() const; void set_is_extension(bool value); @@ -5580,6 +5955,9 @@ class PROTOBUF_EXPORT UninterpretedOption : // optional string identifier_value = 3; bool has_identifier_value() const; + private: + bool _internal_has_identifier_value() const; + public: void clear_identifier_value(); const std::string& identifier_value() const; void set_identifier_value(const std::string& value); @@ -5598,9 +5976,17 @@ class PROTOBUF_EXPORT UninterpretedOption : " future release.") void unsafe_arena_set_allocated_identifier_value( std::string* identifier_value); + private: + const std::string& _internal_identifier_value() const; + void _internal_set_identifier_value(const std::string& value); + std::string* _internal_mutable_identifier_value(); + public: // optional bytes string_value = 7; bool has_string_value() const; + private: + bool _internal_has_string_value() const; + public: void clear_string_value(); const std::string& string_value() const; void set_string_value(const std::string& value); @@ -5619,9 +6005,17 @@ class PROTOBUF_EXPORT UninterpretedOption : " future release.") void unsafe_arena_set_allocated_string_value( std::string* string_value); + private: + const std::string& _internal_string_value() const; + void _internal_set_string_value(const std::string& value); + std::string* _internal_mutable_string_value(); + public: // optional string aggregate_value = 8; bool has_aggregate_value() const; + private: + bool _internal_has_aggregate_value() const; + public: void clear_aggregate_value(); const std::string& aggregate_value() const; void set_aggregate_value(const std::string& value); @@ -5640,21 +6034,35 @@ class PROTOBUF_EXPORT UninterpretedOption : " future release.") void unsafe_arena_set_allocated_aggregate_value( std::string* aggregate_value); + private: + const std::string& _internal_aggregate_value() const; + void _internal_set_aggregate_value(const std::string& value); + std::string* _internal_mutable_aggregate_value(); + public: // optional uint64 positive_int_value = 4; bool has_positive_int_value() const; + private: + bool _internal_has_positive_int_value() const; + public: void clear_positive_int_value(); ::PROTOBUF_NAMESPACE_ID::uint64 positive_int_value() const; void set_positive_int_value(::PROTOBUF_NAMESPACE_ID::uint64 value); // optional int64 negative_int_value = 5; bool has_negative_int_value() const; + private: + bool _internal_has_negative_int_value() const; + public: void clear_negative_int_value(); ::PROTOBUF_NAMESPACE_ID::int64 negative_int_value() const; void set_negative_int_value(::PROTOBUF_NAMESPACE_ID::int64 value); // optional double double_value = 6; bool has_double_value() const; + private: + bool _internal_has_double_value() const; + public: void clear_double_value(); double double_value() const; void set_double_value(double value); @@ -5862,9 +6270,15 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : void add_leading_detached_comments(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& leading_detached_comments() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_leading_detached_comments(); + private: + std::string* _internal_add_leading_detached_comments(); + public: // optional string leading_comments = 3; bool has_leading_comments() const; + private: + bool _internal_has_leading_comments() const; + public: void clear_leading_comments(); const std::string& leading_comments() const; void set_leading_comments(const std::string& value); @@ -5883,9 +6297,17 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : " future release.") void unsafe_arena_set_allocated_leading_comments( std::string* leading_comments); + private: + const std::string& _internal_leading_comments() const; + void _internal_set_leading_comments(const std::string& value); + std::string* _internal_mutable_leading_comments(); + public: // optional string trailing_comments = 4; bool has_trailing_comments() const; + private: + bool _internal_has_trailing_comments() const; + public: void clear_trailing_comments(); const std::string& trailing_comments() const; void set_trailing_comments(const std::string& value); @@ -5904,6 +6326,11 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location : " future release.") void unsafe_arena_set_allocated_trailing_comments( std::string* trailing_comments); + private: + const std::string& _internal_trailing_comments() const; + void _internal_set_trailing_comments(const std::string& value); + std::string* _internal_mutable_trailing_comments(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location) private: @@ -6250,6 +6677,9 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : // optional string source_file = 2; bool has_source_file() const; + private: + bool _internal_has_source_file() const; + public: void clear_source_file(); const std::string& source_file() const; void set_source_file(const std::string& value); @@ -6268,15 +6698,26 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation : " future release.") void unsafe_arena_set_allocated_source_file( std::string* source_file); + private: + const std::string& _internal_source_file() const; + void _internal_set_source_file(const std::string& value); + std::string* _internal_mutable_source_file(); + public: // optional int32 begin = 3; bool has_begin() const; + private: + bool _internal_has_begin() const; + public: void clear_begin(); ::PROTOBUF_NAMESPACE_ID::int32 begin() const; void set_begin(::PROTOBUF_NAMESPACE_ID::int32 value); // optional int32 end = 4; bool has_end() const; + private: + bool _internal_has_end() const; + public: void clear_end(); ::PROTOBUF_NAMESPACE_ID::int32 end() const; void set_end(::PROTOBUF_NAMESPACE_ID::int32 value); @@ -6512,22 +6953,35 @@ FileDescriptorSet::file() const { // FileDescriptorProto // optional string name = 1; -inline bool FileDescriptorProto::has_name() const { +inline bool FileDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool FileDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void FileDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FileDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void FileDescriptorProto::set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + _internal_set_name(value); // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name) } +inline std::string* FileDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& FileDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void FileDescriptorProto::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); +} inline void FileDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( @@ -6548,9 +7002,8 @@ inline void FileDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name) } -inline std::string* FileDescriptorProto::mutable_name() { +inline std::string* FileDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileDescriptorProto::release_name() { @@ -6592,21 +7045,34 @@ inline void FileDescriptorProto::unsafe_arena_set_allocated_name( } // optional string package = 2; -inline bool FileDescriptorProto::has_package() const { +inline bool FileDescriptorProto::_internal_has_package() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool FileDescriptorProto::has_package() const { + return _internal_has_package(); +} inline void FileDescriptorProto::clear_package() { package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FileDescriptorProto::package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package) - return package_.Get(); + return _internal_package(); } inline void FileDescriptorProto::set_package(const std::string& value) { + _internal_set_package(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) +} +inline std::string* FileDescriptorProto::mutable_package() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) + return _internal_mutable_package(); +} +inline const std::string& FileDescriptorProto::_internal_package() const { + return package_.Get(); +} +inline void FileDescriptorProto::_internal_set_package(const std::string& value) { _has_bits_[0] |= 0x00000002u; package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package) } inline void FileDescriptorProto::set_package(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -6628,9 +7094,8 @@ inline void FileDescriptorProto::set_package(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package) } -inline std::string* FileDescriptorProto::mutable_package() { +inline std::string* FileDescriptorProto::_internal_mutable_package() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package) return package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileDescriptorProto::release_package() { @@ -6678,6 +7143,10 @@ inline int FileDescriptorProto::dependency_size() const { inline void FileDescriptorProto::clear_dependency() { dependency_.Clear(); } +inline std::string* FileDescriptorProto::add_dependency() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency) + return _internal_add_dependency(); +} inline const std::string& FileDescriptorProto::dependency(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency) return dependency_.Get(index); @@ -6704,8 +7173,7 @@ inline void FileDescriptorProto::set_dependency(int index, const char* value, si reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency) } -inline std::string* FileDescriptorProto::add_dependency() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency) +inline std::string* FileDescriptorProto::_internal_add_dependency() { return dependency_.Add(); } inline void FileDescriptorProto::add_dependency(const std::string& value) { @@ -6917,9 +7385,12 @@ FileDescriptorProto::extension() const { } // optional .google.protobuf.FileOptions options = 8; -inline bool FileDescriptorProto::has_options() const { +inline bool FileDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool FileDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void FileDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000008u; @@ -6931,17 +7402,14 @@ inline const PROTOBUF_NAMESPACE_ID::FileOptions& FileDescriptorProto::options() &PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options) - _has_bits_[0] &= ~0x00000008u; - PROTOBUF_NAMESPACE_ID::FileOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::FileOptions* FileDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options) _has_bits_[0] &= ~0x00000008u; PROTOBUF_NAMESPACE_ID::FileOptions* temp = options_; options_ = nullptr; @@ -6977,9 +7445,12 @@ inline void FileDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::Fi } // optional .google.protobuf.SourceCodeInfo source_code_info = 9; -inline bool FileDescriptorProto::has_source_code_info() const { +inline bool FileDescriptorProto::_internal_has_source_code_info() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool FileDescriptorProto::has_source_code_info() const { + return _internal_has_source_code_info(); +} inline void FileDescriptorProto::clear_source_code_info() { if (source_code_info_ != nullptr) source_code_info_->Clear(); _has_bits_[0] &= ~0x00000010u; @@ -6991,17 +7462,14 @@ inline const PROTOBUF_NAMESPACE_ID::SourceCodeInfo& FileDescriptorProto::source_ &PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_); } inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::release_source_code_info() { - // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info) - _has_bits_[0] &= ~0x00000010u; - PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = source_code_info_; + auto temp = unsafe_arena_release_source_code_info(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - source_code_info_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::SourceCodeInfo* FileDescriptorProto::unsafe_arena_release_source_code_info() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FileDescriptorProto.source_code_info) + // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info) _has_bits_[0] &= ~0x00000010u; PROTOBUF_NAMESPACE_ID::SourceCodeInfo* temp = source_code_info_; source_code_info_ = nullptr; @@ -7037,21 +7505,34 @@ inline void FileDescriptorProto::set_allocated_source_code_info(PROTOBUF_NAMESPA } // optional string syntax = 12; -inline bool FileDescriptorProto::has_syntax() const { +inline bool FileDescriptorProto::_internal_has_syntax() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool FileDescriptorProto::has_syntax() const { + return _internal_has_syntax(); +} inline void FileDescriptorProto::clear_syntax() { syntax_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FileDescriptorProto::syntax() const { // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax) - return syntax_.Get(); + return _internal_syntax(); } inline void FileDescriptorProto::set_syntax(const std::string& value) { + _internal_set_syntax(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) +} +inline std::string* FileDescriptorProto::mutable_syntax() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) + return _internal_mutable_syntax(); +} +inline const std::string& FileDescriptorProto::_internal_syntax() const { + return syntax_.Get(); +} +inline void FileDescriptorProto::_internal_set_syntax(const std::string& value) { _has_bits_[0] |= 0x00000004u; syntax_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax) } inline void FileDescriptorProto::set_syntax(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -7073,9 +7554,8 @@ inline void FileDescriptorProto::set_syntax(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax) } -inline std::string* FileDescriptorProto::mutable_syntax() { +inline std::string* FileDescriptorProto::_internal_mutable_syntax() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax) return syntax_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileDescriptorProto::release_syntax() { @@ -7121,9 +7601,12 @@ inline void FileDescriptorProto::unsafe_arena_set_allocated_syntax( // DescriptorProto_ExtensionRange // optional int32 start = 1; -inline bool DescriptorProto_ExtensionRange::has_start() const { +inline bool DescriptorProto_ExtensionRange::_internal_has_start() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool DescriptorProto_ExtensionRange::has_start() const { + return _internal_has_start(); +} inline void DescriptorProto_ExtensionRange::clear_start() { start_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -7139,9 +7622,12 @@ inline void DescriptorProto_ExtensionRange::set_start(::PROTOBUF_NAMESPACE_ID::i } // optional int32 end = 2; -inline bool DescriptorProto_ExtensionRange::has_end() const { +inline bool DescriptorProto_ExtensionRange::_internal_has_end() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool DescriptorProto_ExtensionRange::has_end() const { + return _internal_has_end(); +} inline void DescriptorProto_ExtensionRange::clear_end() { end_ = 0; _has_bits_[0] &= ~0x00000004u; @@ -7157,9 +7643,12 @@ inline void DescriptorProto_ExtensionRange::set_end(::PROTOBUF_NAMESPACE_ID::int } // optional .google.protobuf.ExtensionRangeOptions options = 3; -inline bool DescriptorProto_ExtensionRange::has_options() const { +inline bool DescriptorProto_ExtensionRange::_internal_has_options() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool DescriptorProto_ExtensionRange::has_options() const { + return _internal_has_options(); +} inline void DescriptorProto_ExtensionRange::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000001u; @@ -7171,17 +7660,14 @@ inline const PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions& DescriptorProto_Exten &PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.ExtensionRange.options) - _has_bits_[0] &= ~0x00000001u; - PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* DescriptorProto_ExtensionRange::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.ExtensionRange.options) + // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.ExtensionRange.options) _has_bits_[0] &= ~0x00000001u; PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* temp = options_; options_ = nullptr; @@ -7221,9 +7707,12 @@ inline void DescriptorProto_ExtensionRange::set_allocated_options(PROTOBUF_NAMES // DescriptorProto_ReservedRange // optional int32 start = 1; -inline bool DescriptorProto_ReservedRange::has_start() const { +inline bool DescriptorProto_ReservedRange::_internal_has_start() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool DescriptorProto_ReservedRange::has_start() const { + return _internal_has_start(); +} inline void DescriptorProto_ReservedRange::clear_start() { start_ = 0; _has_bits_[0] &= ~0x00000001u; @@ -7239,9 +7728,12 @@ inline void DescriptorProto_ReservedRange::set_start(::PROTOBUF_NAMESPACE_ID::in } // optional int32 end = 2; -inline bool DescriptorProto_ReservedRange::has_end() const { +inline bool DescriptorProto_ReservedRange::_internal_has_end() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool DescriptorProto_ReservedRange::has_end() const { + return _internal_has_end(); +} inline void DescriptorProto_ReservedRange::clear_end() { end_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -7261,21 +7753,34 @@ inline void DescriptorProto_ReservedRange::set_end(::PROTOBUF_NAMESPACE_ID::int3 // DescriptorProto // optional string name = 1; -inline bool DescriptorProto::has_name() const { +inline bool DescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool DescriptorProto::has_name() const { + return _internal_has_name(); +} inline void DescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& DescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void DescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) +} +inline std::string* DescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& DescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void DescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name) } inline void DescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -7297,9 +7802,8 @@ inline void DescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name) } -inline std::string* DescriptorProto::mutable_name() { +inline std::string* DescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* DescriptorProto::release_name() { @@ -7521,9 +8025,12 @@ DescriptorProto::oneof_decl() const { } // optional .google.protobuf.MessageOptions options = 7; -inline bool DescriptorProto::has_options() const { +inline bool DescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool DescriptorProto::has_options() const { + return _internal_has_options(); +} inline void DescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -7535,17 +8042,14 @@ inline const PROTOBUF_NAMESPACE_ID::MessageOptions& DescriptorProto::options() c &PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - PROTOBUF_NAMESPACE_ID::MessageOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::MessageOptions* DescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.DescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::MessageOptions* temp = options_; options_ = nullptr; @@ -7617,6 +8121,10 @@ inline int DescriptorProto::reserved_name_size() const { inline void DescriptorProto::clear_reserved_name() { reserved_name_.Clear(); } +inline std::string* DescriptorProto::add_reserved_name() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name) + return _internal_add_reserved_name(); +} inline const std::string& DescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name) return reserved_name_.Get(index); @@ -7643,8 +8151,7 @@ inline void DescriptorProto::set_reserved_name(int index, const char* value, siz reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name) } -inline std::string* DescriptorProto::add_reserved_name() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name) +inline std::string* DescriptorProto::_internal_add_reserved_name() { return reserved_name_.Add(); } inline void DescriptorProto::add_reserved_name(const std::string& value) { @@ -7714,21 +8221,34 @@ ExtensionRangeOptions::uninterpreted_option() const { // FieldDescriptorProto // optional string name = 1; -inline bool FieldDescriptorProto::has_name() const { +inline bool FieldDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool FieldDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void FieldDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FieldDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void FieldDescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) +} +inline std::string* FieldDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& FieldDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void FieldDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name) } inline void FieldDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -7750,9 +8270,8 @@ inline void FieldDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name) } -inline std::string* FieldDescriptorProto::mutable_name() { +inline std::string* FieldDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FieldDescriptorProto::release_name() { @@ -7794,9 +8313,12 @@ inline void FieldDescriptorProto::unsafe_arena_set_allocated_name( } // optional int32 number = 3; -inline bool FieldDescriptorProto::has_number() const { +inline bool FieldDescriptorProto::_internal_has_number() const { return (_has_bits_[0] & 0x00000040u) != 0; } +inline bool FieldDescriptorProto::has_number() const { + return _internal_has_number(); +} inline void FieldDescriptorProto::clear_number() { number_ = 0; _has_bits_[0] &= ~0x00000040u; @@ -7812,9 +8334,12 @@ inline void FieldDescriptorProto::set_number(::PROTOBUF_NAMESPACE_ID::int32 valu } // optional .google.protobuf.FieldDescriptorProto.Label label = 4; -inline bool FieldDescriptorProto::has_label() const { +inline bool FieldDescriptorProto::_internal_has_label() const { return (_has_bits_[0] & 0x00000100u) != 0; } +inline bool FieldDescriptorProto::has_label() const { + return _internal_has_label(); +} inline void FieldDescriptorProto::clear_label() { label_ = 1; _has_bits_[0] &= ~0x00000100u; @@ -7831,9 +8356,12 @@ inline void FieldDescriptorProto::set_label(PROTOBUF_NAMESPACE_ID::FieldDescript } // optional .google.protobuf.FieldDescriptorProto.Type type = 5; -inline bool FieldDescriptorProto::has_type() const { +inline bool FieldDescriptorProto::_internal_has_type() const { return (_has_bits_[0] & 0x00000200u) != 0; } +inline bool FieldDescriptorProto::has_type() const { + return _internal_has_type(); +} inline void FieldDescriptorProto::clear_type() { type_ = 1; _has_bits_[0] &= ~0x00000200u; @@ -7850,21 +8378,34 @@ inline void FieldDescriptorProto::set_type(PROTOBUF_NAMESPACE_ID::FieldDescripto } // optional string type_name = 6; -inline bool FieldDescriptorProto::has_type_name() const { +inline bool FieldDescriptorProto::_internal_has_type_name() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool FieldDescriptorProto::has_type_name() const { + return _internal_has_type_name(); +} inline void FieldDescriptorProto::clear_type_name() { type_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FieldDescriptorProto::type_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name) - return type_name_.Get(); + return _internal_type_name(); } inline void FieldDescriptorProto::set_type_name(const std::string& value) { + _internal_set_type_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) +} +inline std::string* FieldDescriptorProto::mutable_type_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name) + return _internal_mutable_type_name(); +} +inline const std::string& FieldDescriptorProto::_internal_type_name() const { + return type_name_.Get(); +} +inline void FieldDescriptorProto::_internal_set_type_name(const std::string& value) { _has_bits_[0] |= 0x00000004u; type_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name) } inline void FieldDescriptorProto::set_type_name(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -7886,9 +8427,8 @@ inline void FieldDescriptorProto::set_type_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name) } -inline std::string* FieldDescriptorProto::mutable_type_name() { +inline std::string* FieldDescriptorProto::_internal_mutable_type_name() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name) return type_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FieldDescriptorProto::release_type_name() { @@ -7930,21 +8470,34 @@ inline void FieldDescriptorProto::unsafe_arena_set_allocated_type_name( } // optional string extendee = 2; -inline bool FieldDescriptorProto::has_extendee() const { +inline bool FieldDescriptorProto::_internal_has_extendee() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool FieldDescriptorProto::has_extendee() const { + return _internal_has_extendee(); +} inline void FieldDescriptorProto::clear_extendee() { extendee_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FieldDescriptorProto::extendee() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee) - return extendee_.Get(); + return _internal_extendee(); } inline void FieldDescriptorProto::set_extendee(const std::string& value) { + _internal_set_extendee(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) +} +inline std::string* FieldDescriptorProto::mutable_extendee() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) + return _internal_mutable_extendee(); +} +inline const std::string& FieldDescriptorProto::_internal_extendee() const { + return extendee_.Get(); +} +inline void FieldDescriptorProto::_internal_set_extendee(const std::string& value) { _has_bits_[0] |= 0x00000002u; extendee_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee) } inline void FieldDescriptorProto::set_extendee(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -7966,9 +8519,8 @@ inline void FieldDescriptorProto::set_extendee(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee) } -inline std::string* FieldDescriptorProto::mutable_extendee() { +inline std::string* FieldDescriptorProto::_internal_mutable_extendee() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee) return extendee_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FieldDescriptorProto::release_extendee() { @@ -8010,21 +8562,34 @@ inline void FieldDescriptorProto::unsafe_arena_set_allocated_extendee( } // optional string default_value = 7; -inline bool FieldDescriptorProto::has_default_value() const { +inline bool FieldDescriptorProto::_internal_has_default_value() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool FieldDescriptorProto::has_default_value() const { + return _internal_has_default_value(); +} inline void FieldDescriptorProto::clear_default_value() { default_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000008u; } inline const std::string& FieldDescriptorProto::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value) - return default_value_.Get(); + return _internal_default_value(); } inline void FieldDescriptorProto::set_default_value(const std::string& value) { + _internal_set_default_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) +} +inline std::string* FieldDescriptorProto::mutable_default_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value) + return _internal_mutable_default_value(); +} +inline const std::string& FieldDescriptorProto::_internal_default_value() const { + return default_value_.Get(); +} +inline void FieldDescriptorProto::_internal_set_default_value(const std::string& value) { _has_bits_[0] |= 0x00000008u; default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value) } inline void FieldDescriptorProto::set_default_value(std::string&& value) { _has_bits_[0] |= 0x00000008u; @@ -8046,9 +8611,8 @@ inline void FieldDescriptorProto::set_default_value(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value) } -inline std::string* FieldDescriptorProto::mutable_default_value() { +inline std::string* FieldDescriptorProto::_internal_mutable_default_value() { _has_bits_[0] |= 0x00000008u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value) return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FieldDescriptorProto::release_default_value() { @@ -8090,9 +8654,12 @@ inline void FieldDescriptorProto::unsafe_arena_set_allocated_default_value( } // optional int32 oneof_index = 9; -inline bool FieldDescriptorProto::has_oneof_index() const { +inline bool FieldDescriptorProto::_internal_has_oneof_index() const { return (_has_bits_[0] & 0x00000080u) != 0; } +inline bool FieldDescriptorProto::has_oneof_index() const { + return _internal_has_oneof_index(); +} inline void FieldDescriptorProto::clear_oneof_index() { oneof_index_ = 0; _has_bits_[0] &= ~0x00000080u; @@ -8108,21 +8675,34 @@ inline void FieldDescriptorProto::set_oneof_index(::PROTOBUF_NAMESPACE_ID::int32 } // optional string json_name = 10; -inline bool FieldDescriptorProto::has_json_name() const { +inline bool FieldDescriptorProto::_internal_has_json_name() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool FieldDescriptorProto::has_json_name() const { + return _internal_has_json_name(); +} inline void FieldDescriptorProto::clear_json_name() { json_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000010u; } inline const std::string& FieldDescriptorProto::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name) - return json_name_.Get(); + return _internal_json_name(); } inline void FieldDescriptorProto::set_json_name(const std::string& value) { + _internal_set_json_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) +} +inline std::string* FieldDescriptorProto::mutable_json_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name) + return _internal_mutable_json_name(); +} +inline const std::string& FieldDescriptorProto::_internal_json_name() const { + return json_name_.Get(); +} +inline void FieldDescriptorProto::_internal_set_json_name(const std::string& value) { _has_bits_[0] |= 0x00000010u; json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name) } inline void FieldDescriptorProto::set_json_name(std::string&& value) { _has_bits_[0] |= 0x00000010u; @@ -8144,9 +8724,8 @@ inline void FieldDescriptorProto::set_json_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name) } -inline std::string* FieldDescriptorProto::mutable_json_name() { +inline std::string* FieldDescriptorProto::_internal_mutable_json_name() { _has_bits_[0] |= 0x00000010u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name) return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FieldDescriptorProto::release_json_name() { @@ -8188,9 +8767,12 @@ inline void FieldDescriptorProto::unsafe_arena_set_allocated_json_name( } // optional .google.protobuf.FieldOptions options = 8; -inline bool FieldDescriptorProto::has_options() const { +inline bool FieldDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000020u) != 0; } +inline bool FieldDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void FieldDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000020u; @@ -8202,17 +8784,14 @@ inline const PROTOBUF_NAMESPACE_ID::FieldOptions& FieldDescriptorProto::options( &PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options) - _has_bits_[0] &= ~0x00000020u; - PROTOBUF_NAMESPACE_ID::FieldOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::FieldOptions* FieldDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.FieldDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options) _has_bits_[0] &= ~0x00000020u; PROTOBUF_NAMESPACE_ID::FieldOptions* temp = options_; options_ = nullptr; @@ -8252,21 +8831,34 @@ inline void FieldDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::F // OneofDescriptorProto // optional string name = 1; -inline bool OneofDescriptorProto::has_name() const { +inline bool OneofDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool OneofDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void OneofDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& OneofDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void OneofDescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) +} +inline std::string* OneofDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& OneofDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void OneofDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name) } inline void OneofDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -8288,9 +8880,8 @@ inline void OneofDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name) } -inline std::string* OneofDescriptorProto::mutable_name() { +inline std::string* OneofDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* OneofDescriptorProto::release_name() { @@ -8332,9 +8923,12 @@ inline void OneofDescriptorProto::unsafe_arena_set_allocated_name( } // optional .google.protobuf.OneofOptions options = 2; -inline bool OneofDescriptorProto::has_options() const { +inline bool OneofDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool OneofDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void OneofDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -8346,17 +8940,14 @@ inline const PROTOBUF_NAMESPACE_ID::OneofOptions& OneofDescriptorProto::options( &PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - PROTOBUF_NAMESPACE_ID::OneofOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::OneofOptions* OneofDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.OneofDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::OneofOptions* temp = options_; options_ = nullptr; @@ -8396,9 +8987,12 @@ inline void OneofDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID::O // EnumDescriptorProto_EnumReservedRange // optional int32 start = 1; -inline bool EnumDescriptorProto_EnumReservedRange::has_start() const { +inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_start() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool EnumDescriptorProto_EnumReservedRange::has_start() const { + return _internal_has_start(); +} inline void EnumDescriptorProto_EnumReservedRange::clear_start() { start_ = 0; _has_bits_[0] &= ~0x00000001u; @@ -8414,9 +9008,12 @@ inline void EnumDescriptorProto_EnumReservedRange::set_start(::PROTOBUF_NAMESPAC } // optional int32 end = 2; -inline bool EnumDescriptorProto_EnumReservedRange::has_end() const { +inline bool EnumDescriptorProto_EnumReservedRange::_internal_has_end() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool EnumDescriptorProto_EnumReservedRange::has_end() const { + return _internal_has_end(); +} inline void EnumDescriptorProto_EnumReservedRange::clear_end() { end_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -8436,21 +9033,34 @@ inline void EnumDescriptorProto_EnumReservedRange::set_end(::PROTOBUF_NAMESPACE_ // EnumDescriptorProto // optional string name = 1; -inline bool EnumDescriptorProto::has_name() const { +inline bool EnumDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool EnumDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void EnumDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void EnumDescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) +} +inline std::string* EnumDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& EnumDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void EnumDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name) } inline void EnumDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -8472,9 +9082,8 @@ inline void EnumDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name) } -inline std::string* EnumDescriptorProto::mutable_name() { +inline std::string* EnumDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* EnumDescriptorProto::release_name() { @@ -8546,9 +9155,12 @@ EnumDescriptorProto::value() const { } // optional .google.protobuf.EnumOptions options = 3; -inline bool EnumDescriptorProto::has_options() const { +inline bool EnumDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool EnumDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void EnumDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -8560,17 +9172,14 @@ inline const PROTOBUF_NAMESPACE_ID::EnumOptions& EnumDescriptorProto::options() &PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - PROTOBUF_NAMESPACE_ID::EnumOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::EnumOptions* EnumDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::EnumOptions* temp = options_; options_ = nullptr; @@ -8642,6 +9251,10 @@ inline int EnumDescriptorProto::reserved_name_size() const { inline void EnumDescriptorProto::clear_reserved_name() { reserved_name_.Clear(); } +inline std::string* EnumDescriptorProto::add_reserved_name() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.EnumDescriptorProto.reserved_name) + return _internal_add_reserved_name(); +} inline const std::string& EnumDescriptorProto::reserved_name(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.reserved_name) return reserved_name_.Get(index); @@ -8668,8 +9281,7 @@ inline void EnumDescriptorProto::set_reserved_name(int index, const char* value, reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.reserved_name) } -inline std::string* EnumDescriptorProto::add_reserved_name() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.EnumDescriptorProto.reserved_name) +inline std::string* EnumDescriptorProto::_internal_add_reserved_name() { return reserved_name_.Add(); } inline void EnumDescriptorProto::add_reserved_name(const std::string& value) { @@ -8705,22 +9317,35 @@ EnumDescriptorProto::mutable_reserved_name() { // EnumValueDescriptorProto // optional string name = 1; -inline bool EnumValueDescriptorProto::has_name() const { +inline bool EnumValueDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool EnumValueDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void EnumValueDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& EnumValueDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void EnumValueDescriptorProto::set_name(const std::string& value) { - _has_bits_[0] |= 0x00000001u; - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); + _internal_set_name(value); // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name) } +inline std::string* EnumValueDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& EnumValueDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void EnumValueDescriptorProto::_internal_set_name(const std::string& value) { + _has_bits_[0] |= 0x00000001u; + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); +} inline void EnumValueDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; name_.Set( @@ -8741,9 +9366,8 @@ inline void EnumValueDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name) } -inline std::string* EnumValueDescriptorProto::mutable_name() { +inline std::string* EnumValueDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* EnumValueDescriptorProto::release_name() { @@ -8785,9 +9409,12 @@ inline void EnumValueDescriptorProto::unsafe_arena_set_allocated_name( } // optional int32 number = 2; -inline bool EnumValueDescriptorProto::has_number() const { +inline bool EnumValueDescriptorProto::_internal_has_number() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool EnumValueDescriptorProto::has_number() const { + return _internal_has_number(); +} inline void EnumValueDescriptorProto::clear_number() { number_ = 0; _has_bits_[0] &= ~0x00000004u; @@ -8803,9 +9430,12 @@ inline void EnumValueDescriptorProto::set_number(::PROTOBUF_NAMESPACE_ID::int32 } // optional .google.protobuf.EnumValueOptions options = 3; -inline bool EnumValueDescriptorProto::has_options() const { +inline bool EnumValueDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool EnumValueDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void EnumValueDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -8817,17 +9447,14 @@ inline const PROTOBUF_NAMESPACE_ID::EnumValueOptions& EnumValueDescriptorProto:: &PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::EnumValueOptions* EnumValueDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.EnumValueDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::EnumValueOptions* temp = options_; options_ = nullptr; @@ -8867,21 +9494,34 @@ inline void EnumValueDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_I // ServiceDescriptorProto // optional string name = 1; -inline bool ServiceDescriptorProto::has_name() const { +inline bool ServiceDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool ServiceDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void ServiceDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& ServiceDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void ServiceDescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) +} +inline std::string* ServiceDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& ServiceDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void ServiceDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name) } inline void ServiceDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -8903,9 +9543,8 @@ inline void ServiceDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name) } -inline std::string* ServiceDescriptorProto::mutable_name() { +inline std::string* ServiceDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* ServiceDescriptorProto::release_name() { @@ -8977,9 +9616,12 @@ ServiceDescriptorProto::method() const { } // optional .google.protobuf.ServiceOptions options = 3; -inline bool ServiceDescriptorProto::has_options() const { +inline bool ServiceDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool ServiceDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void ServiceDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000002u; @@ -8991,17 +9633,14 @@ inline const PROTOBUF_NAMESPACE_ID::ServiceOptions& ServiceDescriptorProto::opti &PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options) - _has_bits_[0] &= ~0x00000002u; - PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::ServiceOptions* ServiceDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.ServiceDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::ServiceOptions* temp = options_; options_ = nullptr; @@ -9041,21 +9680,34 @@ inline void ServiceDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID: // MethodDescriptorProto // optional string name = 1; -inline bool MethodDescriptorProto::has_name() const { +inline bool MethodDescriptorProto::_internal_has_name() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool MethodDescriptorProto::has_name() const { + return _internal_has_name(); +} inline void MethodDescriptorProto::clear_name() { name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& MethodDescriptorProto::name() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name) - return name_.Get(); + return _internal_name(); } inline void MethodDescriptorProto::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) +} +inline std::string* MethodDescriptorProto::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) + return _internal_mutable_name(); +} +inline const std::string& MethodDescriptorProto::_internal_name() const { + return name_.Get(); +} +inline void MethodDescriptorProto::_internal_set_name(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name) } inline void MethodDescriptorProto::set_name(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -9077,9 +9729,8 @@ inline void MethodDescriptorProto::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name) } -inline std::string* MethodDescriptorProto::mutable_name() { +inline std::string* MethodDescriptorProto::_internal_mutable_name() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* MethodDescriptorProto::release_name() { @@ -9121,21 +9772,34 @@ inline void MethodDescriptorProto::unsafe_arena_set_allocated_name( } // optional string input_type = 2; -inline bool MethodDescriptorProto::has_input_type() const { +inline bool MethodDescriptorProto::_internal_has_input_type() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool MethodDescriptorProto::has_input_type() const { + return _internal_has_input_type(); +} inline void MethodDescriptorProto::clear_input_type() { input_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& MethodDescriptorProto::input_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type) - return input_type_.Get(); + return _internal_input_type(); } inline void MethodDescriptorProto::set_input_type(const std::string& value) { + _internal_set_input_type(value); + // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) +} +inline std::string* MethodDescriptorProto::mutable_input_type() { + // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type) + return _internal_mutable_input_type(); +} +inline const std::string& MethodDescriptorProto::_internal_input_type() const { + return input_type_.Get(); +} +inline void MethodDescriptorProto::_internal_set_input_type(const std::string& value) { _has_bits_[0] |= 0x00000002u; input_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type) } inline void MethodDescriptorProto::set_input_type(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -9157,9 +9821,8 @@ inline void MethodDescriptorProto::set_input_type(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type) } -inline std::string* MethodDescriptorProto::mutable_input_type() { +inline std::string* MethodDescriptorProto::_internal_mutable_input_type() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type) return input_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* MethodDescriptorProto::release_input_type() { @@ -9201,21 +9864,34 @@ inline void MethodDescriptorProto::unsafe_arena_set_allocated_input_type( } // optional string output_type = 3; -inline bool MethodDescriptorProto::has_output_type() const { +inline bool MethodDescriptorProto::_internal_has_output_type() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool MethodDescriptorProto::has_output_type() const { + return _internal_has_output_type(); +} inline void MethodDescriptorProto::clear_output_type() { output_type_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& MethodDescriptorProto::output_type() const { // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type) - return output_type_.Get(); + return _internal_output_type(); } inline void MethodDescriptorProto::set_output_type(const std::string& value) { + _internal_set_output_type(value); + // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) +} +inline std::string* MethodDescriptorProto::mutable_output_type() { + // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type) + return _internal_mutable_output_type(); +} +inline const std::string& MethodDescriptorProto::_internal_output_type() const { + return output_type_.Get(); +} +inline void MethodDescriptorProto::_internal_set_output_type(const std::string& value) { _has_bits_[0] |= 0x00000004u; output_type_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type) } inline void MethodDescriptorProto::set_output_type(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -9237,9 +9913,8 @@ inline void MethodDescriptorProto::set_output_type(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type) } -inline std::string* MethodDescriptorProto::mutable_output_type() { +inline std::string* MethodDescriptorProto::_internal_mutable_output_type() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type) return output_type_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* MethodDescriptorProto::release_output_type() { @@ -9281,9 +9956,12 @@ inline void MethodDescriptorProto::unsafe_arena_set_allocated_output_type( } // optional .google.protobuf.MethodOptions options = 4; -inline bool MethodDescriptorProto::has_options() const { +inline bool MethodDescriptorProto::_internal_has_options() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool MethodDescriptorProto::has_options() const { + return _internal_has_options(); +} inline void MethodDescriptorProto::clear_options() { if (options_ != nullptr) options_->Clear(); _has_bits_[0] &= ~0x00000008u; @@ -9295,17 +9973,14 @@ inline const PROTOBUF_NAMESPACE_ID::MethodOptions& MethodDescriptorProto::option &PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_); } inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::release_options() { - // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options) - _has_bits_[0] &= ~0x00000008u; - PROTOBUF_NAMESPACE_ID::MethodOptions* temp = options_; + auto temp = unsafe_arena_release_options(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - options_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::MethodOptions* MethodDescriptorProto::unsafe_arena_release_options() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.MethodDescriptorProto.options) + // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options) _has_bits_[0] &= ~0x00000008u; PROTOBUF_NAMESPACE_ID::MethodOptions* temp = options_; options_ = nullptr; @@ -9341,9 +10016,12 @@ inline void MethodDescriptorProto::set_allocated_options(PROTOBUF_NAMESPACE_ID:: } // optional bool client_streaming = 5 [default = false]; -inline bool MethodDescriptorProto::has_client_streaming() const { +inline bool MethodDescriptorProto::_internal_has_client_streaming() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool MethodDescriptorProto::has_client_streaming() const { + return _internal_has_client_streaming(); +} inline void MethodDescriptorProto::clear_client_streaming() { client_streaming_ = false; _has_bits_[0] &= ~0x00000010u; @@ -9359,9 +10037,12 @@ inline void MethodDescriptorProto::set_client_streaming(bool value) { } // optional bool server_streaming = 6 [default = false]; -inline bool MethodDescriptorProto::has_server_streaming() const { +inline bool MethodDescriptorProto::_internal_has_server_streaming() const { return (_has_bits_[0] & 0x00000020u) != 0; } +inline bool MethodDescriptorProto::has_server_streaming() const { + return _internal_has_server_streaming(); +} inline void MethodDescriptorProto::clear_server_streaming() { server_streaming_ = false; _has_bits_[0] &= ~0x00000020u; @@ -9381,21 +10062,34 @@ inline void MethodDescriptorProto::set_server_streaming(bool value) { // FileOptions // optional string java_package = 1; -inline bool FileOptions::has_java_package() const { +inline bool FileOptions::_internal_has_java_package() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool FileOptions::has_java_package() const { + return _internal_has_java_package(); +} inline void FileOptions::clear_java_package() { java_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& FileOptions::java_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package) - return java_package_.Get(); + return _internal_java_package(); } inline void FileOptions::set_java_package(const std::string& value) { + _internal_set_java_package(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) +} +inline std::string* FileOptions::mutable_java_package() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package) + return _internal_mutable_java_package(); +} +inline const std::string& FileOptions::_internal_java_package() const { + return java_package_.Get(); +} +inline void FileOptions::_internal_set_java_package(const std::string& value) { _has_bits_[0] |= 0x00000001u; java_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package) } inline void FileOptions::set_java_package(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -9417,9 +10111,8 @@ inline void FileOptions::set_java_package(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package) } -inline std::string* FileOptions::mutable_java_package() { +inline std::string* FileOptions::_internal_mutable_java_package() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package) return java_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_java_package() { @@ -9461,21 +10154,34 @@ inline void FileOptions::unsafe_arena_set_allocated_java_package( } // optional string java_outer_classname = 8; -inline bool FileOptions::has_java_outer_classname() const { +inline bool FileOptions::_internal_has_java_outer_classname() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool FileOptions::has_java_outer_classname() const { + return _internal_has_java_outer_classname(); +} inline void FileOptions::clear_java_outer_classname() { java_outer_classname_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& FileOptions::java_outer_classname() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname) - return java_outer_classname_.Get(); + return _internal_java_outer_classname(); } inline void FileOptions::set_java_outer_classname(const std::string& value) { + _internal_set_java_outer_classname(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) +} +inline std::string* FileOptions::mutable_java_outer_classname() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname) + return _internal_mutable_java_outer_classname(); +} +inline const std::string& FileOptions::_internal_java_outer_classname() const { + return java_outer_classname_.Get(); +} +inline void FileOptions::_internal_set_java_outer_classname(const std::string& value) { _has_bits_[0] |= 0x00000002u; java_outer_classname_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname) } inline void FileOptions::set_java_outer_classname(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -9497,9 +10203,8 @@ inline void FileOptions::set_java_outer_classname(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname) } -inline std::string* FileOptions::mutable_java_outer_classname() { +inline std::string* FileOptions::_internal_mutable_java_outer_classname() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname) return java_outer_classname_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_java_outer_classname() { @@ -9541,9 +10246,12 @@ inline void FileOptions::unsafe_arena_set_allocated_java_outer_classname( } // optional bool java_multiple_files = 10 [default = false]; -inline bool FileOptions::has_java_multiple_files() const { +inline bool FileOptions::_internal_has_java_multiple_files() const { return (_has_bits_[0] & 0x00000400u) != 0; } +inline bool FileOptions::has_java_multiple_files() const { + return _internal_has_java_multiple_files(); +} inline void FileOptions::clear_java_multiple_files() { java_multiple_files_ = false; _has_bits_[0] &= ~0x00000400u; @@ -9559,9 +10267,12 @@ 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 { +inline bool FileOptions::_internal_has_java_generate_equals_and_hash() const { return (_has_bits_[0] & 0x00000800u) != 0; } +inline bool FileOptions::has_java_generate_equals_and_hash() const { + return _internal_has_java_generate_equals_and_hash(); +} inline void FileOptions::clear_java_generate_equals_and_hash() { java_generate_equals_and_hash_ = false; _has_bits_[0] &= ~0x00000800u; @@ -9577,9 +10288,12 @@ 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 { +inline bool FileOptions::_internal_has_java_string_check_utf8() const { return (_has_bits_[0] & 0x00001000u) != 0; } +inline bool FileOptions::has_java_string_check_utf8() const { + return _internal_has_java_string_check_utf8(); +} inline void FileOptions::clear_java_string_check_utf8() { java_string_check_utf8_ = false; _has_bits_[0] &= ~0x00001000u; @@ -9595,9 +10309,12 @@ 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 { +inline bool FileOptions::_internal_has_optimize_for() const { return (_has_bits_[0] & 0x00080000u) != 0; } +inline bool FileOptions::has_optimize_for() const { + return _internal_has_optimize_for(); +} inline void FileOptions::clear_optimize_for() { optimize_for_ = 1; _has_bits_[0] &= ~0x00080000u; @@ -9614,21 +10331,34 @@ inline void FileOptions::set_optimize_for(PROTOBUF_NAMESPACE_ID::FileOptions_Opt } // optional string go_package = 11; -inline bool FileOptions::has_go_package() const { +inline bool FileOptions::_internal_has_go_package() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool FileOptions::has_go_package() const { + return _internal_has_go_package(); +} inline void FileOptions::clear_go_package() { go_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& FileOptions::go_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package) - return go_package_.Get(); + return _internal_go_package(); } inline void FileOptions::set_go_package(const std::string& value) { + _internal_set_go_package(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) +} +inline std::string* FileOptions::mutable_go_package() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package) + return _internal_mutable_go_package(); +} +inline const std::string& FileOptions::_internal_go_package() const { + return go_package_.Get(); +} +inline void FileOptions::_internal_set_go_package(const std::string& value) { _has_bits_[0] |= 0x00000004u; go_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package) } inline void FileOptions::set_go_package(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -9650,9 +10380,8 @@ inline void FileOptions::set_go_package(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package) } -inline std::string* FileOptions::mutable_go_package() { +inline std::string* FileOptions::_internal_mutable_go_package() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package) return go_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_go_package() { @@ -9694,9 +10423,12 @@ inline void FileOptions::unsafe_arena_set_allocated_go_package( } // optional bool cc_generic_services = 16 [default = false]; -inline bool FileOptions::has_cc_generic_services() const { +inline bool FileOptions::_internal_has_cc_generic_services() const { return (_has_bits_[0] & 0x00002000u) != 0; } +inline bool FileOptions::has_cc_generic_services() const { + return _internal_has_cc_generic_services(); +} inline void FileOptions::clear_cc_generic_services() { cc_generic_services_ = false; _has_bits_[0] &= ~0x00002000u; @@ -9712,9 +10444,12 @@ 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 { +inline bool FileOptions::_internal_has_java_generic_services() const { return (_has_bits_[0] & 0x00004000u) != 0; } +inline bool FileOptions::has_java_generic_services() const { + return _internal_has_java_generic_services(); +} inline void FileOptions::clear_java_generic_services() { java_generic_services_ = false; _has_bits_[0] &= ~0x00004000u; @@ -9730,9 +10465,12 @@ 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 { +inline bool FileOptions::_internal_has_py_generic_services() const { return (_has_bits_[0] & 0x00008000u) != 0; } +inline bool FileOptions::has_py_generic_services() const { + return _internal_has_py_generic_services(); +} inline void FileOptions::clear_py_generic_services() { py_generic_services_ = false; _has_bits_[0] &= ~0x00008000u; @@ -9748,9 +10486,12 @@ inline void FileOptions::set_py_generic_services(bool value) { } // optional bool php_generic_services = 42 [default = false]; -inline bool FileOptions::has_php_generic_services() const { +inline bool FileOptions::_internal_has_php_generic_services() const { return (_has_bits_[0] & 0x00010000u) != 0; } +inline bool FileOptions::has_php_generic_services() const { + return _internal_has_php_generic_services(); +} inline void FileOptions::clear_php_generic_services() { php_generic_services_ = false; _has_bits_[0] &= ~0x00010000u; @@ -9766,9 +10507,12 @@ inline void FileOptions::set_php_generic_services(bool value) { } // optional bool deprecated = 23 [default = false]; -inline bool FileOptions::has_deprecated() const { +inline bool FileOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00020000u) != 0; } +inline bool FileOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void FileOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00020000u; @@ -9784,9 +10528,12 @@ inline void FileOptions::set_deprecated(bool value) { } // optional bool cc_enable_arenas = 31 [default = false]; -inline bool FileOptions::has_cc_enable_arenas() const { +inline bool FileOptions::_internal_has_cc_enable_arenas() const { return (_has_bits_[0] & 0x00040000u) != 0; } +inline bool FileOptions::has_cc_enable_arenas() const { + return _internal_has_cc_enable_arenas(); +} inline void FileOptions::clear_cc_enable_arenas() { cc_enable_arenas_ = false; _has_bits_[0] &= ~0x00040000u; @@ -9802,21 +10549,34 @@ inline void FileOptions::set_cc_enable_arenas(bool value) { } // optional string objc_class_prefix = 36; -inline bool FileOptions::has_objc_class_prefix() const { +inline bool FileOptions::_internal_has_objc_class_prefix() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool FileOptions::has_objc_class_prefix() const { + return _internal_has_objc_class_prefix(); +} inline void FileOptions::clear_objc_class_prefix() { objc_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000008u; } inline const std::string& FileOptions::objc_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix) - return objc_class_prefix_.Get(); + return _internal_objc_class_prefix(); } inline void FileOptions::set_objc_class_prefix(const std::string& value) { + _internal_set_objc_class_prefix(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) +} +inline std::string* FileOptions::mutable_objc_class_prefix() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix) + return _internal_mutable_objc_class_prefix(); +} +inline const std::string& FileOptions::_internal_objc_class_prefix() const { + return objc_class_prefix_.Get(); +} +inline void FileOptions::_internal_set_objc_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000008u; objc_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix) } inline void FileOptions::set_objc_class_prefix(std::string&& value) { _has_bits_[0] |= 0x00000008u; @@ -9838,9 +10598,8 @@ inline void FileOptions::set_objc_class_prefix(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix) } -inline std::string* FileOptions::mutable_objc_class_prefix() { +inline std::string* FileOptions::_internal_mutable_objc_class_prefix() { _has_bits_[0] |= 0x00000008u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix) return objc_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_objc_class_prefix() { @@ -9882,21 +10641,34 @@ inline void FileOptions::unsafe_arena_set_allocated_objc_class_prefix( } // optional string csharp_namespace = 37; -inline bool FileOptions::has_csharp_namespace() const { +inline bool FileOptions::_internal_has_csharp_namespace() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool FileOptions::has_csharp_namespace() const { + return _internal_has_csharp_namespace(); +} inline void FileOptions::clear_csharp_namespace() { csharp_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000010u; } inline const std::string& FileOptions::csharp_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace) - return csharp_namespace_.Get(); + return _internal_csharp_namespace(); } inline void FileOptions::set_csharp_namespace(const std::string& value) { + _internal_set_csharp_namespace(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) +} +inline std::string* FileOptions::mutable_csharp_namespace() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) + return _internal_mutable_csharp_namespace(); +} +inline const std::string& FileOptions::_internal_csharp_namespace() const { + return csharp_namespace_.Get(); +} +inline void FileOptions::_internal_set_csharp_namespace(const std::string& value) { _has_bits_[0] |= 0x00000010u; csharp_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace) } inline void FileOptions::set_csharp_namespace(std::string&& value) { _has_bits_[0] |= 0x00000010u; @@ -9918,9 +10690,8 @@ inline void FileOptions::set_csharp_namespace(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace) } -inline std::string* FileOptions::mutable_csharp_namespace() { +inline std::string* FileOptions::_internal_mutable_csharp_namespace() { _has_bits_[0] |= 0x00000010u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace) return csharp_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_csharp_namespace() { @@ -9962,21 +10733,34 @@ inline void FileOptions::unsafe_arena_set_allocated_csharp_namespace( } // optional string swift_prefix = 39; -inline bool FileOptions::has_swift_prefix() const { +inline bool FileOptions::_internal_has_swift_prefix() const { return (_has_bits_[0] & 0x00000020u) != 0; } +inline bool FileOptions::has_swift_prefix() const { + return _internal_has_swift_prefix(); +} inline void FileOptions::clear_swift_prefix() { swift_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000020u; } inline const std::string& FileOptions::swift_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.swift_prefix) - return swift_prefix_.Get(); + return _internal_swift_prefix(); } inline void FileOptions::set_swift_prefix(const std::string& value) { + _internal_set_swift_prefix(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) +} +inline std::string* FileOptions::mutable_swift_prefix() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) + return _internal_mutable_swift_prefix(); +} +inline const std::string& FileOptions::_internal_swift_prefix() const { + return swift_prefix_.Get(); +} +inline void FileOptions::_internal_set_swift_prefix(const std::string& value) { _has_bits_[0] |= 0x00000020u; swift_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.swift_prefix) } inline void FileOptions::set_swift_prefix(std::string&& value) { _has_bits_[0] |= 0x00000020u; @@ -9998,9 +10782,8 @@ inline void FileOptions::set_swift_prefix(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.swift_prefix) } -inline std::string* FileOptions::mutable_swift_prefix() { +inline std::string* FileOptions::_internal_mutable_swift_prefix() { _has_bits_[0] |= 0x00000020u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.swift_prefix) return swift_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_swift_prefix() { @@ -10042,21 +10825,34 @@ inline void FileOptions::unsafe_arena_set_allocated_swift_prefix( } // optional string php_class_prefix = 40; -inline bool FileOptions::has_php_class_prefix() const { +inline bool FileOptions::_internal_has_php_class_prefix() const { return (_has_bits_[0] & 0x00000040u) != 0; } +inline bool FileOptions::has_php_class_prefix() const { + return _internal_has_php_class_prefix(); +} inline void FileOptions::clear_php_class_prefix() { php_class_prefix_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000040u; } inline const std::string& FileOptions::php_class_prefix() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_class_prefix) - return php_class_prefix_.Get(); + return _internal_php_class_prefix(); } inline void FileOptions::set_php_class_prefix(const std::string& value) { + _internal_set_php_class_prefix(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) +} +inline std::string* FileOptions::mutable_php_class_prefix() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) + return _internal_mutable_php_class_prefix(); +} +inline const std::string& FileOptions::_internal_php_class_prefix() const { + return php_class_prefix_.Get(); +} +inline void FileOptions::_internal_set_php_class_prefix(const std::string& value) { _has_bits_[0] |= 0x00000040u; php_class_prefix_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_class_prefix) } inline void FileOptions::set_php_class_prefix(std::string&& value) { _has_bits_[0] |= 0x00000040u; @@ -10078,9 +10874,8 @@ inline void FileOptions::set_php_class_prefix(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_class_prefix) } -inline std::string* FileOptions::mutable_php_class_prefix() { +inline std::string* FileOptions::_internal_mutable_php_class_prefix() { _has_bits_[0] |= 0x00000040u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_class_prefix) return php_class_prefix_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_php_class_prefix() { @@ -10122,21 +10917,34 @@ inline void FileOptions::unsafe_arena_set_allocated_php_class_prefix( } // optional string php_namespace = 41; -inline bool FileOptions::has_php_namespace() const { +inline bool FileOptions::_internal_has_php_namespace() const { return (_has_bits_[0] & 0x00000080u) != 0; } +inline bool FileOptions::has_php_namespace() const { + return _internal_has_php_namespace(); +} inline void FileOptions::clear_php_namespace() { php_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000080u; } inline const std::string& FileOptions::php_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_namespace) - return php_namespace_.Get(); + return _internal_php_namespace(); } inline void FileOptions::set_php_namespace(const std::string& value) { + _internal_set_php_namespace(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) +} +inline std::string* FileOptions::mutable_php_namespace() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace) + return _internal_mutable_php_namespace(); +} +inline const std::string& FileOptions::_internal_php_namespace() const { + return php_namespace_.Get(); +} +inline void FileOptions::_internal_set_php_namespace(const std::string& value) { _has_bits_[0] |= 0x00000080u; php_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_namespace) } inline void FileOptions::set_php_namespace(std::string&& value) { _has_bits_[0] |= 0x00000080u; @@ -10158,9 +10966,8 @@ inline void FileOptions::set_php_namespace(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_namespace) } -inline std::string* FileOptions::mutable_php_namespace() { +inline std::string* FileOptions::_internal_mutable_php_namespace() { _has_bits_[0] |= 0x00000080u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_namespace) return php_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_php_namespace() { @@ -10202,21 +11009,34 @@ inline void FileOptions::unsafe_arena_set_allocated_php_namespace( } // optional string php_metadata_namespace = 44; -inline bool FileOptions::has_php_metadata_namespace() const { +inline bool FileOptions::_internal_has_php_metadata_namespace() const { return (_has_bits_[0] & 0x00000100u) != 0; } +inline bool FileOptions::has_php_metadata_namespace() const { + return _internal_has_php_metadata_namespace(); +} inline void FileOptions::clear_php_metadata_namespace() { php_metadata_namespace_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000100u; } inline const std::string& FileOptions::php_metadata_namespace() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.php_metadata_namespace) - return php_metadata_namespace_.Get(); + return _internal_php_metadata_namespace(); } inline void FileOptions::set_php_metadata_namespace(const std::string& value) { + _internal_set_php_metadata_namespace(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace) +} +inline std::string* FileOptions::mutable_php_metadata_namespace() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_metadata_namespace) + return _internal_mutable_php_metadata_namespace(); +} +inline const std::string& FileOptions::_internal_php_metadata_namespace() const { + return php_metadata_namespace_.Get(); +} +inline void FileOptions::_internal_set_php_metadata_namespace(const std::string& value) { _has_bits_[0] |= 0x00000100u; php_metadata_namespace_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.php_metadata_namespace) } inline void FileOptions::set_php_metadata_namespace(std::string&& value) { _has_bits_[0] |= 0x00000100u; @@ -10238,9 +11058,8 @@ inline void FileOptions::set_php_metadata_namespace(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.php_metadata_namespace) } -inline std::string* FileOptions::mutable_php_metadata_namespace() { +inline std::string* FileOptions::_internal_mutable_php_metadata_namespace() { _has_bits_[0] |= 0x00000100u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.php_metadata_namespace) return php_metadata_namespace_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_php_metadata_namespace() { @@ -10282,21 +11101,34 @@ inline void FileOptions::unsafe_arena_set_allocated_php_metadata_namespace( } // optional string ruby_package = 45; -inline bool FileOptions::has_ruby_package() const { +inline bool FileOptions::_internal_has_ruby_package() const { return (_has_bits_[0] & 0x00000200u) != 0; } +inline bool FileOptions::has_ruby_package() const { + return _internal_has_ruby_package(); +} inline void FileOptions::clear_ruby_package() { ruby_package_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000200u; } inline const std::string& FileOptions::ruby_package() const { // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.ruby_package) - return ruby_package_.Get(); + return _internal_ruby_package(); } inline void FileOptions::set_ruby_package(const std::string& value) { + _internal_set_ruby_package(value); + // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package) +} +inline std::string* FileOptions::mutable_ruby_package() { + // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.ruby_package) + return _internal_mutable_ruby_package(); +} +inline const std::string& FileOptions::_internal_ruby_package() const { + return ruby_package_.Get(); +} +inline void FileOptions::_internal_set_ruby_package(const std::string& value) { _has_bits_[0] |= 0x00000200u; ruby_package_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.ruby_package) } inline void FileOptions::set_ruby_package(std::string&& value) { _has_bits_[0] |= 0x00000200u; @@ -10318,9 +11150,8 @@ inline void FileOptions::set_ruby_package(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.ruby_package) } -inline std::string* FileOptions::mutable_ruby_package() { +inline std::string* FileOptions::_internal_mutable_ruby_package() { _has_bits_[0] |= 0x00000200u; - // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.ruby_package) return ruby_package_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* FileOptions::release_ruby_package() { @@ -10396,9 +11227,12 @@ FileOptions::uninterpreted_option() const { // MessageOptions // optional bool message_set_wire_format = 1 [default = false]; -inline bool MessageOptions::has_message_set_wire_format() const { +inline bool MessageOptions::_internal_has_message_set_wire_format() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool MessageOptions::has_message_set_wire_format() const { + return _internal_has_message_set_wire_format(); +} inline void MessageOptions::clear_message_set_wire_format() { message_set_wire_format_ = false; _has_bits_[0] &= ~0x00000001u; @@ -10414,9 +11248,12 @@ inline void MessageOptions::set_message_set_wire_format(bool value) { } // optional bool no_standard_descriptor_accessor = 2 [default = false]; -inline bool MessageOptions::has_no_standard_descriptor_accessor() const { +inline bool MessageOptions::_internal_has_no_standard_descriptor_accessor() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool MessageOptions::has_no_standard_descriptor_accessor() const { + return _internal_has_no_standard_descriptor_accessor(); +} inline void MessageOptions::clear_no_standard_descriptor_accessor() { no_standard_descriptor_accessor_ = false; _has_bits_[0] &= ~0x00000002u; @@ -10432,9 +11269,12 @@ inline void MessageOptions::set_no_standard_descriptor_accessor(bool value) { } // optional bool deprecated = 3 [default = false]; -inline bool MessageOptions::has_deprecated() const { +inline bool MessageOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool MessageOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void MessageOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000004u; @@ -10450,9 +11290,12 @@ inline void MessageOptions::set_deprecated(bool value) { } // optional bool map_entry = 7; -inline bool MessageOptions::has_map_entry() const { +inline bool MessageOptions::_internal_has_map_entry() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool MessageOptions::has_map_entry() const { + return _internal_has_map_entry(); +} inline void MessageOptions::clear_map_entry() { map_entry_ = false; _has_bits_[0] &= ~0x00000008u; @@ -10502,9 +11345,12 @@ MessageOptions::uninterpreted_option() const { // FieldOptions // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; -inline bool FieldOptions::has_ctype() const { +inline bool FieldOptions::_internal_has_ctype() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool FieldOptions::has_ctype() const { + return _internal_has_ctype(); +} inline void FieldOptions::clear_ctype() { ctype_ = 0; _has_bits_[0] &= ~0x00000001u; @@ -10521,9 +11367,12 @@ inline void FieldOptions::set_ctype(PROTOBUF_NAMESPACE_ID::FieldOptions_CType va } // optional bool packed = 2; -inline bool FieldOptions::has_packed() const { +inline bool FieldOptions::_internal_has_packed() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool FieldOptions::has_packed() const { + return _internal_has_packed(); +} inline void FieldOptions::clear_packed() { packed_ = false; _has_bits_[0] &= ~0x00000002u; @@ -10539,9 +11388,12 @@ inline void FieldOptions::set_packed(bool value) { } // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; -inline bool FieldOptions::has_jstype() const { +inline bool FieldOptions::_internal_has_jstype() const { return (_has_bits_[0] & 0x00000020u) != 0; } +inline bool FieldOptions::has_jstype() const { + return _internal_has_jstype(); +} inline void FieldOptions::clear_jstype() { jstype_ = 0; _has_bits_[0] &= ~0x00000020u; @@ -10558,9 +11410,12 @@ inline void FieldOptions::set_jstype(PROTOBUF_NAMESPACE_ID::FieldOptions_JSType } // optional bool lazy = 5 [default = false]; -inline bool FieldOptions::has_lazy() const { +inline bool FieldOptions::_internal_has_lazy() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool FieldOptions::has_lazy() const { + return _internal_has_lazy(); +} inline void FieldOptions::clear_lazy() { lazy_ = false; _has_bits_[0] &= ~0x00000004u; @@ -10576,9 +11431,12 @@ inline void FieldOptions::set_lazy(bool value) { } // optional bool deprecated = 3 [default = false]; -inline bool FieldOptions::has_deprecated() const { +inline bool FieldOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool FieldOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void FieldOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000008u; @@ -10594,9 +11452,12 @@ inline void FieldOptions::set_deprecated(bool value) { } // optional bool weak = 10 [default = false]; -inline bool FieldOptions::has_weak() const { +inline bool FieldOptions::_internal_has_weak() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool FieldOptions::has_weak() const { + return _internal_has_weak(); +} inline void FieldOptions::clear_weak() { weak_ = false; _has_bits_[0] &= ~0x00000010u; @@ -10680,9 +11541,12 @@ OneofOptions::uninterpreted_option() const { // EnumOptions // optional bool allow_alias = 2; -inline bool EnumOptions::has_allow_alias() const { +inline bool EnumOptions::_internal_has_allow_alias() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool EnumOptions::has_allow_alias() const { + return _internal_has_allow_alias(); +} inline void EnumOptions::clear_allow_alias() { allow_alias_ = false; _has_bits_[0] &= ~0x00000001u; @@ -10698,9 +11562,12 @@ inline void EnumOptions::set_allow_alias(bool value) { } // optional bool deprecated = 3 [default = false]; -inline bool EnumOptions::has_deprecated() const { +inline bool EnumOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool EnumOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void EnumOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000002u; @@ -10750,9 +11617,12 @@ EnumOptions::uninterpreted_option() const { // EnumValueOptions // optional bool deprecated = 1 [default = false]; -inline bool EnumValueOptions::has_deprecated() const { +inline bool EnumValueOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool EnumValueOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void EnumValueOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000001u; @@ -10802,9 +11672,12 @@ EnumValueOptions::uninterpreted_option() const { // ServiceOptions // optional bool deprecated = 33 [default = false]; -inline bool ServiceOptions::has_deprecated() const { +inline bool ServiceOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool ServiceOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void ServiceOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000001u; @@ -10854,9 +11727,12 @@ ServiceOptions::uninterpreted_option() const { // MethodOptions // optional bool deprecated = 33 [default = false]; -inline bool MethodOptions::has_deprecated() const { +inline bool MethodOptions::_internal_has_deprecated() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool MethodOptions::has_deprecated() const { + return _internal_has_deprecated(); +} inline void MethodOptions::clear_deprecated() { deprecated_ = false; _has_bits_[0] &= ~0x00000001u; @@ -10872,9 +11748,12 @@ inline void MethodOptions::set_deprecated(bool value) { } // optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; -inline bool MethodOptions::has_idempotency_level() const { +inline bool MethodOptions::_internal_has_idempotency_level() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool MethodOptions::has_idempotency_level() const { + return _internal_has_idempotency_level(); +} inline void MethodOptions::clear_idempotency_level() { idempotency_level_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -10925,21 +11804,34 @@ MethodOptions::uninterpreted_option() const { // UninterpretedOption_NamePart // required string name_part = 1; -inline bool UninterpretedOption_NamePart::has_name_part() const { +inline bool UninterpretedOption_NamePart::_internal_has_name_part() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool UninterpretedOption_NamePart::has_name_part() const { + return _internal_has_name_part(); +} inline void UninterpretedOption_NamePart::clear_name_part() { name_part_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption_NamePart::name_part() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part) - return name_part_.Get(); + return _internal_name_part(); } inline void UninterpretedOption_NamePart::set_name_part(const std::string& value) { + _internal_set_name_part(value); + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) +} +inline std::string* UninterpretedOption_NamePart::mutable_name_part() { + // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) + return _internal_mutable_name_part(); +} +inline const std::string& UninterpretedOption_NamePart::_internal_name_part() const { + return name_part_.Get(); +} +inline void UninterpretedOption_NamePart::_internal_set_name_part(const std::string& value) { _has_bits_[0] |= 0x00000001u; name_part_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part) } inline void UninterpretedOption_NamePart::set_name_part(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -10961,9 +11853,8 @@ inline void UninterpretedOption_NamePart::set_name_part(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part) } -inline std::string* UninterpretedOption_NamePart::mutable_name_part() { +inline std::string* UninterpretedOption_NamePart::_internal_mutable_name_part() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part) return name_part_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* UninterpretedOption_NamePart::release_name_part() { @@ -11005,9 +11896,12 @@ inline void UninterpretedOption_NamePart::unsafe_arena_set_allocated_name_part( } // required bool is_extension = 2; -inline bool UninterpretedOption_NamePart::has_is_extension() const { +inline bool UninterpretedOption_NamePart::_internal_has_is_extension() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool UninterpretedOption_NamePart::has_is_extension() const { + return _internal_has_is_extension(); +} inline void UninterpretedOption_NamePart::clear_is_extension() { is_extension_ = false; _has_bits_[0] &= ~0x00000002u; @@ -11057,21 +11951,34 @@ UninterpretedOption::name() const { } // optional string identifier_value = 3; -inline bool UninterpretedOption::has_identifier_value() const { +inline bool UninterpretedOption::_internal_has_identifier_value() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool UninterpretedOption::has_identifier_value() const { + return _internal_has_identifier_value(); +} inline void UninterpretedOption::clear_identifier_value() { identifier_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& UninterpretedOption::identifier_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value) - return identifier_value_.Get(); + return _internal_identifier_value(); } inline void UninterpretedOption::set_identifier_value(const std::string& value) { + _internal_set_identifier_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) +} +inline std::string* UninterpretedOption::mutable_identifier_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value) + return _internal_mutable_identifier_value(); +} +inline const std::string& UninterpretedOption::_internal_identifier_value() const { + return identifier_value_.Get(); +} +inline void UninterpretedOption::_internal_set_identifier_value(const std::string& value) { _has_bits_[0] |= 0x00000001u; identifier_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value) } inline void UninterpretedOption::set_identifier_value(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -11093,9 +12000,8 @@ inline void UninterpretedOption::set_identifier_value(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value) } -inline std::string* UninterpretedOption::mutable_identifier_value() { +inline std::string* UninterpretedOption::_internal_mutable_identifier_value() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value) return identifier_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* UninterpretedOption::release_identifier_value() { @@ -11137,9 +12043,12 @@ inline void UninterpretedOption::unsafe_arena_set_allocated_identifier_value( } // optional uint64 positive_int_value = 4; -inline bool UninterpretedOption::has_positive_int_value() const { +inline bool UninterpretedOption::_internal_has_positive_int_value() const { return (_has_bits_[0] & 0x00000008u) != 0; } +inline bool UninterpretedOption::has_positive_int_value() const { + return _internal_has_positive_int_value(); +} inline void UninterpretedOption::clear_positive_int_value() { positive_int_value_ = PROTOBUF_ULONGLONG(0); _has_bits_[0] &= ~0x00000008u; @@ -11155,9 +12064,12 @@ inline void UninterpretedOption::set_positive_int_value(::PROTOBUF_NAMESPACE_ID: } // optional int64 negative_int_value = 5; -inline bool UninterpretedOption::has_negative_int_value() const { +inline bool UninterpretedOption::_internal_has_negative_int_value() const { return (_has_bits_[0] & 0x00000010u) != 0; } +inline bool UninterpretedOption::has_negative_int_value() const { + return _internal_has_negative_int_value(); +} inline void UninterpretedOption::clear_negative_int_value() { negative_int_value_ = PROTOBUF_LONGLONG(0); _has_bits_[0] &= ~0x00000010u; @@ -11173,9 +12085,12 @@ inline void UninterpretedOption::set_negative_int_value(::PROTOBUF_NAMESPACE_ID: } // optional double double_value = 6; -inline bool UninterpretedOption::has_double_value() const { +inline bool UninterpretedOption::_internal_has_double_value() const { return (_has_bits_[0] & 0x00000020u) != 0; } +inline bool UninterpretedOption::has_double_value() const { + return _internal_has_double_value(); +} inline void UninterpretedOption::clear_double_value() { double_value_ = 0; _has_bits_[0] &= ~0x00000020u; @@ -11191,21 +12106,34 @@ inline void UninterpretedOption::set_double_value(double value) { } // optional bytes string_value = 7; -inline bool UninterpretedOption::has_string_value() const { +inline bool UninterpretedOption::_internal_has_string_value() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool UninterpretedOption::has_string_value() const { + return _internal_has_string_value(); +} inline void UninterpretedOption::clear_string_value() { string_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& UninterpretedOption::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value) - return string_value_.Get(); + return _internal_string_value(); } inline void UninterpretedOption::set_string_value(const std::string& value) { + _internal_set_string_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) +} +inline std::string* UninterpretedOption::mutable_string_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value) + return _internal_mutable_string_value(); +} +inline const std::string& UninterpretedOption::_internal_string_value() const { + return string_value_.Get(); +} +inline void UninterpretedOption::_internal_set_string_value(const std::string& value) { _has_bits_[0] |= 0x00000002u; string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value) } inline void UninterpretedOption::set_string_value(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -11227,9 +12155,8 @@ inline void UninterpretedOption::set_string_value(const void* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value) } -inline std::string* UninterpretedOption::mutable_string_value() { +inline std::string* UninterpretedOption::_internal_mutable_string_value() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value) return string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* UninterpretedOption::release_string_value() { @@ -11271,21 +12198,34 @@ inline void UninterpretedOption::unsafe_arena_set_allocated_string_value( } // optional string aggregate_value = 8; -inline bool UninterpretedOption::has_aggregate_value() const { +inline bool UninterpretedOption::_internal_has_aggregate_value() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool UninterpretedOption::has_aggregate_value() const { + return _internal_has_aggregate_value(); +} inline void UninterpretedOption::clear_aggregate_value() { aggregate_value_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000004u; } inline const std::string& UninterpretedOption::aggregate_value() const { // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value) - return aggregate_value_.Get(); + return _internal_aggregate_value(); } inline void UninterpretedOption::set_aggregate_value(const std::string& value) { + _internal_set_aggregate_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) +} +inline std::string* UninterpretedOption::mutable_aggregate_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value) + return _internal_mutable_aggregate_value(); +} +inline const std::string& UninterpretedOption::_internal_aggregate_value() const { + return aggregate_value_.Get(); +} +inline void UninterpretedOption::_internal_set_aggregate_value(const std::string& value) { _has_bits_[0] |= 0x00000004u; aggregate_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value) } inline void UninterpretedOption::set_aggregate_value(std::string&& value) { _has_bits_[0] |= 0x00000004u; @@ -11307,9 +12247,8 @@ inline void UninterpretedOption::set_aggregate_value(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value) } -inline std::string* UninterpretedOption::mutable_aggregate_value() { +inline std::string* UninterpretedOption::_internal_mutable_aggregate_value() { _has_bits_[0] |= 0x00000004u; - // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value) return aggregate_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* UninterpretedOption::release_aggregate_value() { @@ -11415,21 +12354,34 @@ SourceCodeInfo_Location::mutable_span() { } // optional string leading_comments = 3; -inline bool SourceCodeInfo_Location::has_leading_comments() const { +inline bool SourceCodeInfo_Location::_internal_has_leading_comments() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool SourceCodeInfo_Location::has_leading_comments() const { + return _internal_has_leading_comments(); +} inline void SourceCodeInfo_Location::clear_leading_comments() { leading_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& SourceCodeInfo_Location::leading_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments) - return leading_comments_.Get(); + return _internal_leading_comments(); } inline void SourceCodeInfo_Location::set_leading_comments(const std::string& value) { + _internal_set_leading_comments(value); + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) +} +inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { + // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments) + return _internal_mutable_leading_comments(); +} +inline const std::string& SourceCodeInfo_Location::_internal_leading_comments() const { + return leading_comments_.Get(); +} +inline void SourceCodeInfo_Location::_internal_set_leading_comments(const std::string& value) { _has_bits_[0] |= 0x00000001u; leading_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments) } inline void SourceCodeInfo_Location::set_leading_comments(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -11451,9 +12403,8 @@ inline void SourceCodeInfo_Location::set_leading_comments(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments) } -inline std::string* SourceCodeInfo_Location::mutable_leading_comments() { +inline std::string* SourceCodeInfo_Location::_internal_mutable_leading_comments() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments) return leading_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* SourceCodeInfo_Location::release_leading_comments() { @@ -11495,21 +12446,34 @@ inline void SourceCodeInfo_Location::unsafe_arena_set_allocated_leading_comments } // optional string trailing_comments = 4; -inline bool SourceCodeInfo_Location::has_trailing_comments() const { +inline bool SourceCodeInfo_Location::_internal_has_trailing_comments() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool SourceCodeInfo_Location::has_trailing_comments() const { + return _internal_has_trailing_comments(); +} inline void SourceCodeInfo_Location::clear_trailing_comments() { trailing_comments_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000002u; } inline const std::string& SourceCodeInfo_Location::trailing_comments() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments) - return trailing_comments_.Get(); + return _internal_trailing_comments(); } inline void SourceCodeInfo_Location::set_trailing_comments(const std::string& value) { + _internal_set_trailing_comments(value); + // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) +} +inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { + // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments) + return _internal_mutable_trailing_comments(); +} +inline const std::string& SourceCodeInfo_Location::_internal_trailing_comments() const { + return trailing_comments_.Get(); +} +inline void SourceCodeInfo_Location::_internal_set_trailing_comments(const std::string& value) { _has_bits_[0] |= 0x00000002u; trailing_comments_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments) } inline void SourceCodeInfo_Location::set_trailing_comments(std::string&& value) { _has_bits_[0] |= 0x00000002u; @@ -11531,9 +12495,8 @@ inline void SourceCodeInfo_Location::set_trailing_comments(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments) } -inline std::string* SourceCodeInfo_Location::mutable_trailing_comments() { +inline std::string* SourceCodeInfo_Location::_internal_mutable_trailing_comments() { _has_bits_[0] |= 0x00000002u; - // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments) return trailing_comments_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* SourceCodeInfo_Location::release_trailing_comments() { @@ -11581,6 +12544,10 @@ inline int SourceCodeInfo_Location::leading_detached_comments_size() const { inline void SourceCodeInfo_Location::clear_leading_detached_comments() { leading_detached_comments_.Clear(); } +inline std::string* SourceCodeInfo_Location::add_leading_detached_comments() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) + return _internal_add_leading_detached_comments(); +} inline const std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) return leading_detached_comments_.Get(index); @@ -11607,8 +12574,7 @@ inline void SourceCodeInfo_Location::set_leading_detached_comments(int index, co reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) } -inline std::string* SourceCodeInfo_Location::add_leading_detached_comments() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments) +inline std::string* SourceCodeInfo_Location::_internal_add_leading_detached_comments() { return leading_detached_comments_.Add(); } inline void SourceCodeInfo_Location::add_leading_detached_comments(const std::string& value) { @@ -11708,21 +12674,34 @@ GeneratedCodeInfo_Annotation::mutable_path() { } // optional string source_file = 2; -inline bool GeneratedCodeInfo_Annotation::has_source_file() const { +inline bool GeneratedCodeInfo_Annotation::_internal_has_source_file() const { return (_has_bits_[0] & 0x00000001u) != 0; } +inline bool GeneratedCodeInfo_Annotation::has_source_file() const { + return _internal_has_source_file(); +} inline void GeneratedCodeInfo_Annotation::clear_source_file() { source_file_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); _has_bits_[0] &= ~0x00000001u; } inline const std::string& GeneratedCodeInfo_Annotation::source_file() const { // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file) - return source_file_.Get(); + return _internal_source_file(); } inline void GeneratedCodeInfo_Annotation::set_source_file(const std::string& value) { + _internal_set_source_file(value); + // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) +} +inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { + // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) + return _internal_mutable_source_file(); +} +inline const std::string& GeneratedCodeInfo_Annotation::_internal_source_file() const { + return source_file_.Get(); +} +inline void GeneratedCodeInfo_Annotation::_internal_set_source_file(const std::string& value) { _has_bits_[0] |= 0x00000001u; source_file_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } inline void GeneratedCodeInfo_Annotation::set_source_file(std::string&& value) { _has_bits_[0] |= 0x00000001u; @@ -11744,9 +12723,8 @@ inline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file) } -inline std::string* GeneratedCodeInfo_Annotation::mutable_source_file() { +inline std::string* GeneratedCodeInfo_Annotation::_internal_mutable_source_file() { _has_bits_[0] |= 0x00000001u; - // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file) return source_file_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* GeneratedCodeInfo_Annotation::release_source_file() { @@ -11788,9 +12766,12 @@ inline void GeneratedCodeInfo_Annotation::unsafe_arena_set_allocated_source_file } // optional int32 begin = 3; -inline bool GeneratedCodeInfo_Annotation::has_begin() const { +inline bool GeneratedCodeInfo_Annotation::_internal_has_begin() const { return (_has_bits_[0] & 0x00000002u) != 0; } +inline bool GeneratedCodeInfo_Annotation::has_begin() const { + return _internal_has_begin(); +} inline void GeneratedCodeInfo_Annotation::clear_begin() { begin_ = 0; _has_bits_[0] &= ~0x00000002u; @@ -11806,9 +12787,12 @@ inline void GeneratedCodeInfo_Annotation::set_begin(::PROTOBUF_NAMESPACE_ID::int } // optional int32 end = 4; -inline bool GeneratedCodeInfo_Annotation::has_end() const { +inline bool GeneratedCodeInfo_Annotation::_internal_has_end() const { return (_has_bits_[0] & 0x00000004u) != 0; } +inline bool GeneratedCodeInfo_Annotation::has_end() const { + return _internal_has_end(); +} inline void GeneratedCodeInfo_Annotation::clear_end() { end_ = 0; _has_bits_[0] &= ~0x00000004u; diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index fe6b02c40a..b613148d3d 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -38,7 +38,6 @@ #include #include - #include #include diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 568e983738..b315f26e8a 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -4535,8 +4535,7 @@ TEST_F(ValidationErrorTest, RequiredExtension) { " }" "}", - "foo.proto: Foo.foo: TYPE: Message extensions cannot have required " - "fields.\n"); + "foo.proto: Foo.foo: TYPE: The extension Foo.foo cannot be required.\n"); } TEST_F(ValidationErrorTest, UndefinedFieldType) { diff --git a/src/google/protobuf/duration.pb.cc b/src/google/protobuf/duration.pb.cc index 6f0cec796f..c029235ac4 100644 --- a/src/google/protobuf/duration.pb.cc +++ b/src/google/protobuf/duration.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto() } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Duration_google_2fprotobuf_2fduration_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Duration_google_2fprotobuf_2fduration_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fduration_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fduration_2eproto = nullptr; diff --git a/src/google/protobuf/duration.proto b/src/google/protobuf/duration.proto index 9d8a52de29..99cb102c35 100644 --- a/src/google/protobuf/duration.proto +++ b/src/google/protobuf/duration.proto @@ -61,7 +61,7 @@ option objc_class_prefix = "GPB"; // if (duration.seconds < 0 && duration.nanos > 0) { // duration.seconds += 1; // duration.nanos -= 1000000000; -// } else if (durations.seconds > 0 && duration.nanos < 0) { +// } else if (duration.seconds > 0 && duration.nanos < 0) { // duration.seconds -= 1; // duration.nanos += 1000000000; // } diff --git a/src/google/protobuf/empty.pb.cc b/src/google/protobuf/empty.pb.cc index caa48d04ac..a919ce0bca 100644 --- a/src/google/protobuf/empty.pb.cc +++ b/src/google/protobuf/empty.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Empty_google_2fprotobuf_2fempty_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Empty_google_2fprotobuf_2fempty_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fempty_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fempty_2eproto = nullptr; diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h index a7de200590..81de4a49ff 100644 --- a/src/google/protobuf/extension_set.h +++ b/src/google/protobuf/extension_set.h @@ -1334,7 +1334,7 @@ RepeatedMessageTypeTraits::GetDefaultRepeatedField() { // This is the type of actual extension objects. E.g. if you have: // extends Foo with optional int32 bar = 1234; // then "bar" will be defined in C++ as: -// ExtensionIdentifier, 1, false> bar(1234); +// ExtensionIdentifier, 5, false> bar(1234); // // Note that we could, in theory, supply the field number as a template // parameter, and thus make an instance of ExtensionIdentifier have no diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h index 9e15a17c4a..ec6efee39c 100644 --- a/src/google/protobuf/extension_set_inl.h +++ b/src/google/protobuf/extension_set_inl.h @@ -84,7 +84,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( #define HANDLE_VARINT_TYPE(UPPERCASE, CPP_CAMELCASE) \ case WireFormatLite::TYPE_##UPPERCASE: { \ uint64 value; \ - ptr = ParseVarint64(ptr, &value); \ + ptr = VarintParse(ptr, &value); \ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); \ if (extension.is_repeated) { \ Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ @@ -103,7 +103,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( #define HANDLE_SVARINT_TYPE(UPPERCASE, CPP_CAMELCASE, SIZE) \ case WireFormatLite::TYPE_##UPPERCASE: { \ uint64 val; \ - ptr = ParseVarint64(ptr, &val); \ + ptr = VarintParse(ptr, &val); \ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); \ auto value = WireFormatLite::ZigZagDecode##SIZE(val); \ if (extension.is_repeated) { \ @@ -120,8 +120,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( #undef HANDLE_SVARINT_TYPE #define HANDLE_FIXED_TYPE(UPPERCASE, CPP_CAMELCASE, CPPTYPE) \ case WireFormatLite::TYPE_##UPPERCASE: { \ - CPPTYPE value; \ - std::memcpy(&value, ptr, sizeof(CPPTYPE)); \ + auto value = UnalignedLoad(ptr); \ ptr += sizeof(CPPTYPE); \ if (extension.is_repeated) { \ Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \ @@ -143,7 +142,7 @@ const char* ExtensionSet::ParseFieldWithExtensionInfo( case WireFormatLite::TYPE_ENUM: { uint64 val; - ptr = ParseVarint64(ptr, &val); + ptr = VarintParse(ptr, &val); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); int value = val; @@ -213,7 +212,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(const char* ptr, uint32 tag = static_cast(*ptr++); if (tag == WireFormatLite::kMessageSetTypeIdTag) { uint64 tmp; - ptr = ParseVarint64Inline(ptr, &tmp); + ptr = ParseBigVarint(ptr, &tmp); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); type_id = tmp; if (!payload.empty()) { @@ -257,13 +256,7 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(const char* ptr, GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); } } else { - if (tag >= 128) { - // Parse remainder of tag varint - uint32 tmp; - ptr = VarintParse<4>(ptr, &tmp); - GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - tag += (tmp - 1) << 7; - } + ptr = ReadTag(ptr - 1, &tag); if (tag == 0 || (tag & 7) == 4) { ctx->SetLastTag(tag); return ptr; diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 6dd6f7d8f5..c08782b589 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -33,7 +33,6 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include - #include #include #include diff --git a/src/google/protobuf/field_mask.pb.cc b/src/google/protobuf/field_mask.pb.cc index 57619091f5..9c83c8cb87 100644 --- a/src/google/protobuf/field_mask.pb.cc +++ b/src/google/protobuf/field_mask.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2epr } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_FieldMask_google_2fprotobuf_2ffield_5fmask_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ffield_5fmask_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ffield_5fmask_2eproto = nullptr; @@ -162,10 +162,10 @@ const char* FieldMask::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(add_paths(), ptr, ctx, "google.protobuf.FieldMask.paths"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_add_paths(), ptr, ctx, "google.protobuf.FieldMask.paths"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -202,10 +202,10 @@ bool FieldMask::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_paths())); + input, this->_internal_add_paths())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->paths(this->paths_size() - 1).data(), - static_cast(this->paths(this->paths_size() - 1).length()), + paths_.Get(paths_.size() - 1).data(), + static_cast(paths_.Get(paths_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.FieldMask.paths")); } else { @@ -242,8 +242,8 @@ failure: (void) cached_has_bits; // repeated string paths = 1; - for (auto it = this->paths().pointer_begin(), - end = this->paths().pointer_end(); it < end; ++it) { + for (auto it = paths_.pointer_begin(), + end = paths_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( s.data(), static_cast(s.length()), @@ -270,10 +270,10 @@ size_t FieldMask::ByteSizeLong() const { // repeated string paths = 1; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->paths_size()); - for (int i = 0, n = this->paths_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(paths_.size()); + for (int i = 0, n = paths_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->paths(i)); + paths_.Get(i)); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -331,7 +331,7 @@ bool FieldMask::IsInitialized() const { void FieldMask::InternalSwap(FieldMask* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - paths_.InternalSwap(CastToBase(&other->paths_)); + paths_.InternalSwap(&other->paths_); } ::PROTOBUF_NAMESPACE_ID::Metadata FieldMask::GetMetadata() const { diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 44160db43d..d4937ec590 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -215,6 +215,9 @@ class PROTOBUF_EXPORT FieldMask : void add_paths(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& paths() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_paths(); + private: + std::string* _internal_add_paths(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.FieldMask) private: @@ -246,6 +249,10 @@ inline int FieldMask::paths_size() const { inline void FieldMask::clear_paths() { paths_.Clear(); } +inline std::string* FieldMask::add_paths() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths) + return _internal_add_paths(); +} inline const std::string& FieldMask::paths(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths) return paths_.Get(index); @@ -272,8 +279,7 @@ inline void FieldMask::set_paths(int index, const char* value, size_t size) { reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths) } -inline std::string* FieldMask::add_paths() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths) +inline std::string* FieldMask::_internal_add_paths() { return paths_.Add(); } inline void FieldMask::add_paths(const std::string& value) { diff --git a/src/google/protobuf/generated_message_reflection.h b/src/google/protobuf/generated_message_reflection.h index f61dce4091..cbfab5e1c7 100644 --- a/src/google/protobuf/generated_message_reflection.h +++ b/src/google/protobuf/generated_message_reflection.h @@ -69,7 +69,6 @@ struct Metadata; } // namespace protobuf } // namespace google - namespace google { namespace protobuf { namespace internal { diff --git a/src/google/protobuf/generated_message_util.cc b/src/google/protobuf/generated_message_util.cc index 6cf87aa2ef..bdeabddf3c 100644 --- a/src/google/protobuf/generated_message_util.cc +++ b/src/google/protobuf/generated_message_util.cc @@ -44,19 +44,18 @@ #include -#include #include +#include #include #include #include #include #include #include +#include #include #include -#include - namespace google { namespace protobuf { @@ -766,10 +765,19 @@ void InitSCC_DFS(SCCInfoBase* scc) { SCCInfoBase::kUninitialized) return; scc->visit_status.store(SCCInfoBase::kRunning, std::memory_order_relaxed); - // Each base is followed by an array of pointers to deps - auto deps = reinterpret_cast(scc + 1); - for (int i = 0; i < scc->num_deps; i++) { - if (deps[i]) InitSCC_DFS(deps[i]); + // Each base is followed by an array of void*, containing first pointers to + // SCCInfoBase and then pointers-to-pointers to SCCInfoBase. + auto deps = reinterpret_cast(scc + 1); + auto strong_deps = reinterpret_cast(deps); + for (int i = 0; i < scc->num_deps; ++i) { + if (strong_deps[i]) InitSCC_DFS(strong_deps[i]); + } + auto implicit_weak_deps = + reinterpret_cast(deps + scc->num_deps); + for (int i = 0; i < scc->num_implicit_weak_deps; ++i) { + if (*implicit_weak_deps[i]) { + InitSCC_DFS(*implicit_weak_deps[i]); + } } scc->init_func(); // Mark done (note we use memory order release here), other threads could diff --git a/src/google/protobuf/generated_message_util.h b/src/google/protobuf/generated_message_util.h index 4e8ad9142f..ecb8c0a67c 100644 --- a/src/google/protobuf/generated_message_util.h +++ b/src/google/protobuf/generated_message_util.h @@ -197,21 +197,35 @@ struct PROTOBUF_EXPORT SCCInfoBase { std::atomic visit_status; #endif int num_deps; + int num_implicit_weak_deps; void (*init_func)(); // This is followed by an array of num_deps // const SCCInfoBase* deps[]; }; +// Zero-length arrays are a language extension available in GCC and Clang but +// not MSVC. +#ifdef __GNUC__ +#define PROTOBUF_ARRAY_SIZE(n) (n) +#else +#define PROTOBUF_ARRAY_SIZE(n) ((n) ? (n) : 1) +#endif + template struct SCCInfo { SCCInfoBase base; // Semantically this is const SCCInfo* which is is a templated type. // The obvious inheriting from SCCInfoBase mucks with struct initialization. // Attempts showed the compiler was generating dynamic initialization code. - // Zero length arrays produce warnings with MSVC. - SCCInfoBase* deps[N ? N : 1]; + // This deps array consists of base.num_deps pointers to SCCInfoBase followed + // by base.num_implicit_weak_deps pointers to SCCInfoBase*. We need the extra + // pointer indirection for implicit weak fields. We cannot use a union type + // here, since that would prevent the array from being linker-initialized. + void* deps[PROTOBUF_ARRAY_SIZE(N)]; }; +#undef PROTOBUF_ARRAY_SIZE + PROTOBUF_EXPORT void InitSCCImpl(SCCInfoBase* scc); inline void InitSCC(SCCInfoBase* scc) { diff --git a/src/google/protobuf/implicit_weak_message.h b/src/google/protobuf/implicit_weak_message.h index a0cb1c179f..10d430cd07 100644 --- a/src/google/protobuf/implicit_weak_message.h +++ b/src/google/protobuf/implicit_weak_message.h @@ -32,16 +32,18 @@ #define GOOGLE_PROTOBUF_IMPLICIT_WEAK_MESSAGE_H__ #include + #include #include #include - -#include +#include #ifdef SWIG #error "You cannot SWIG proto headers" #endif +#include + // This file is logically internal-only and should only be used by protobuf // generated code. @@ -104,15 +106,9 @@ class PROTOBUF_EXPORT ImplicitWeakMessage : public MessageLite { template class ImplicitWeakTypeHandler { public: - typedef ImplicitWeakType Type; - typedef MessageLite WeakType; + typedef MessageLite Type; static const bool Moveable = false; - // With implicit weak fields, we need separate NewFromPrototype and - // NewFromPrototypeWeak functions. The former is used when we want to create a - // strong dependency on the message type, and it just delegates to the - // GenericTypeHandler. The latter avoids creating a strong dependency, by - // simply calling MessageLite::New. static inline MessageLite* NewFromPrototype(const MessageLite* prototype, Arena* arena = NULL) { return prototype->New(arena); @@ -133,12 +129,66 @@ class ImplicitWeakTypeHandler { static void Merge(const MessageLite& from, MessageLite* to) { to->CheckTypeAndMergeFrom(from); } - static inline size_t SpaceUsedLong(const Type& value) { - return value.SpaceUsedLong(); - } }; } // namespace internal + +template +struct WeakRepeatedPtrField { + using TypeHandler = internal::ImplicitWeakTypeHandler; + WeakRepeatedPtrField() : weak() {} + explicit WeakRepeatedPtrField(Arena* arena) : weak(arena) {} + ~WeakRepeatedPtrField() { weak.template Destroy(); } + + typedef internal::RepeatedPtrIterator iterator; + typedef internal::RepeatedPtrIterator const_iterator; + typedef internal::RepeatedPtrOverPtrsIterator + pointer_iterator; + typedef internal::RepeatedPtrOverPtrsIterator + const_pointer_iterator; + + iterator begin() { return iterator(base().raw_data()); } + const_iterator begin() const { return iterator(base().raw_data()); } + const_iterator cbegin() const { return begin(); } + iterator end() { return begin() + base().size(); } + const_iterator end() const { return begin() + base().size(); } + const_iterator cend() const { return end(); } + pointer_iterator pointer_begin() { + return pointer_iterator(base().raw_mutable_data()); + } + const_pointer_iterator pointer_begin() const { + return const_pointer_iterator(base().raw_mutable_data()); + } + pointer_iterator pointer_end() { + return pointer_iterator(base().raw_mutable_data() + base().size()); + } + const_pointer_iterator pointer_end() const { + return const_pointer_iterator(base().raw_mutable_data() + base().size()); + } + + MessageLite* AddWeak(const MessageLite* prototype) { + return base().AddWeak(prototype); + } + T* Add() { return weak.Add(); } + void Clear() { base().template Clear(); } + void MergeFrom(const WeakRepeatedPtrField& other) { + base().template MergeFrom(other.base()); + } + void InternalSwap(WeakRepeatedPtrField* other) { + base().InternalSwap(&other->base()); + } + + const internal::RepeatedPtrFieldBase& base() const { return weak; } + internal::RepeatedPtrFieldBase& base() { return weak; } + // Union disables running the destructor. Which would create a strong link. + // Instead we explicitly destroy the underlying base through the virtual + // destructor. + union { + RepeatedPtrField weak; + }; +}; + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc index f04dc1db2e..003858aef4 100644 --- a/src/google/protobuf/io/coded_stream.cc +++ b/src/google/protobuf/io/coded_stream.cc @@ -48,9 +48,9 @@ #include #include -#include -#include #include +#include +#include #include @@ -190,12 +190,13 @@ int CodedInputStream::BytesUntilTotalBytesLimit() const { } void CodedInputStream::PrintTotalBytesLimitError() { - GOOGLE_LOG(ERROR) << "A protocol message was rejected because it was too " - "big (more than " - << total_bytes_limit_ - << " bytes). To increase the limit (or to disable these " - "warnings), see CodedInputStream::SetTotalBytesLimit() " - "in net/proto2/io/public/coded_stream.h."; + GOOGLE_LOG(ERROR) + << "A protocol message was rejected because it was too " + "big (more than " + << total_bytes_limit_ + << " bytes). To increase the limit (or to disable these " + "warnings), see CodedInputStream::SetTotalBytesLimit() " + "in third_party/protobuf/src/google/protobuf/io/coded_stream.h."; } bool CodedInputStream::SkipFallback(int count, int original_buffer_size) { @@ -238,12 +239,39 @@ bool CodedInputStream::GetDirectBufferPointer(const void** data, int* size) { } bool CodedInputStream::ReadRaw(void* buffer, int size) { - return InternalReadRawInline(buffer, size); + int current_buffer_size; + while ((current_buffer_size = BufferSize()) < size) { + // Reading past end of buffer. Copy what we have, then refresh. + memcpy(buffer, buffer_, current_buffer_size); + buffer = reinterpret_cast(buffer) + current_buffer_size; + size -= current_buffer_size; + Advance(current_buffer_size); + if (!Refresh()) return false; + } + + memcpy(buffer, buffer_, size); + Advance(size); + + return true; } bool CodedInputStream::ReadString(std::string* buffer, int size) { if (size < 0) return false; // security: size is often user-supplied - return InternalReadStringInline(buffer, size); + + if (BufferSize() >= size) { + STLStringResizeUninitialized(buffer, size); + std::pair z = as_string_data(buffer); + if (z.second) { + // Oddly enough, memcpy() requires its first two args to be non-NULL even + // if we copy 0 bytes. So, we have ensured that z.first is non-NULL here. + GOOGLE_DCHECK(z.first != NULL); + memcpy(z.first, buffer_, size); + Advance(size); + } + return true; + } + + return ReadStringFallback(buffer, size); } bool CodedInputStream::ReadStringFallback(std::string* buffer, int size) { diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index c620d89c63..fd75850fe9 100755 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -139,8 +139,8 @@ #endif #include #include -#include #include +#include #include @@ -219,17 +219,8 @@ class PROTOBUF_EXPORT CodedInputStream { // Read raw bytes, copying them into the given buffer. bool ReadRaw(void* buffer, int size); - // Like the above, with inlined optimizations. This should only be used - // by the protobuf implementation. - PROTOBUF_ALWAYS_INLINE - bool InternalReadRawInline(void* buffer, int size); - // Like ReadRaw, but reads into a string. bool ReadString(std::string* buffer, int size); - // Like the above, with inlined optimizations. This should only be used - // by the protobuf implementation. - PROTOBUF_ALWAYS_INLINE - bool InternalReadStringInline(std::string* buffer, int size); // Read a 32-bit little-endian integer. @@ -814,37 +805,12 @@ class PROTOBUF_EXPORT EpsCopyOutputStream { // remains live until all of the data has been consumed from the stream. void EnableAliasing(bool enabled); - // Deterministic serialization, if requested, guarantees that for a given - // binary, equal messages will always be serialized to the same bytes. This - // implies: - // . repeated serialization of a message will return the same bytes - // . different processes of the same binary (which may be executing on - // different machines) will serialize equal messages to the same bytes. - // - // Note the deterministic serialization is NOT canonical across languages; it - // is also unstable across different builds with schema changes due to unknown - // fields. Users who need canonical serialization, e.g., persistent storage in - // a canonical form, fingerprinting, etc., should define their own - // canonicalization specification and implement the serializer using - // reflection APIs rather than relying on this API. - // - // If deterministic serialization is requested, the serializer will - // sort map entries by keys in lexicographical order or numerical order. - // (This is an implementation detail and may subject to change.) - // - // There are two ways to determine whether serialization should be - // deterministic for this CodedOutputStream. If SetSerializationDeterministic - // has not yet been called, then the default comes from the global default, - // which is false, until SetDefaultSerializationDeterministic has been called. - // Otherwise, SetSerializationDeterministic has been called, and the last - // value passed to it is all that matters. + // See documentation on CodedOutputStream::SetSerializationDeterministic. void SetSerializationDeterministic(bool value) { is_serialization_deterministic_ = value; } - // See above. Also, note that users of this CodedOutputStream may need to - // call IsSerializationDeterministic() to serialize in the intended way. This - // CodedOutputStream cannot enforce a desire for deterministic serialization - // by itself. + + // See documentation on CodedOutputStream::IsSerializationDeterministic. bool IsSerializationDeterministic() const { return is_serialization_deterministic_; } @@ -1233,14 +1199,32 @@ class PROTOBUF_EXPORT CodedOutputStream { // remains live until all of the data has been consumed from the stream. void EnableAliasing(bool enabled) { impl_.EnableAliasing(enabled); } + // Indicate to the serializer whether the user wants derministic + // serialization. The default when this is not called comes from the global + // default, controlled by SetDefaultSerializationDeterministic. + // + // What deterministic serialization means is entirely up to the driver of the + // serialization process (i.e. the caller of methods like WriteVarint32). In + // the case of serializing a proto buffer message using one of the methods of + // MessageLite, this means that for a given binary equal messages will always + // be serialized to the same bytes. This implies: + // + // * Repeated serialization of a message will return the same bytes. + // + // * Different processes running the same binary (including on different + // machines) will serialize equal messages to the same bytes. + // + // Note that this is *not* canonical across languages. It is also unstable + // across different builds with intervening message definition changes, due to + // unknown fields. Users who need canonical serialization (e.g. persistent + // storage in a canonical form, fingerprinting) should define their own + // canonicalization specification and implement the serializer using + // reflection APIs rather than relying on this API. void SetSerializationDeterministic(bool value) { impl_.SetSerializationDeterministic(value); } - // See above. Also, note that users of this CodedOutputStream may need to - // call IsSerializationDeterministic() to serialize in the intended way. This - // CodedOutputStream cannot enforce a desire for deterministic serialization - // by itself. + // Return whether the user wants deterministic serialization. See above. bool IsSerializationDeterministic() const { return impl_.IsSerializationDeterministic(); } diff --git a/src/google/protobuf/io/coded_stream_inl.h b/src/google/protobuf/io/coded_stream_inl.h deleted file mode 100644 index 0c10e65546..0000000000 --- a/src/google/protobuf/io/coded_stream_inl.h +++ /dev/null @@ -1,90 +0,0 @@ -// 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. - -// Author: jasonh@google.com (Jason Hsueh) -// -// Implements methods of coded_stream.h that need to be inlined for performance -// reasons, but should not be defined in a public header. - -#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ -#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ - -#include -#include -#include -#include -#include -#include - -namespace google { -namespace protobuf { -namespace io { - -inline bool CodedInputStream::InternalReadStringInline(std::string* buffer, - int size) { - if (size < 0) return false; // security: size is often user-supplied - - if (BufferSize() >= size) { - STLStringResizeUninitialized(buffer, size); - std::pair z = as_string_data(buffer); - if (z.second) { - // Oddly enough, memcpy() requires its first two args to be non-NULL even - // if we copy 0 bytes. So, we have ensured that z.first is non-NULL here. - GOOGLE_DCHECK(z.first != NULL); - memcpy(z.first, buffer_, size); - Advance(size); - } - return true; - } - - return ReadStringFallback(buffer, size); -} - -inline bool CodedInputStream::InternalReadRawInline(void* buffer, int size) { - int current_buffer_size; - while ((current_buffer_size = BufferSize()) < size) { - // Reading past end of buffer. Copy what we have, then refresh. - memcpy(buffer, buffer_, current_buffer_size); - buffer = reinterpret_cast(buffer) + current_buffer_size; - size -= current_buffer_size; - Advance(current_buffer_size); - if (!Refresh()) return false; - } - - memcpy(buffer, buffer_, size); - Advance(size); - - return true; -} - -} // namespace io -} // namespace protobuf -} // namespace google -#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index 52b7a7bada..6018132aac 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -34,13 +34,13 @@ // // This file contains tests and benchmarks. -#include -#include - #include #include +#include +#include + #include #include #include diff --git a/src/google/protobuf/io/io_win32.cc b/src/google/protobuf/io/io_win32.cc index 5999fac0dd..dcbdde4f36 100755 --- a/src/google/protobuf/io/io_win32.cc +++ b/src/google/protobuf/io/io_win32.cc @@ -49,12 +49,13 @@ // debug failing tests if that's caused by the long path support. #define SUPPORT_LONGPATHS +#include + #include #include #include #include #include -#include #include #include #include @@ -65,8 +66,6 @@ #include -#include - #include #include #include diff --git a/src/google/protobuf/io/io_win32.h b/src/google/protobuf/io/io_win32.h index 775252b35b..f72cd22892 100755 --- a/src/google/protobuf/io/io_win32.h +++ b/src/google/protobuf/io/io_win32.h @@ -51,6 +51,7 @@ #include #include + #include #include diff --git a/src/google/protobuf/io/io_win32_unittest.cc b/src/google/protobuf/io/io_win32_unittest.cc index be2101e04c..09812a15df 100755 --- a/src/google/protobuf/io/io_win32_unittest.cc +++ b/src/google/protobuf/io/io_win32_unittest.cc @@ -40,6 +40,8 @@ #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN +#include + #include #include #include @@ -49,14 +51,13 @@ #include #include -#include -#include - #include #include #include #include +#include + namespace google { namespace protobuf { namespace io { diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index 6a86c58c1a..f8d4d2b1f9 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -32,11 +32,12 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include #include -#include #include namespace google { diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h old mode 100644 new mode 100755 index a55946e929..b3e6abf6d2 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -40,8 +40,8 @@ #include #include #include -#include +#include #include namespace google { @@ -53,7 +53,7 @@ class ZeroCopyOutputStream; // zero_copy_stream.h // Records annotations about a Printer's output. class PROTOBUF_EXPORT AnnotationCollector { public: - // Annotation is a ofset range and a payload pair. + // Annotation is a offset range and a payload pair. typedef std::pair, std::string> Annotation; // Records that the bytes in file_path beginning with begin_offset and ending diff --git a/src/google/protobuf/io/printer_unittest.cc b/src/google/protobuf/io/printer_unittest.cc index b847fa70dc..ca45d67813 100644 --- a/src/google/protobuf/io/printer_unittest.cc +++ b/src/google/protobuf/io/printer_unittest.cc @@ -32,16 +32,16 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. -#include - #include -#include -#include + +#include #include #include +#include #include #include +#include namespace google { namespace protobuf { diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc index f8cf2ebd1a..ff839467cb 100644 --- a/src/google/protobuf/io/tokenizer.cc +++ b/src/google/protobuf/io/tokenizer.cc @@ -89,12 +89,13 @@ // exactly pretty. #include + #include #include #include +#include #include #include -#include #include namespace google { diff --git a/src/google/protobuf/io/tokenizer.h b/src/google/protobuf/io/tokenizer.h index cb33b931c9..f2e16979aa 100644 --- a/src/google/protobuf/io/tokenizer.h +++ b/src/google/protobuf/io/tokenizer.h @@ -39,9 +39,9 @@ #include #include + #include #include - #include namespace google { diff --git a/src/google/protobuf/io/tokenizer_unittest.cc b/src/google/protobuf/io/tokenizer_unittest.cc index 37628ab2f9..82c283c040 100644 --- a/src/google/protobuf/io/tokenizer_unittest.cc +++ b/src/google/protobuf/io/tokenizer_unittest.cc @@ -32,18 +32,18 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include #include -#include -#include - #include #include #include #include +#include #include #include diff --git a/src/google/protobuf/io/zero_copy_stream.h b/src/google/protobuf/io/zero_copy_stream.h index de2374b513..6be63cf9d4 100644 --- a/src/google/protobuf/io/zero_copy_stream.h +++ b/src/google/protobuf/io/zero_copy_stream.h @@ -108,8 +108,8 @@ #define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__ #include -#include +#include #include @@ -117,6 +117,10 @@ namespace google { namespace protobuf { namespace io { +// TODO(b/136291652): remove once we have switched the default to int64_t and +// updated everyone who derives from this class. +using ByteCountInt64 = int64_t; + // Defined in this file. class ZeroCopyInputStream; class ZeroCopyOutputStream; @@ -171,7 +175,7 @@ class PROTOBUF_EXPORT ZeroCopyInputStream { virtual bool Skip(int count) = 0; // Returns the total number of bytes read since this object was created. - virtual int64 ByteCount() const = 0; + virtual ByteCountInt64 ByteCount() const = 0; private: @@ -226,7 +230,7 @@ class PROTOBUF_EXPORT ZeroCopyOutputStream { virtual void BackUp(int count) = 0; // Returns the total number of bytes written since this object was created. - virtual int64 ByteCount() const = 0; + virtual ByteCountInt64 ByteCount() const = 0; // Write a given chunk of data to the output. Some output streams may // implement this in a way that avoids copying. Check AllowsAliasing() before diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc index 4af76b786e..f3004e492a 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.cc +++ b/src/google/protobuf/io/zero_copy_stream_impl.cc @@ -39,8 +39,10 @@ #include #endif #include + #include #include + #include #include #include diff --git a/src/google/protobuf/io/zero_copy_stream_impl.h b/src/google/protobuf/io/zero_copy_stream_impl.h index fd06c06cc2..46a8fae148 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl.h +++ b/src/google/protobuf/io/zero_copy_stream_impl.h @@ -42,6 +42,7 @@ #include #include + #include #include #include diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/src/google/protobuf/io/zero_copy_stream_impl_lite.h index ebb20176e3..b8f387f730 100644 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h @@ -47,6 +47,7 @@ #include #include #include + #include #include #include diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index 5f7b6104b9..bec9df0af6 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -55,13 +55,14 @@ #include #include #include + #include #include #include #include -#include #include +#include #include #if HAVE_ZLIB diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index b633969615..71ab6417af 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -446,47 +446,33 @@ const char* MapTypeHandler::Read( } inline const char* ReadINT64(const char* ptr, int64* value) { - return ParseVarint64(ptr, reinterpret_cast(value)); + return VarintParse(ptr, reinterpret_cast(value)); } inline const char* ReadUINT64(const char* ptr, uint64* value) { - return ParseVarint64(ptr, value); + return VarintParse(ptr, value); } inline const char* ReadINT32(const char* ptr, int32* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = static_cast(tmp); - return res; + return VarintParse(ptr, reinterpret_cast(value)); } inline const char* ReadUINT32(const char* ptr, uint32* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = static_cast(tmp); - return res; + return VarintParse(ptr, value); } inline const char* ReadSINT64(const char* ptr, int64* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = WireFormatLite::ZigZagDecode64(tmp); - return res; + *value = ReadVarintZigZag64(&ptr); + return ptr; } inline const char* ReadSINT32(const char* ptr, int32* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = WireFormatLite::ZigZagDecode32(static_cast(tmp)); - return res; + *value = ReadVarintZigZag32(&ptr); + return ptr; } template inline const char* ReadENUM(const char* ptr, E* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = static_cast(tmp); - return res; + *value = static_cast(ReadVarint(&ptr)); + return ptr; } inline const char* ReadBOOL(const char* ptr, bool* value) { - uint64 tmp; - auto res = ParseVarint64(ptr, &tmp); - *value = static_cast(tmp); - return res; + *value = static_cast(ReadVarint(&ptr)); + return ptr; } template diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index ab7f5a2df6..af1c74906e 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -56,7 +56,6 @@ #include #include #include - #include #include #include diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 2babba0b65..4b51affb3e 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -51,7 +51,6 @@ #include #include #include - #include #include diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 949e200e95..1da0d117c6 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -446,21 +446,6 @@ class PROTOBUF_EXPORT MessageLite { #endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER protected: - // CastToBase allows generated code to cast a RepeatedPtrField to - // RepeatedPtrFieldBase. We try to restrict access to RepeatedPtrFieldBase - // because it is an implementation detail that user code should not access - // directly. - template - static internal::RepeatedPtrFieldBase* CastToBase( - RepeatedPtrField* repeated) { - return repeated; - } - template - static const internal::RepeatedPtrFieldBase& CastToBase( - const RepeatedPtrField& repeated) { - return repeated; - } - template static T* CreateMaybeMessage(Arena* arena) { return Arena::CreateMaybeMessage(arena); diff --git a/src/google/protobuf/message_unittest.inc b/src/google/protobuf/message_unittest.inc index e92171f624..93fcb5e4e5 100644 --- a/src/google/protobuf/message_unittest.inc +++ b/src/google/protobuf/message_unittest.inc @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ #include #include #include +#include namespace google { diff --git a/src/google/protobuf/parse_context.cc b/src/google/protobuf/parse_context.cc index d514079e9f..17d645331b 100644 --- a/src/google/protobuf/parse_context.cc +++ b/src/google/protobuf/parse_context.cc @@ -64,7 +64,7 @@ bool ParseEndsInSlopRegion(const char* begin, int overrun, int d) { switch (tag & 7) { case 0: { // Varint uint64 val; - ptr = ParseVarint64(ptr, &val); + ptr = VarintParse(ptr, &val); if (ptr == nullptr) return false; break; } @@ -232,6 +232,19 @@ const char* EpsCopyInputStream::ReadRepeatedFixed(const char* ptr, return ptr; } +template +void byteswap(void* p); +template <> +void byteswap<1>(void* p) {} +template <> +void byteswap<4>(void* p) { + *static_cast(p) = bswap_32(*static_cast(p)); +} +template <> +void byteswap<8>(void* p) { + *static_cast(p) = bswap_64(*static_cast(p)); +} + template const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, RepeatedField* out) { @@ -241,7 +254,13 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, int old_entries = out->size(); out->Reserve(old_entries + num); int block_size = num * sizeof(T); - std::memcpy(out->AddNAlreadyReserved(num), ptr, block_size); + auto dst = out->AddNAlreadyReserved(num); +#ifdef PROTOBUF_LITTLE_ENDIAN + std::memcpy(dst, ptr, block_size); +#else + for (int i = 0; i < num; i++) + dst[i] = UnalignedLoad(ptr + i * sizeof(T)); +#endif ptr += block_size; size -= block_size; if (DoneWithCheck(&ptr, -1)) return nullptr; @@ -251,7 +270,12 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, int old_entries = out->size(); out->Reserve(old_entries + num); int block_size = num * sizeof(T); - std::memcpy(out->AddNAlreadyReserved(num), ptr, block_size); + auto dst = out->AddNAlreadyReserved(num); +#ifdef PROTOBUF_LITTLE_ENDIAN + std::memcpy(dst, ptr, block_size); +#else + for (int i = 0; i < num; i++) dst[i] = UnalignedLoad(ptr + i * sizeof(T)); +#endif ptr += block_size; if (size != block_size) return nullptr; return ptr; @@ -316,10 +340,29 @@ void WriteLengthDelimited(uint32 num, StringPiece val, std::string* s) { s->append(val.data(), val.size()); } -std::pair ReadTagFallback(const char* p, uint32 res) { - for (std::uint32_t i = 0; i < 3; i++) { - std::uint32_t byte = static_cast(p[i]); - res += (byte - 1) << (7 * (i + 2)); +std::pair VarintParseSlow32(const char* p, uint32 res) { + for (std::uint32_t i = 2; i < 5; i++) { + uint32 byte = static_cast(p[i]); + res += (byte - 1) << (7 * i); + if (PROTOBUF_PREDICT_TRUE(byte < 128)) { + return {p + i + 1, res}; + } + } + // Accept >5 bytes + for (std::uint32_t i = 5; i < 10; i++) { + uint32 byte = static_cast(p[i]); + if (PROTOBUF_PREDICT_TRUE(byte < 128)) { + return {p + i + 1, res}; + } + } + return {nullptr, 0}; +} + +std::pair VarintParseSlow64(const char* p, uint32 res32) { + uint64 res = res32; + for (std::uint32_t i = 2; i < 10; i++) { + uint64 byte = static_cast(p[i]); + res += (byte - 1) << (7 * i); if (PROTOBUF_PREDICT_TRUE(byte < 128)) { return {p + i + 1, res}; } @@ -327,16 +370,35 @@ std::pair ReadTagFallback(const char* p, uint32 res) { return {nullptr, 0}; } -std::pair ParseVarint64Fallback(const char* p, - uint64 res) { - return ParseVarint64FallbackInline(p, res); +std::pair ReadTagFallback(const char* p, uint32 res) { + for (std::uint32_t i = 2; i < 5; i++) { + uint32 byte = static_cast(p[i]); + res += (byte - 1) << (7 * i); + if (PROTOBUF_PREDICT_TRUE(byte < 128)) { + return {p + i + 1, res}; + } + } + return {nullptr, 0}; } -std::pair ReadSizeFallback(const char* p, uint32 first) { - uint32 tmp; - auto res = VarintParse<4>(p + 1, &tmp); - if (tmp >= (1 << 24) - ParseContext::kSlopBytes) return {nullptr, 0}; - return {res, (tmp << 7) + first - 0x80}; +std::pair ReadSizeFallback(const char* p, uint32 res) { + for (std::uint32_t i = 1; i < 4; i++) { + uint32 byte = static_cast(p[i]); + res += (byte - 1) << (7 * i); + if (PROTOBUF_PREDICT_TRUE(byte < 128)) { + return {p + i + 1, res}; + } + } + std::uint32_t byte = static_cast(p[4]); + if (PROTOBUF_PREDICT_FALSE(byte >= 8)) return {nullptr, 0}; // size >= 2gb + res += (byte - 1) << 28; + // Protect against sign integer overflow in PushLimit. Limits are relative + // to buffer ends and ptr could potential be kSlopBytes beyond a buffer end. + // To protect against overflow we reject limits absurdly close to INT_MAX. + if (PROTOBUF_PREDICT_FALSE(res > INT_MAX - ParseContext::kSlopBytes)) { + return {nullptr, 0}; + } + return {p + 5, res}; } const char* StringParser(const char* begin, const char* end, void* object, @@ -501,7 +563,8 @@ class UnknownFieldLiteParserHelper { if (unknown_ == nullptr) return; WriteVarint(num * 8 + 1, unknown_); char buffer[8]; - std::memcpy(buffer, &value, 8); + io::CodedOutputStream::WriteLittleEndian64ToArray( + value, reinterpret_cast(buffer)); unknown_->append(buffer, 8); } const char* ParseLengthDelimited(uint32 num, const char* ptr, @@ -524,7 +587,8 @@ class UnknownFieldLiteParserHelper { if (unknown_ == nullptr) return; WriteVarint(num * 8 + 5, unknown_); char buffer[4]; - std::memcpy(buffer, &value, 4); + io::CodedOutputStream::WriteLittleEndian32ToArray( + value, reinterpret_cast(buffer)); unknown_->append(buffer, 4); } diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 72355f81cf..bc7a0ad05a 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -124,7 +124,9 @@ class PROTOBUF_EXPORT EpsCopyInputStream { // If return value is negative it's an error PROTOBUF_MUST_USE_RESULT int PushLimit(const char* ptr, int limit) { - GOOGLE_DCHECK(limit >= 0); + GOOGLE_DCHECK(limit >= 0 && limit <= INT_MAX - kSlopBytes); + // This add is safe due to the invariant above, because + // ptr - buffer_end_ <= kSlopBytes. limit += static_cast(ptr - buffer_end_); limit_end_ = buffer_end_ + (std::min)(0, limit); auto old_limit = limit_; @@ -343,8 +345,7 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { const Data& data() const { return data_; } template - PROTOBUF_MUST_USE_RESULT PROTOBUF_ALWAYS_INLINE const char* ParseMessage( - T* msg, const char* ptr); + PROTOBUF_MUST_USE_RESULT const char* ParseMessage(T* msg, const char* ptr); // We outline when the type is generic and we go through a virtual const char* ParseMessage(MessageLite* msg, const char* ptr); const char* ParseMessage(Message* msg, const char* ptr); @@ -374,141 +375,167 @@ class PROTOBUF_EXPORT ParseContext : public EpsCopyInputStream { Data data_; }; +template +bool ExpectTag(const char* ptr) { + if (tag < 128) { + return *ptr == tag; + } else { + static_assert(tag < 128 * 128, "We only expect tags for 1 or 2 bytes"); + char buf[2] = {static_cast(tag | 0x80), static_cast(tag >> 7)}; + return std::memcmp(ptr, buf, 2) == 0; + } +} + +template +struct EndianHelper; + +template <> +struct EndianHelper<1> { + static uint8 Load(const void* p) { return *static_cast(p); } +}; + +template <> +struct EndianHelper<2> { + static uint16 Load(const void* p) { + uint16 tmp; + std::memcpy(&tmp, p, 2); +#ifndef PROTOBUF_LITTLE_ENDIAN + tmp = bswap_16(tmp); +#endif + return tmp; + } +}; + +template <> +struct EndianHelper<4> { + static uint32 Load(const void* p) { + uint32 tmp; + std::memcpy(&tmp, p, 4); +#ifndef PROTOBUF_LITTLE_ENDIAN + tmp = bswap_32(tmp); +#endif + return tmp; + } +}; + +template <> +struct EndianHelper<8> { + static uint64 Load(const void* p) { + uint64 tmp; + std::memcpy(&tmp, p, 8); +#ifndef PROTOBUF_LITTLE_ENDIAN + tmp = bswap_64(tmp); +#endif + return tmp; + } +}; + template -T UnalignedLoad(const void* p) { +T UnalignedLoad(const char* p) { + auto tmp = EndianHelper::Load(p); T res; - memcpy(&res, p, sizeof(T)); + memcpy(&res, &tmp, sizeof(T)); return res; } -// TODO(gerbens) Experiment with best implementation. -// Clang unrolls loop and generating pretty good code on O2, gcc doesn't. -// Unclear if we want 64 bit parse loop unrolled, inlined or opaque function -// call. Hence experimentation is needed. -// Important guarantee is that it doesn't read more than size bytes from p. -template -PROTOBUF_MUST_USE_RESULT const char* VarintParse(const char* p, T* out) { - T res = 1; - for (int i = 0; i < size; i++) { - T byte = static_cast(p[i]); - res += (byte - 1) << (i * 7); - int j = i + 1; - if (PROTOBUF_PREDICT_TRUE(byte < 128)) { - *out = res; - return p + j; - } - } - *out = 0; - return nullptr; -} +std::pair VarintParseSlow32(const char* p, uint32 res); +std::pair VarintParseSlow64(const char* p, uint32 res); -// Decode 2 consecutive bytes of a varint and returns the value, shifted left -// by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the -// first byte's continuation bit is set. -// If bit 15 of return value is set (equivalent to the continuation bits of both -// bytes being set) the varint continues, otherwise the parse is done. On x86 -// movsx eax, dil -// add edi, eax -// adc [rsi], 1 -// add eax, eax -// and eax, edi -inline uint32 DecodeTwoBytes(uint32 value, const char** ptr) { - // Sign extend the low byte continuation bit - uint32_t x = static_cast(value); - // This add is an amazing operation, it cancels the low byte continuation bit - // from y transferring it to the carry. Simultaneously it also shifts the 7 - // LSB left by one tightly against high byte varint bits. Hence value now - // contains the unpacked value shifted left by 1. - value += x; - // Use the carry to update the ptr appropriately. - *ptr += value < x ? 2 : 1; - return value & (x + x); // Mask out the high byte iff no continuation +inline const char* VarintParseSlow(const char* p, uint32 res, uint32* out) { + auto tmp = VarintParseSlow32(p, res); + *out = tmp.second; + return tmp.first; } -// Used for tags, could read up to 5 bytes which must be available. -// Caller must ensure its safe to call. - -std::pair ReadTagFallback(const char* p, uint32 res); +inline const char* VarintParseSlow(const char* p, uint32 res, uint64* out) { + auto tmp = VarintParseSlow64(p, res); + *out = tmp.second; + return tmp.first; +} -inline const char* ReadTag(const char* p, uint32* out) { - uint32 res = static_cast(p[0]); - if (res < 128) { +template +PROTOBUF_MUST_USE_RESULT const char* VarintParse(const char* p, T* out) { + auto ptr = reinterpret_cast(p); + uint32 res = ptr[0]; + if (!(res & 0x80)) { *out = res; return p + 1; } - uint32 second = static_cast(p[1]); - res += (second - 1) << 7; - if (second < 128) { + uint32 byte = ptr[1]; + res += (byte - 1) << 7; + if (!(byte & 0x80)) { *out = res; return p + 2; } - auto tmp = ReadTagFallback(p + 2, res); - *out = tmp.second; - return tmp.first; + return VarintParseSlow(p, res, out); } -// Will preload the next 2 bytes -inline const char* ReadTag(const char* p, uint32* out, uint32* preload) { +// Used for tags, could read up to 5 bytes which must be available. +// Caller must ensure its safe to call. + +std::pair ReadTagFallback(const char* p, uint32 res); + +// Same as ParseVarint but only accept 5 bytes at most. +inline const char* ReadTag(const char* p, uint32* out, uint32 max_tag = 0) { uint32 res = static_cast(p[0]); if (res < 128) { *out = res; - *preload = UnalignedLoad(p + 1); return p + 1; } uint32 second = static_cast(p[1]); res += (second - 1) << 7; if (second < 128) { *out = res; - *preload = UnalignedLoad(p + 2); return p + 2; } - auto tmp = ReadTagFallback(p + 2, res); + auto tmp = ReadTagFallback(p, res); *out = tmp.second; return tmp.first; } -inline std::pair ParseVarint64FallbackInline(const char* p, - uint64 res) { - res >>= 1; - for (std::uint32_t i = 0; i < 4; i++) { - auto pnew = p + 2 * i; - auto tmp = DecodeTwoBytes(UnalignedLoad(pnew), &pnew); - res += (static_cast(tmp) - 2) << (14 * (i + 1) - 1); - if (PROTOBUF_PREDICT_TRUE(std::int16_t(tmp) >= 0)) { - return {pnew, res}; - } - } - return {nullptr, res}; +// Decode 2 consecutive bytes of a varint and returns the value, shifted left +// by 1. It simultaneous updates *ptr to *ptr + 1 or *ptr + 2 depending if the +// first byte's continuation bit is set. +// If bit 15 of return value is set (equivalent to the continuation bits of both +// bytes being set) the varint continues, otherwise the parse is done. On x86 +// movsx eax, dil +// add edi, eax +// adc [rsi], 1 +// add eax, eax +// and eax, edi +inline uint32 DecodeTwoBytes(const char** ptr) { + uint32 value = UnalignedLoad(*ptr); + // Sign extend the low byte continuation bit + uint32_t x = static_cast(value); + // This add is an amazing operation, it cancels the low byte continuation bit + // from y transferring it to the carry. Simultaneously it also shifts the 7 + // LSB left by one tightly against high byte varint bits. Hence value now + // contains the unpacked value shifted left by 1. + value += x; + // Use the carry to update the ptr appropriately. + *ptr += value < x ? 2 : 1; + return value & (x + x); // Mask out the high byte iff no continuation } -inline const char* ParseVarint64Inline(const char* p, uint64* out) { - auto tmp = DecodeTwoBytes(UnalignedLoad(p), &p); - if (PROTOBUF_PREDICT_TRUE(static_cast(tmp) >= 0)) { - *out = tmp >> 1; - return p; +// More efficient varint parsing for big varints +inline const char* ParseBigVarint(const char* p, uint64* out) { + auto pnew = p; + auto tmp = DecodeTwoBytes(&pnew); + uint64 res = tmp >> 1; + if (PROTOBUF_PREDICT_TRUE(std::int16_t(tmp) >= 0)) { + *out = res; + return pnew; } - auto x = ParseVarint64FallbackInline(p, tmp); - *out = x.second; - return x.first; -} - -std::pair ParseVarint64Fallback(const char* p, uint64 res); - -inline const char* ParseVarint64(const char* p, uint32 preload, uint64* out) { - auto tmp = DecodeTwoBytes(preload, &p); - if (PROTOBUF_PREDICT_TRUE(static_cast(tmp) >= 0)) { - *out = tmp >> 1; - return p; + for (std::uint32_t i = 1; i < 5; i++) { + pnew = p + 2 * i; + tmp = DecodeTwoBytes(&pnew); + res += (static_cast(tmp) - 2) << (14 * i - 1); + if (PROTOBUF_PREDICT_TRUE(std::int16_t(tmp) >= 0)) { + *out = res; + return pnew; + } } - auto x = ParseVarint64Fallback(p, tmp); - *out = x.second; - return x.first; -} - -// Used for reading varint wiretype values, could read up to 10 bytes. -// Caller must ensure its safe to call. -inline const char* ParseVarint64(const char* p, uint64* out) { - return ParseVarint64(p, UnalignedLoad(p), out); + return nullptr; } std::pair ReadSizeFallback(const char* p, uint32 first); @@ -534,37 +561,19 @@ inline uint32 ReadSize(const char** pp) { // stack frames that scale as O(num fields). inline uint64 ReadVarint(const char** p) { uint64 tmp; - *p = ParseVarint64(*p, &tmp); + *p = VarintParse(*p, &tmp); return tmp; } inline int64 ReadVarintZigZag64(const char** p) { uint64 tmp; - *p = ParseVarint64(*p, &tmp); + *p = VarintParse(*p, &tmp); return WireFormatLite::ZigZagDecode64(tmp); } inline int32 ReadVarintZigZag32(const char** p) { uint64 tmp; - *p = ParseVarint64(*p, &tmp); - return WireFormatLite::ZigZagDecode32(static_cast(tmp)); -} - -inline uint64 ReadVarint(const char** p, uint32 preload) { - uint64 tmp; - *p = ParseVarint64(*p, preload, &tmp); - return tmp; -} - -inline int64 ReadVarintZigZag64(const char** p, uint32 preload) { - uint64 tmp; - *p = ParseVarint64(*p, preload, &tmp); - return WireFormatLite::ZigZagDecode64(tmp); -} - -inline int32 ReadVarintZigZag32(const char** p, uint32 preload) { - uint64 tmp; - *p = ParseVarint64(*p, preload, &tmp); + *p = VarintParse(*p, &tmp); return WireFormatLite::ZigZagDecode32(static_cast(tmp)); } @@ -590,7 +599,7 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { if (old < 0) return nullptr; while (!DoneWithCheck(&ptr, -1)) { uint64 varint; - ptr = ParseVarint64(ptr, &varint); + ptr = VarintParse(ptr, &varint); if (!ptr) return nullptr; add(varint); } @@ -643,7 +652,7 @@ PROTOBUF_MUST_USE_RESULT const char* FieldParser(uint64 tag, T& field_parser, switch (tag & 7) { case WireType::WIRETYPE_VARINT: { uint64 value; - ptr = ParseVarint64(ptr, &value); + ptr = VarintParse(ptr, &value); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); field_parser.AddVarint(number, value); break; diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 17ab7ed83a..7b754ddb57 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -160,10 +160,11 @@ #ifdef GOOGLE_ATTRIBUTE_ALWAYS_INLINE #define PROTOBUF_ALWAYS_INLINE GOOGLE_ATTRIBUTE_ALWAYS_INLINE #else -#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#if defined(__GNUC__) && \ + (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force inline. // Introduced in gcc 3.1. -#define PROTOBUF_ALWAYS_INLINE __attribute__ ((always_inline)) +#define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline)) #else // Other compilers will have to figure it out for themselves. #define PROTOBUF_ALWAYS_INLINE @@ -173,10 +174,11 @@ #ifdef GOOGLE_ATTRIBUTE_NOINLINE #define PROTOBUF_NOINLINE GOOGLE_ATTRIBUTE_NOINLINE #else -#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#if defined(__GNUC__) && \ + (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) // For functions we want to force not inline. // Introduced in gcc 3.1. -#define PROTOBUF_NOINLINE __attribute__ ((noinline)) +#define PROTOBUF_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) // Seems to have been around since at least Visual Studio 2005 #define PROTOBUF_NOINLINE __declspec(noinline) @@ -190,9 +192,10 @@ #define PROTOBUF_FUNC_ALIGN GOOGLE_ATTRIBUTE_FUNC_ALIGN #else #if defined(__clang__) || \ - defined(__GNUC__) && (__GNUC__ > 4 ||(__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) // Function alignment attribute introduced in gcc 4.3 -#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__ ((aligned(bytes))) +#define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) #else #define PROTOBUF_FUNC_ALIGN(bytes) #endif @@ -312,10 +315,10 @@ // For Clang we use __builtin_offsetof() and suppress the warning, // to avoid Control Flow Integrity and UBSan vptr sanitizers from // crashing while trying to validate the invalid reinterpet_casts. -#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ - __builtin_offsetof(TYPE, FIELD) \ +#define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \ + __builtin_offsetof(TYPE, FIELD) \ _Pragma("clang diagnostic pop") #else // Note that we calculate relative to the pointer value 16 here since if we @@ -328,7 +331,6 @@ reinterpret_cast(16)) #endif - #if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) #ifdef LIBPROTOBUF_EXPORTS #define PROTOBUF_EXPORT __declspec(dllexport) diff --git a/src/google/protobuf/reflection_ops.cc b/src/google/protobuf/reflection_ops.cc index 3ced1419f4..f2852f83b7 100644 --- a/src/google/protobuf/reflection_ops.cc +++ b/src/google/protobuf/reflection_ops.cc @@ -45,7 +45,6 @@ #include #include - #include namespace google { diff --git a/src/google/protobuf/repeated_field.cc b/src/google/protobuf/repeated_field.cc index e5dbe025be..bac35503e6 100644 --- a/src/google/protobuf/repeated_field.cc +++ b/src/google/protobuf/repeated_field.cc @@ -32,11 +32,13 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include + #include #include #include -#include +#include #include diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index 47c9987041..fb8301bfa4 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -56,10 +56,10 @@ #include #include #include + #include #include #include -#include #include #include #include @@ -72,19 +72,15 @@ #error "You cannot SWIG proto headers" #endif -// Forward-declare these so that we can make them friends. -namespace upb { -namespace google_opensource { -class GMR_Handlers; -} // namespace google_opensource -} // namespace upb - namespace google { namespace protobuf { class Message; class Reflection; +template +struct WeakRepeatedPtrField; + namespace internal { class MergePartialFromCodedStreamHelper; @@ -323,7 +319,6 @@ class RepeatedField final { friend class Arena; typedef void InternalArenaConstructable_; - // Move the contents of |from| into |to|, possibly clobbering |from| in the // process. For primitive types this is just a memcpy(), but it could be // specialized for non-primitive types to, say, swap each element instead. @@ -443,11 +438,8 @@ struct IsMovable // class TypeHandler { // public: // typedef MyType Type; -// // WeakType is almost always the same as MyType, but we use it in -// // ImplicitWeakTypeHandler. -// typedef MyType WeakType; // static Type* New(); -// static WeakType* NewFromPrototype(const WeakType* prototype, +// static Type* NewFromPrototype(const Type* prototype, // Arena* arena); // static void Delete(Type*); // static void Clear(Type*); @@ -460,12 +452,20 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { protected: RepeatedPtrFieldBase(); explicit RepeatedPtrFieldBase(Arena* arena); - ~RepeatedPtrFieldBase() {} + ~RepeatedPtrFieldBase() { +#ifndef NDEBUG + // Try to trigger segfault / asan failure in non-opt builds. If arena_ + // lifetime has ended before the destructor. + if (arena_) (void)arena_->SpaceAllocated(); +#endif + } + public: // Must be called from destructor. template void Destroy(); + protected: bool empty() const; int size() const; @@ -487,7 +487,7 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // application code. template - const typename TypeHandler::WeakType& Get(int index) const; + const typename TypeHandler::Type& Get(int index) const; // Creates and adds an element using the given prototype, without introducing // a link-time dependency on the concrete message type. This method is used to @@ -662,12 +662,9 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase { // The table-driven MergePartialFromCodedStream implementation needs to // operate on RepeatedPtrField. friend class MergePartialFromCodedStreamHelper; - - // To parse directly into a proto2 generated class, the upb class GMR_Handlers - // needs to be able to modify a RepeatedPtrFieldBase directly. - friend class upb::google_opensource::GMR_Handlers; - friend class AccessorHelper; + template + friend struct google::protobuf::WeakRepeatedPtrField; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase); }; @@ -676,7 +673,6 @@ template class GenericTypeHandler { public: typedef GenericType Type; - typedef GenericType WeakType; using Movable = IsMovable; static inline GenericType* New(Arena* arena) { @@ -744,31 +740,21 @@ template <> void GenericTypeHandler::Merge(const std::string& from, std::string* to); -// Declarations of the specialization as we cannot define them here, as the -// header that defines ProtocolMessage depends on types defined in this header. -#define DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(TypeName) \ - template <> \ - PROTOBUF_EXPORT TypeName* GenericTypeHandler::NewFromPrototype( \ - const TypeName* prototype, Arena* arena); \ - template <> \ - PROTOBUF_EXPORT Arena* GenericTypeHandler::GetArena( \ - TypeName* value); \ - template <> \ - PROTOBUF_EXPORT void* GenericTypeHandler::GetMaybeArenaPointer( \ - TypeName* value); - // Message specialization bodies defined in message.cc. This split is necessary // to allow proto2-lite (which includes this header) to be independent of // Message. -DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(Message) - - -#undef DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES +template <> +PROTOBUF_EXPORT Message* GenericTypeHandler::NewFromPrototype( + const Message* prototype, Arena* arena); +template <> +PROTOBUF_EXPORT Arena* GenericTypeHandler::GetArena(Message* value); +template <> +PROTOBUF_EXPORT void* GenericTypeHandler::GetMaybeArenaPointer( + Message* value); class StringTypeHandler { public: typedef std::string Type; - typedef std::string WeakType; using Movable = IsMovable; static inline std::string* New(Arena* arena) { @@ -1037,7 +1023,9 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { // For internal use only. // // This is public due to it being called by generated code. - using RepeatedPtrFieldBase::InternalSwap; + void InternalSwap(RepeatedPtrField* other) { + internal::RepeatedPtrFieldBase::InternalSwap(other); + } private: // Note: RepeatedPtrField SHOULD NOT be subclassed by users. @@ -1056,7 +1044,9 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase { std::false_type); friend class Arena; - friend class MessageLite; + + template + friend struct WeakRepeatedPtrField; typedef void InternalArenaConstructable_; @@ -1543,7 +1533,7 @@ inline bool RepeatedPtrFieldBase::empty() const { return current_size_ == 0; } inline int RepeatedPtrFieldBase::size() const { return current_size_; } template -inline const typename TypeHandler::WeakType& RepeatedPtrFieldBase::Get( +inline const typename TypeHandler::Type& RepeatedPtrFieldBase::Get( int index) const { GOOGLE_DCHECK_GE(index, 0); GOOGLE_DCHECK_LT(index, current_size_); @@ -1670,18 +1660,18 @@ void RepeatedPtrFieldBase::MergeFromInnerLoop(void** our_elems, // to avoid a branch within the loop. for (int i = 0; i < already_allocated && i < length; i++) { // Already allocated: use existing element. - typename TypeHandler::WeakType* other_elem = - reinterpret_cast(other_elems[i]); - typename TypeHandler::WeakType* new_elem = - reinterpret_cast(our_elems[i]); + typename TypeHandler::Type* other_elem = + reinterpret_cast(other_elems[i]); + typename TypeHandler::Type* new_elem = + reinterpret_cast(our_elems[i]); TypeHandler::Merge(*other_elem, new_elem); } Arena* arena = GetArenaNoVirtual(); for (int i = already_allocated; i < length; i++) { // Not allocated: alloc a new element first, then merge it. - typename TypeHandler::WeakType* other_elem = - reinterpret_cast(other_elems[i]); - typename TypeHandler::WeakType* new_elem = + typename TypeHandler::Type* other_elem = + reinterpret_cast(other_elems[i]); + typename TypeHandler::Type* new_elem = TypeHandler::NewFromPrototype(other_elem, arena); TypeHandler::Merge(*other_elem, new_elem); our_elems[i] = new_elem; diff --git a/src/google/protobuf/repeated_field_unittest.cc b/src/google/protobuf/repeated_field_unittest.cc index dd79d42e15..ca5452b8e9 100644 --- a/src/google/protobuf/repeated_field_unittest.cc +++ b/src/google/protobuf/repeated_field_unittest.cc @@ -51,7 +51,6 @@ #include #include #include - #include namespace google { diff --git a/src/google/protobuf/source_context.pb.cc b/src/google/protobuf/source_context.pb.cc index 877814bfdc..6dea4e8fbb 100644 --- a/src/google/protobuf/source_context.pb.cc +++ b/src/google/protobuf/source_context.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_SourceContext_google_2fprotobuf_2fsource_5fcont } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fsource_5fcontext_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fsource_5fcontext_2eproto = nullptr; @@ -99,7 +99,7 @@ SourceContext::SourceContext(const SourceContext& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); file_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.file_name().empty()) { + if (!from._internal_file_name().empty()) { file_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.file_name_); } // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext) @@ -149,7 +149,7 @@ const char* SourceContext::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ // string file_name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_file_name(), ptr, ctx, "google.protobuf.SourceContext.file_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_file_name(), ptr, ctx, "google.protobuf.SourceContext.file_name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -187,9 +187,9 @@ bool SourceContext::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_file_name())); + input, this->_internal_mutable_file_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->file_name().data(), static_cast(this->file_name().length()), + this->_internal_file_name().data(), static_cast(this->_internal_file_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.SourceContext.file_name")); } else { @@ -228,11 +228,11 @@ failure: // string file_name = 1; if (this->file_name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->file_name().data(), static_cast(this->file_name().length()), + this->_internal_file_name().data(), static_cast(this->_internal_file_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.SourceContext.file_name"); target = stream->WriteStringMaybeAliased( - 1, this->file_name(), target); + 1, this->_internal_file_name(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -255,7 +255,7 @@ size_t SourceContext::ByteSizeLong() const { if (this->file_name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->file_name()); + this->_internal_file_name()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 13c4e073e2..27a1a4aaf8 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -189,6 +189,11 @@ class PROTOBUF_EXPORT SourceContext : std::string* mutable_file_name(); std::string* release_file_name(); void set_allocated_file_name(std::string* file_name); + private: + const std::string& _internal_file_name() const; + void _internal_set_file_name(const std::string& value); + std::string* _internal_mutable_file_name(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.SourceContext) private: @@ -216,12 +221,22 @@ inline void SourceContext::clear_file_name() { } inline const std::string& SourceContext::file_name() const { // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name) - return file_name_.GetNoArena(); + return _internal_file_name(); } inline void SourceContext::set_file_name(const std::string& value) { + _internal_set_file_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) +} +inline std::string* SourceContext::mutable_file_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name) + return _internal_mutable_file_name(); +} +inline const std::string& SourceContext::_internal_file_name() const { + return file_name_.GetNoArena(); +} +inline void SourceContext::_internal_set_file_name(const std::string& value) { file_name_.SetNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value); - // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name) } inline void SourceContext::set_file_name(std::string&& value) { @@ -241,9 +256,8 @@ inline void SourceContext::set_file_name(const char* value, size_t size) { ::std::string(reinterpret_cast(value), size)); // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name) } -inline std::string* SourceContext::mutable_file_name() { +inline std::string* SourceContext::_internal_mutable_file_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name) return file_name_.MutableNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); } inline std::string* SourceContext::release_file_name() { diff --git a/src/google/protobuf/struct.pb.cc b/src/google/protobuf/struct.pb.cc index 2f9876fb71..cd49d6df38 100644 --- a/src/google/protobuf/struct.pb.cc +++ b/src/google/protobuf/struct.pb.cc @@ -68,7 +68,7 @@ static void InitDefaultsscc_info_ListValue_google_2fprotobuf_2fstruct_2eproto() } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ListValue_google_2fprotobuf_2fstruct_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_ListValue_google_2fprotobuf_2fstruct_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ListValue_google_2fprotobuf_2fstruct_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fstruct_2eproto[4]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fstruct_2eproto[1]; @@ -275,7 +275,7 @@ const char* Struct::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int ptr = ctx->ParseMessage(&fields_, ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -570,7 +570,7 @@ Value::Value(const Value& from) break; } case kStringValue: { - set_string_value(from.string_value()); + _internal_set_string_value(from._internal_string_value()); break; } case kBoolValue: { @@ -701,7 +701,7 @@ const char* Value::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte // string string_value = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_string_value(), ptr, ctx, "google.protobuf.Value.string_value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_string_value(), ptr, ctx, "google.protobuf.Value.string_value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -788,9 +788,9 @@ bool Value::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_string_value())); + input, this->_internal_mutable_string_value())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->string_value().data(), static_cast(this->string_value().length()), + this->_internal_string_value().data(), static_cast(this->_internal_string_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Value.string_value")); } else { @@ -878,11 +878,11 @@ failure: // string string_value = 3; if (has_string_value()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->string_value().data(), static_cast(this->string_value().length()), + this->_internal_string_value().data(), static_cast(this->_internal_string_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Value.string_value"); target = stream->WriteStringMaybeAliased( - 3, this->string_value(), target); + 3, this->_internal_string_value(), target); } // bool bool_value = 4; @@ -939,7 +939,7 @@ size_t Value::ByteSizeLong() const { case kStringValue: { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->string_value()); + this->_internal_string_value()); break; } // bool bool_value = 4; @@ -1006,7 +1006,7 @@ void Value::MergeFrom(const Value& from) { break; } case kStringValue: { - set_string_value(from.string_value()); + _internal_set_string_value(from._internal_string_value()); break; } case kBoolValue: { @@ -1142,7 +1142,7 @@ const char* ListValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ptr = ctx->ParseMessage(add_values(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 10); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr)); } else goto handle_unusual; continue; default: { @@ -1214,8 +1214,8 @@ failure: (void) cached_has_bits; // repeated .google.protobuf.Value values = 1; - for (auto it = this->values().pointer_begin(), - end = this->values().pointer_end(); it < end; ++it) { + for (auto it = this->values_.pointer_begin(), + end = this->values_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(1, **it, target, stream); @@ -1238,14 +1238,10 @@ size_t ListValue::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Value values = 1; - { - unsigned int count = static_cast(this->values_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->values(static_cast(i))); - } + total_size += 1UL * this->values_size(); + for (const auto& msg : this->values_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1303,7 +1299,7 @@ bool ListValue::IsInitialized() const { void ListValue::InternalSwap(ListValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&values_)->InternalSwap(CastToBase(&other->values_)); + values_.InternalSwap(&other->values_); } ::PROTOBUF_NAMESPACE_ID::Metadata ListValue::GetMetadata() const { diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index c7c08f1572..124016bd9a 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -485,6 +485,11 @@ class PROTOBUF_EXPORT Value : " future release.") void unsafe_arena_set_allocated_string_value( std::string* string_value); + private: + const std::string& _internal_string_value() const; + void _internal_set_string_value(const std::string& value); + std::string* _internal_mutable_string_value(); + public: // bool bool_value = 4; private: @@ -496,6 +501,9 @@ class PROTOBUF_EXPORT Value : // .google.protobuf.Struct struct_value = 5; bool has_struct_value() const; + private: + bool _internal_has_struct_value() const; + public: void clear_struct_value(); const PROTOBUF_NAMESPACE_ID::Struct& struct_value() const; PROTOBUF_NAMESPACE_ID::Struct* release_struct_value(); @@ -507,6 +515,9 @@ class PROTOBUF_EXPORT Value : // .google.protobuf.ListValue list_value = 6; bool has_list_value() const; + private: + bool _internal_has_list_value() const; + public: void clear_list_value(); const PROTOBUF_NAMESPACE_ID::ListValue& list_value() const; PROTOBUF_NAMESPACE_ID::ListValue* release_list_value(); @@ -816,12 +827,23 @@ inline void Value::clear_string_value() { } inline const std::string& Value::string_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value) + return _internal_string_value(); +} +inline void Value::set_string_value(const std::string& value) { + _internal_set_string_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) +} +inline std::string* Value::mutable_string_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value) + return _internal_mutable_string_value(); +} +inline const std::string& Value::_internal_string_value() const { if (has_string_value()) { return kind_.string_value_.Get(); } return *&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); } -inline void Value::set_string_value(const std::string& value) { +inline void Value::_internal_set_string_value(const std::string& value) { if (!has_string_value()) { clear_kind(); set_has_string_value(); @@ -829,7 +851,6 @@ inline void Value::set_string_value(const std::string& value) { } kind_.string_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) } inline void Value::set_string_value(std::string&& value) { // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value) @@ -866,7 +887,7 @@ inline void Value::set_string_value(const char* value, GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value) } -inline std::string* Value::mutable_string_value() { +inline std::string* Value::_internal_mutable_string_value() { if (!has_string_value()) { clear_kind(); set_has_string_value(); @@ -874,7 +895,6 @@ inline std::string* Value::mutable_string_value() { } return kind_.string_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); - // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value) } inline std::string* Value::release_string_value() { // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value) diff --git a/src/google/protobuf/test_util2.h b/src/google/protobuf/test_util2.h index d1cf2119e3..f12addb313 100644 --- a/src/google/protobuf/test_util2.h +++ b/src/google/protobuf/test_util2.h @@ -36,7 +36,6 @@ #include #include - namespace google { namespace protobuf { namespace TestUtil { diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 420c1e8c6d..75d10077c7 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -37,6 +37,7 @@ #include #include #include + #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -54,18 +54,15 @@ #include #include #include +#include #include #include #include #include - - - +#include #include #include -#include - namespace google { namespace protobuf { @@ -1239,6 +1236,10 @@ class TextFormat::Printer::TextGenerator --indent_level_; } + size_t GetCurrentIndentationSize() const override { + return 2 * indent_level_; + } + // Print text to the output stream. void Print(const char* text, size_t size) override { if (indent_level_ > 0) { @@ -1309,7 +1310,7 @@ class TextFormat::Printer::TextGenerator return; } GOOGLE_DCHECK(!failed_); - int size = 2 * indent_level_; + int size = GetCurrentIndentationSize(); while (size > buffer_size_) { // Data exceeds space in the buffer. Write what we can and request a new diff --git a/src/google/protobuf/text_format.h b/src/google/protobuf/text_format.h index 2d755a9d8a..86ca3d7954 100644 --- a/src/google/protobuf/text_format.h +++ b/src/google/protobuf/text_format.h @@ -103,6 +103,8 @@ class PROTOBUF_EXPORT TextFormat { virtual void Indent() {} virtual void Outdent() {} + // Returns the current indentation size in characters. + virtual size_t GetCurrentIndentationSize() const { return 0; } // Print text to the output stream. virtual void Print(const char* text, size_t size) = 0; diff --git a/src/google/protobuf/text_format_unittest.cc b/src/google/protobuf/text_format_unittest.cc index 56801c3467..fcabc5f6a8 100644 --- a/src/google/protobuf/text_format_unittest.cc +++ b/src/google/protobuf/text_format_unittest.cc @@ -54,8 +54,6 @@ #include #include #include - - #include #include #include diff --git a/src/google/protobuf/timestamp.pb.cc b/src/google/protobuf/timestamp.pb.cc index 009320e440..01e1acfbce 100644 --- a/src/google/protobuf/timestamp.pb.cc +++ b/src/google/protobuf/timestamp.pb.cc @@ -32,7 +32,7 @@ static void InitDefaultsscc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Timestamp_google_2fprotobuf_2ftimestamp_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2ftimestamp_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2ftimestamp_2eproto = nullptr; diff --git a/src/google/protobuf/type.pb.cc b/src/google/protobuf/type.pb.cc index 734010d817..caf16c96c4 100644 --- a/src/google/protobuf/type.pb.cc +++ b/src/google/protobuf/type.pb.cc @@ -53,7 +53,7 @@ static void InitDefaultsscc_info_Enum_google_2fprotobuf_2ftype_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_Enum_google_2fprotobuf_2ftype_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsscc_info_Enum_google_2fprotobuf_2ftype_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_Enum_google_2fprotobuf_2ftype_2eproto}, { &scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto.base, &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base, &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base,}}; @@ -70,7 +70,7 @@ static void InitDefaultsscc_info_EnumValue_google_2fprotobuf_2ftype_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_EnumValue_google_2fprotobuf_2ftype_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_EnumValue_google_2fprotobuf_2ftype_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_EnumValue_google_2fprotobuf_2ftype_2eproto}, { &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}}; static void InitDefaultsscc_info_Field_google_2fprotobuf_2ftype_2eproto() { @@ -85,7 +85,7 @@ static void InitDefaultsscc_info_Field_google_2fprotobuf_2ftype_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Field_google_2fprotobuf_2ftype_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_Field_google_2fprotobuf_2ftype_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Field_google_2fprotobuf_2ftype_2eproto}, { &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base,}}; static void InitDefaultsscc_info_Option_google_2fprotobuf_2ftype_2eproto() { @@ -100,7 +100,7 @@ static void InitDefaultsscc_info_Option_google_2fprotobuf_2ftype_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Option_google_2fprotobuf_2ftype_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_Option_google_2fprotobuf_2ftype_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Option_google_2fprotobuf_2ftype_2eproto}, { &scc_info_Any_google_2fprotobuf_2fany_2eproto.base,}}; static void InitDefaultsscc_info_Type_google_2fprotobuf_2ftype_2eproto() { @@ -115,7 +115,7 @@ static void InitDefaultsscc_info_Type_google_2fprotobuf_2ftype_2eproto() { } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_Type_google_2fprotobuf_2ftype_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, InitDefaultsscc_info_Type_google_2fprotobuf_2ftype_2eproto}, { + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_Type_google_2fprotobuf_2ftype_2eproto}, { &scc_info_Field_google_2fprotobuf_2ftype_2eproto.base, &scc_info_Option_google_2fprotobuf_2ftype_2eproto.base, &scc_info_SourceContext_google_2fprotobuf_2fsource_5fcontext_2eproto.base,}}; @@ -410,8 +410,8 @@ Type::Type(const Type& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_source_context()) { @@ -487,7 +487,7 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Type.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Type.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -500,7 +500,7 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ptr = ctx->ParseMessage(add_fields(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // repeated string oneofs = 3; @@ -509,10 +509,10 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ptr -= 1; do { ptr += 1; - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(add_oneofs(), ptr, ctx, "google.protobuf.Type.oneofs"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_add_oneofs(), ptr, ctx, "google.protobuf.Type.oneofs"); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.Option options = 4; @@ -524,7 +524,7 @@ const char* Type::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 34); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<34>(ptr)); } else goto handle_unusual; continue; // .google.protobuf.SourceContext source_context = 5; @@ -576,9 +576,9 @@ bool Type::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Type.name")); } else { @@ -602,10 +602,10 @@ bool Type::MergePartialFromCodedStream( case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (26 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->add_oneofs())); + input, this->_internal_add_oneofs())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->oneofs(this->oneofs_size() - 1).data(), - static_cast(this->oneofs(this->oneofs_size() - 1).length()), + oneofs_.Get(oneofs_.size() - 1).data(), + static_cast(oneofs_.Get(oneofs_.size() - 1).length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Type.oneofs")); } else { @@ -680,24 +680,24 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Type.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.Field fields = 2; - for (auto it = this->fields().pointer_begin(), - end = this->fields().pointer_end(); it < end; ++it) { + for (auto it = this->fields_.pointer_begin(), + end = this->fields_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); } // repeated string oneofs = 3; - for (auto it = this->oneofs().pointer_begin(), - end = this->oneofs().pointer_end(); it < end; ++it) { + for (auto it = oneofs_.pointer_begin(), + end = oneofs_.pointer_end(); it < end; ++it) { const auto& s = **it; ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( s.data(), static_cast(s.length()), @@ -707,8 +707,8 @@ failure: } // repeated .google.protobuf.Option options = 4; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(4, **it, target, stream); @@ -746,40 +746,32 @@ size_t Type::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Field fields = 2; - { - unsigned int count = static_cast(this->fields_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->fields(static_cast(i))); - } + total_size += 1UL * this->fields_size(); + for (const auto& msg : this->fields_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated string oneofs = 3; total_size += 1 * - ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->oneofs_size()); - for (int i = 0, n = this->oneofs_size(); i < n; i++) { + ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(oneofs_.size()); + for (int i = 0, n = oneofs_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->oneofs(i)); + oneofs_.Get(i)); } // repeated .google.protobuf.Option options = 4; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // .google.protobuf.SourceContext source_context = 5; @@ -830,7 +822,7 @@ void Type::MergeFrom(const Type& from) { oneofs_.MergeFrom(from.oneofs_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (from.has_source_context()) { mutable_source_context()->PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from.source_context()); @@ -861,9 +853,9 @@ bool Type::IsInitialized() const { void Type::InternalSwap(Type* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&fields_)->InternalSwap(CastToBase(&other->fields_)); - oneofs_.InternalSwap(CastToBase(&other->oneofs_)); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + fields_.InternalSwap(&other->fields_); + oneofs_.InternalSwap(&other->oneofs_); + options_.InternalSwap(&other->options_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(source_context_, other->source_context_); @@ -902,23 +894,23 @@ Field::Field(const Field& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } type_url_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.type_url().empty()) { - type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.type_url(), + if (!from._internal_type_url().empty()) { + type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_type_url(), GetArenaNoVirtual()); } json_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.json_name().empty()) { - json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.json_name(), + if (!from._internal_json_name().empty()) { + json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_json_name(), GetArenaNoVirtual()); } default_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.default_value().empty()) { - default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.default_value(), + if (!from._internal_default_value().empty()) { + default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_default_value(), GetArenaNoVirtual()); } ::memcpy(&kind_, &from.kind_, @@ -1018,14 +1010,14 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte // string name = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Field.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Field.name"); CHK_(ptr); } else goto handle_unusual; continue; // string type_url = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_type_url(), ptr, ctx, "google.protobuf.Field.type_url"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_type_url(), ptr, ctx, "google.protobuf.Field.type_url"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1052,20 +1044,20 @@ const char* Field::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 74); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<74>(ptr)); } else goto handle_unusual; continue; // string json_name = 10; case 10: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_json_name(), ptr, ctx, "google.protobuf.Field.json_name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_json_name(), ptr, ctx, "google.protobuf.Field.json_name"); CHK_(ptr); } else goto handle_unusual; continue; // string default_value = 11; case 11: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_default_value(), ptr, ctx, "google.protobuf.Field.default_value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_default_value(), ptr, ctx, "google.protobuf.Field.default_value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1144,9 +1136,9 @@ bool Field::MergePartialFromCodedStream( case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (34 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Field.name")); } else { @@ -1159,9 +1151,9 @@ bool Field::MergePartialFromCodedStream( case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (50 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_type_url())); + input, this->_internal_mutable_type_url())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), static_cast(this->type_url().length()), + this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Field.type_url")); } else { @@ -1211,9 +1203,9 @@ bool Field::MergePartialFromCodedStream( case 10: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (82 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_json_name())); + input, this->_internal_mutable_json_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->json_name().data(), static_cast(this->json_name().length()), + this->_internal_json_name().data(), static_cast(this->_internal_json_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Field.json_name")); } else { @@ -1226,9 +1218,9 @@ bool Field::MergePartialFromCodedStream( case 11: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (90 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_default_value())); + input, this->_internal_mutable_default_value())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->default_value().data(), static_cast(this->default_value().length()), + this->_internal_default_value().data(), static_cast(this->_internal_default_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Field.default_value")); } else { @@ -1287,21 +1279,21 @@ failure: // string name = 4; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.name"); target = stream->WriteStringMaybeAliased( - 4, this->name(), target); + 4, this->_internal_name(), target); } // string type_url = 6; if (this->type_url().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->type_url().data(), static_cast(this->type_url().length()), + this->_internal_type_url().data(), static_cast(this->_internal_type_url().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.type_url"); target = stream->WriteStringMaybeAliased( - 6, this->type_url(), target); + 6, this->_internal_type_url(), target); } // int32 oneof_index = 7; @@ -1317,8 +1309,8 @@ failure: } // repeated .google.protobuf.Option options = 9; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(9, **it, target, stream); @@ -1327,21 +1319,21 @@ failure: // string json_name = 10; if (this->json_name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->json_name().data(), static_cast(this->json_name().length()), + this->_internal_json_name().data(), static_cast(this->_internal_json_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.json_name"); target = stream->WriteStringMaybeAliased( - 10, this->json_name(), target); + 10, this->_internal_json_name(), target); } // string default_value = 11; if (this->default_value().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->default_value().data(), static_cast(this->default_value().length()), + this->_internal_default_value().data(), static_cast(this->_internal_default_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Field.default_value"); target = stream->WriteStringMaybeAliased( - 11, this->default_value(), target); + 11, this->_internal_default_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -1361,42 +1353,38 @@ size_t Field::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Option options = 9; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 4; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // string type_url = 6; if (this->type_url().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->type_url()); + this->_internal_type_url()); } // string json_name = 10; if (this->json_name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->json_name()); + this->_internal_json_name()); } // string default_value = 11; if (this->default_value().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->default_value()); + this->_internal_default_value()); } // .google.protobuf.Field.Kind kind = 1; @@ -1463,16 +1451,16 @@ void Field::MergeFrom(const Field& from) { options_.MergeFrom(from.options_); if (from.name().size() > 0) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (from.type_url().size() > 0) { - set_type_url(from.type_url()); + _internal_set_type_url(from._internal_type_url()); } if (from.json_name().size() > 0) { - set_json_name(from.json_name()); + _internal_set_json_name(from._internal_json_name()); } if (from.default_value().size() > 0) { - set_default_value(from.default_value()); + _internal_set_default_value(from._internal_default_value()); } if (from.kind() != 0) { set_kind(from.kind()); @@ -1512,7 +1500,7 @@ bool Field::IsInitialized() const { void Field::InternalSwap(Field* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + options_.InternalSwap(&other->options_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); type_url_.Swap(&other->type_url_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), @@ -1588,8 +1576,8 @@ Enum::Enum(const Enum& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_source_context()) { @@ -1664,7 +1652,7 @@ const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Enum.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Enum.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -1677,7 +1665,7 @@ const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ptr = ctx->ParseMessage(add_enumvalue(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 18); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } else goto handle_unusual; continue; // repeated .google.protobuf.Option options = 3; @@ -1689,7 +1677,7 @@ const char* Enum::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inter ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; // .google.protobuf.SourceContext source_context = 4; @@ -1741,9 +1729,9 @@ bool Enum::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Enum.name")); } else { @@ -1829,24 +1817,24 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Enum.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // repeated .google.protobuf.EnumValue enumvalue = 2; - for (auto it = this->enumvalue().pointer_begin(), - end = this->enumvalue().pointer_end(); it < end; ++it) { + for (auto it = this->enumvalue_.pointer_begin(), + end = this->enumvalue_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(2, **it, target, stream); } // repeated .google.protobuf.Option options = 3; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(3, **it, target, stream); @@ -1884,32 +1872,24 @@ size_t Enum::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.EnumValue enumvalue = 2; - { - unsigned int count = static_cast(this->enumvalue_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->enumvalue(static_cast(i))); - } + total_size += 1UL * this->enumvalue_size(); + for (const auto& msg : this->enumvalue_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // repeated .google.protobuf.Option options = 3; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // .google.protobuf.SourceContext source_context = 4; @@ -1959,7 +1939,7 @@ void Enum::MergeFrom(const Enum& from) { enumvalue_.MergeFrom(from.enumvalue_); options_.MergeFrom(from.options_); if (from.name().size() > 0) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (from.has_source_context()) { mutable_source_context()->PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom(from.source_context()); @@ -1990,8 +1970,8 @@ bool Enum::IsInitialized() const { void Enum::InternalSwap(Enum* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&enumvalue_)->InternalSwap(CastToBase(&other->enumvalue_)); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + enumvalue_.InternalSwap(&other->enumvalue_); + options_.InternalSwap(&other->options_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(source_context_, other->source_context_); @@ -2030,8 +2010,8 @@ EnumValue::EnumValue(const EnumValue& from) options_(from.options_) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } number_ = from.number_; @@ -2093,7 +2073,7 @@ const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.EnumValue.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.EnumValue.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -2113,7 +2093,7 @@ const char* EnumValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID:: ptr = ctx->ParseMessage(add_options(), ptr); CHK_(ptr); if (!ctx->DataAvailable(ptr)) break; - } while (::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<::PROTOBUF_NAMESPACE_ID::uint8>(ptr) == 26); + } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } else goto handle_unusual; continue; default: { @@ -2150,9 +2130,9 @@ bool EnumValue::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.EnumValue.name")); } else { @@ -2215,11 +2195,11 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.EnumValue.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // int32 number = 2; @@ -2229,8 +2209,8 @@ failure: } // repeated .google.protobuf.Option options = 3; - for (auto it = this->options().pointer_begin(), - end = this->options().pointer_end(); it < end; ++it) { + for (auto it = this->options_.pointer_begin(), + end = this->options_.pointer_end(); it < end; ++it) { stream->EnsureSpace(&target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray(3, **it, target, stream); @@ -2253,21 +2233,17 @@ size_t EnumValue::ByteSizeLong() const { (void) cached_has_bits; // repeated .google.protobuf.Option options = 3; - { - unsigned int count = static_cast(this->options_size()); - total_size += 1UL * count; - for (unsigned int i = 0; i < count; i++) { - total_size += - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - this->options(static_cast(i))); - } + total_size += 1UL * this->options_size(); + for (const auto& msg : this->options_) { + total_size += + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } // string name = 1; if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // int32 number = 2; @@ -2310,7 +2286,7 @@ void EnumValue::MergeFrom(const EnumValue& from) { options_.MergeFrom(from.options_); if (from.name().size() > 0) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (from.number() != 0) { set_number(from.number()); @@ -2338,7 +2314,7 @@ bool EnumValue::IsInitialized() const { void EnumValue::InternalSwap(EnumValue* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); - CastToBase(&options_)->InternalSwap(CastToBase(&other->options_)); + options_.InternalSwap(&other->options_); name_.Swap(&other->name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(number_, other->number_); @@ -2400,8 +2376,8 @@ Option::Option(const Option& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.name().empty()) { - name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.name(), + if (!from._internal_name().empty()) { + name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_name(), GetArenaNoVirtual()); } if (from.has_value()) { @@ -2470,7 +2446,7 @@ const char* Option::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int // string name = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_name(), ptr, ctx, "google.protobuf.Option.name"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_name(), ptr, ctx, "google.protobuf.Option.name"); CHK_(ptr); } else goto handle_unusual; continue; @@ -2515,9 +2491,9 @@ bool Option::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_name())); + input, this->_internal_mutable_name())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.Option.name")); } else { @@ -2567,11 +2543,11 @@ failure: // string name = 1; if (this->name().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->name().data(), static_cast(this->name().length()), + this->_internal_name().data(), static_cast(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Option.name"); target = stream->WriteStringMaybeAliased( - 1, this->name(), target); + 1, this->_internal_name(), target); } // .google.protobuf.Any value = 2; @@ -2602,7 +2578,7 @@ size_t Option::ByteSizeLong() const { if (this->name().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->name()); + this->_internal_name()); } // .google.protobuf.Any value = 2; @@ -2644,7 +2620,7 @@ void Option::MergeFrom(const Option& from) { (void) cached_has_bits; if (from.name().size() > 0) { - set_name(from.name()); + _internal_set_name(from._internal_name()); } if (from.has_value()) { mutable_value()->PROTOBUF_NAMESPACE_ID::Any::MergeFrom(from.value()); diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 4742aec31a..49550a9f41 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -344,6 +344,9 @@ class PROTOBUF_EXPORT Type : void add_oneofs(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField& oneofs() const; ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField* mutable_oneofs(); + private: + std::string* _internal_add_oneofs(); + public: // repeated .google.protobuf.Option options = 4; int options_size() const; @@ -375,9 +378,17 @@ class PROTOBUF_EXPORT Type : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // .google.protobuf.SourceContext source_context = 5; bool has_source_context() const; + private: + bool _internal_has_source_context() const; + public: void clear_source_context(); const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); @@ -681,6 +692,11 @@ class PROTOBUF_EXPORT Field : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // string type_url = 6; void clear_type_url(); @@ -701,6 +717,11 @@ class PROTOBUF_EXPORT Field : " future release.") void unsafe_arena_set_allocated_type_url( std::string* type_url); + private: + const std::string& _internal_type_url() const; + void _internal_set_type_url(const std::string& value); + std::string* _internal_mutable_type_url(); + public: // string json_name = 10; void clear_json_name(); @@ -721,6 +742,11 @@ class PROTOBUF_EXPORT Field : " future release.") void unsafe_arena_set_allocated_json_name( std::string* json_name); + private: + const std::string& _internal_json_name() const; + void _internal_set_json_name(const std::string& value); + std::string* _internal_mutable_json_name(); + public: // string default_value = 11; void clear_default_value(); @@ -741,6 +767,11 @@ class PROTOBUF_EXPORT Field : " future release.") void unsafe_arena_set_allocated_default_value( std::string* default_value); + private: + const std::string& _internal_default_value() const; + void _internal_set_default_value(const std::string& value); + std::string* _internal_mutable_default_value(); + public: // .google.protobuf.Field.Kind kind = 1; void clear_kind(); @@ -968,9 +999,17 @@ class PROTOBUF_EXPORT Enum : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // .google.protobuf.SourceContext source_context = 4; bool has_source_context() const; + private: + bool _internal_has_source_context() const; + public: void clear_source_context(); const PROTOBUF_NAMESPACE_ID::SourceContext& source_context() const; PROTOBUF_NAMESPACE_ID::SourceContext* release_source_context(); @@ -1168,6 +1207,11 @@ class PROTOBUF_EXPORT EnumValue : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // int32 number = 2; void clear_number(); @@ -1343,9 +1387,17 @@ class PROTOBUF_EXPORT Option : " future release.") void unsafe_arena_set_allocated_name( std::string* name); + private: + const std::string& _internal_name() const; + void _internal_set_name(const std::string& value); + std::string* _internal_mutable_name(); + public: // .google.protobuf.Any value = 2; bool has_value() const; + private: + bool _internal_has_value() const; + public: void clear_value(); const PROTOBUF_NAMESPACE_ID::Any& value() const; PROTOBUF_NAMESPACE_ID::Any* release_value(); @@ -1385,12 +1437,22 @@ inline void Type::clear_name() { } inline const std::string& Type::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Type.name) - return name_.Get(); + return _internal_name(); } inline void Type::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Type.name) +} +inline std::string* Type::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) + return _internal_mutable_name(); +} +inline const std::string& Type::_internal_name() const { + return name_.Get(); +} +inline void Type::_internal_set_name(const std::string& value) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Type.name) } inline void Type::set_name(std::string&& value) { @@ -1412,9 +1474,8 @@ inline void Type::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name) } -inline std::string* Type::mutable_name() { +inline std::string* Type::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Type::release_name() { @@ -1489,6 +1550,10 @@ inline int Type::oneofs_size() const { inline void Type::clear_oneofs() { oneofs_.Clear(); } +inline std::string* Type::add_oneofs() { + // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs) + return _internal_add_oneofs(); +} inline const std::string& Type::oneofs(int index) const { // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs) return oneofs_.Get(index); @@ -1515,8 +1580,7 @@ inline void Type::set_oneofs(int index, const char* value, size_t size) { reinterpret_cast(value), size); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs) } -inline std::string* Type::add_oneofs() { - // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs) +inline std::string* Type::_internal_add_oneofs() { return oneofs_.Add(); } inline void Type::add_oneofs(const std::string& value) { @@ -1588,17 +1652,14 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Type::source_context() const &PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); } inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) - - PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; + auto temp = unsafe_arena_release_source_context(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - source_context_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::SourceContext* Type::unsafe_arena_release_source_context() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Type.source_context) + // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context) PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; source_context_ = nullptr; @@ -1698,12 +1759,22 @@ inline void Field::clear_name() { } inline const std::string& Field::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.name) - return name_.Get(); + return _internal_name(); } inline void Field::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Field.name) +} +inline std::string* Field::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) + return _internal_mutable_name(); +} +inline const std::string& Field::_internal_name() const { + return name_.Get(); +} +inline void Field::_internal_set_name(const std::string& value) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Field.name) } inline void Field::set_name(std::string&& value) { @@ -1725,9 +1796,8 @@ inline void Field::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name) } -inline std::string* Field::mutable_name() { +inline std::string* Field::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Field::release_name() { @@ -1771,12 +1841,22 @@ inline void Field::clear_type_url() { } inline const std::string& Field::type_url() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url) - return type_url_.Get(); + return _internal_type_url(); } inline void Field::set_type_url(const std::string& value) { + _internal_set_type_url(value); + // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) +} +inline std::string* Field::mutable_type_url() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) + return _internal_mutable_type_url(); +} +inline const std::string& Field::_internal_type_url() const { + return type_url_.Get(); +} +inline void Field::_internal_set_type_url(const std::string& value) { type_url_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url) } inline void Field::set_type_url(std::string&& value) { @@ -1798,9 +1878,8 @@ inline void Field::set_type_url(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url) } -inline std::string* Field::mutable_type_url() { +inline std::string* Field::_internal_mutable_type_url() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url) return type_url_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Field::release_type_url() { @@ -1902,12 +1981,22 @@ inline void Field::clear_json_name() { } inline const std::string& Field::json_name() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name) - return json_name_.Get(); + return _internal_json_name(); } inline void Field::set_json_name(const std::string& value) { + _internal_set_json_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) +} +inline std::string* Field::mutable_json_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) + return _internal_mutable_json_name(); +} +inline const std::string& Field::_internal_json_name() const { + return json_name_.Get(); +} +inline void Field::_internal_set_json_name(const std::string& value) { json_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name) } inline void Field::set_json_name(std::string&& value) { @@ -1929,9 +2018,8 @@ inline void Field::set_json_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name) } -inline std::string* Field::mutable_json_name() { +inline std::string* Field::_internal_mutable_json_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name) return json_name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Field::release_json_name() { @@ -1975,12 +2063,22 @@ inline void Field::clear_default_value() { } inline const std::string& Field::default_value() const { // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value) - return default_value_.Get(); + return _internal_default_value(); } inline void Field::set_default_value(const std::string& value) { + _internal_set_default_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) +} +inline std::string* Field::mutable_default_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) + return _internal_mutable_default_value(); +} +inline const std::string& Field::_internal_default_value() const { + return default_value_.Get(); +} +inline void Field::_internal_set_default_value(const std::string& value) { default_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value) } inline void Field::set_default_value(std::string&& value) { @@ -2002,9 +2100,8 @@ inline void Field::set_default_value(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value) } -inline std::string* Field::mutable_default_value() { +inline std::string* Field::_internal_mutable_default_value() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value) return default_value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Field::release_default_value() { @@ -2052,12 +2149,22 @@ inline void Enum::clear_name() { } inline const std::string& Enum::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Enum.name) - return name_.Get(); + return _internal_name(); } inline void Enum::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) +} +inline std::string* Enum::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) + return _internal_mutable_name(); +} +inline const std::string& Enum::_internal_name() const { + return name_.Get(); +} +inline void Enum::_internal_set_name(const std::string& value) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Enum.name) } inline void Enum::set_name(std::string&& value) { @@ -2079,9 +2186,8 @@ inline void Enum::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name) } -inline std::string* Enum::mutable_name() { +inline std::string* Enum::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Enum::release_name() { @@ -2190,17 +2296,14 @@ inline const PROTOBUF_NAMESPACE_ID::SourceContext& Enum::source_context() const &PROTOBUF_NAMESPACE_ID::_SourceContext_default_instance_); } inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::release_source_context() { - // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) - - PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; + auto temp = unsafe_arena_release_source_context(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - source_context_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::SourceContext* Enum::unsafe_arena_release_source_context() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Enum.source_context) + // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context) PROTOBUF_NAMESPACE_ID::SourceContext* temp = source_context_; source_context_ = nullptr; @@ -2258,12 +2361,22 @@ inline void EnumValue::clear_name() { } inline const std::string& EnumValue::name() const { // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name) - return name_.Get(); + return _internal_name(); } inline void EnumValue::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) +} +inline std::string* EnumValue::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) + return _internal_mutable_name(); +} +inline const std::string& EnumValue::_internal_name() const { + return name_.Get(); +} +inline void EnumValue::_internal_set_name(const std::string& value) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name) } inline void EnumValue::set_name(std::string&& value) { @@ -2285,9 +2398,8 @@ inline void EnumValue::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name) } -inline std::string* EnumValue::mutable_name() { +inline std::string* EnumValue::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* EnumValue::release_name() { @@ -2379,12 +2491,22 @@ inline void Option::clear_name() { } inline const std::string& Option::name() const { // @@protoc_insertion_point(field_get:google.protobuf.Option.name) - return name_.Get(); + return _internal_name(); } inline void Option::set_name(const std::string& value) { + _internal_set_name(value); + // @@protoc_insertion_point(field_set:google.protobuf.Option.name) +} +inline std::string* Option::mutable_name() { + // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name) + return _internal_mutable_name(); +} +inline const std::string& Option::_internal_name() const { + return name_.Get(); +} +inline void Option::_internal_set_name(const std::string& value) { name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.Option.name) } inline void Option::set_name(std::string&& value) { @@ -2406,9 +2528,8 @@ inline void Option::set_name(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name) } -inline std::string* Option::mutable_name() { +inline std::string* Option::_internal_mutable_name() { - // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name) return name_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* Option::release_name() { @@ -2457,17 +2578,14 @@ inline const PROTOBUF_NAMESPACE_ID::Any& Option::value() const { &PROTOBUF_NAMESPACE_ID::_Any_default_instance_); } inline PROTOBUF_NAMESPACE_ID::Any* Option::release_value() { - // @@protoc_insertion_point(field_release:google.protobuf.Option.value) - - PROTOBUF_NAMESPACE_ID::Any* temp = value_; + auto temp = unsafe_arena_release_value(); if (GetArenaNoVirtual() != nullptr) { temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); } - value_ = nullptr; return temp; } inline PROTOBUF_NAMESPACE_ID::Any* Option::unsafe_arena_release_value() { - // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.Option.value) + // @@protoc_insertion_point(field_release:google.protobuf.Option.value) PROTOBUF_NAMESPACE_ID::Any* temp = value_; value_ = nullptr; diff --git a/src/google/protobuf/unknown_field_set_unittest.cc b/src/google/protobuf/unknown_field_set_unittest.cc index 6d76b67b5b..b3af94b629 100644 --- a/src/google/protobuf/unknown_field_set_unittest.cc +++ b/src/google/protobuf/unknown_field_set_unittest.cc @@ -49,8 +49,6 @@ #include #include #include - - #include namespace google { diff --git a/src/google/protobuf/util/field_mask_util.cc b/src/google/protobuf/util/field_mask_util.cc index c4b2758bf9..d3f347ed32 100644 --- a/src/google/protobuf/util/field_mask_util.cc +++ b/src/google/protobuf/util/field_mask_util.cc @@ -31,7 +31,6 @@ #include #include - #include #include diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 55af434e97..8ffd824d80 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -34,7 +34,6 @@ #include #include #include - #include #include #include diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc index 6c3b58bf63..ec9ede881b 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.cc +++ b/src/google/protobuf/util/internal/default_value_objectwriter.cc @@ -67,7 +67,6 @@ DefaultValueObjectWriter::DefaultValueObjectWriter( suppress_empty_list_(false), preserve_proto_field_names_(false), use_ints_for_enums_(false), - field_scrub_callback_(nullptr), ow_(ow) {} DefaultValueObjectWriter::~DefaultValueObjectWriter() { @@ -183,8 +182,8 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderNull( } void DefaultValueObjectWriter::RegisterFieldScrubCallBack( - FieldScrubCallBackPtr field_scrub_callback) { - field_scrub_callback_.reset(field_scrub_callback.release()); + FieldScrubCallBack field_scrub_callback) { + field_scrub_callback_ = std::move(field_scrub_callback); } DefaultValueObjectWriter::Node* DefaultValueObjectWriter::CreateNewNode( @@ -192,10 +191,10 @@ DefaultValueObjectWriter::Node* DefaultValueObjectWriter::CreateNewNode( const DataPiece& data, bool is_placeholder, const std::vector& path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, - FieldScrubCallBack* field_scrub_callback) { + FieldScrubCallBack field_scrub_callback) { return new Node(name, type, kind, data, is_placeholder, path, suppress_empty_list, preserve_proto_field_names, - use_ints_for_enums, field_scrub_callback); + use_ints_for_enums, std::move(field_scrub_callback)); } DefaultValueObjectWriter::Node::Node( @@ -203,7 +202,7 @@ DefaultValueObjectWriter::Node::Node( const DataPiece& data, bool is_placeholder, const std::vector& path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, - FieldScrubCallBack* field_scrub_callback) + FieldScrubCallBack field_scrub_callback) : name_(name), type_(type), kind_(kind), @@ -214,7 +213,7 @@ DefaultValueObjectWriter::Node::Node( suppress_empty_list_(suppress_empty_list), preserve_proto_field_names_(preserve_proto_field_names), use_ints_for_enums_(use_ints_for_enums), - field_scrub_callback_(field_scrub_callback) {} + field_scrub_callback_(std::move(field_scrub_callback)) {} DefaultValueObjectWriter::Node* DefaultValueObjectWriter::Node::FindChild( StringPiece name) { @@ -329,8 +328,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren( path.insert(path.begin(), path_.begin(), path_.end()); } path.push_back(field.name()); - if (field_scrub_callback_ != nullptr && - field_scrub_callback_->Run(path, &field)) { + if (field_scrub_callback_ && field_scrub_callback_(path, &field)) { continue; } @@ -491,10 +489,10 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( StringPiece name) { if (current_ == nullptr) { std::vector path; - root_.reset(CreateNewNode( - std::string(name), &type_, OBJECT, DataPiece::NullData(), false, path, - suppress_empty_list_, preserve_proto_field_names_, use_ints_for_enums_, - field_scrub_callback_.get())); + root_.reset(CreateNewNode(std::string(name), &type_, OBJECT, + DataPiece::NullData(), false, path, + suppress_empty_list_, preserve_proto_field_names_, + use_ints_for_enums_, field_scrub_callback_)); root_->PopulateChildren(typeinfo_); current_ = root_.get(); return this; @@ -512,7 +510,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartObject( OBJECT, DataPiece::NullData(), false, child == nullptr ? current_->path() : child->path(), suppress_empty_list_, preserve_proto_field_names_, - use_ints_for_enums_, field_scrub_callback_.get())); + use_ints_for_enums_, field_scrub_callback_)); child = node.get(); current_->AddChild(node.release()); } @@ -542,10 +540,10 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( StringPiece name) { if (current_ == nullptr) { std::vector path; - root_.reset(CreateNewNode( - std::string(name), &type_, LIST, DataPiece::NullData(), false, path, - suppress_empty_list_, preserve_proto_field_names_, use_ints_for_enums_, - field_scrub_callback_.get())); + root_.reset(CreateNewNode(std::string(name), &type_, LIST, + DataPiece::NullData(), false, path, + suppress_empty_list_, preserve_proto_field_names_, + use_ints_for_enums_, field_scrub_callback_)); current_ = root_.get(); return this; } @@ -556,7 +554,7 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::StartList( std::string(name), nullptr, LIST, DataPiece::NullData(), false, child == nullptr ? current_->path() : child->path(), suppress_empty_list_, preserve_proto_field_names_, use_ints_for_enums_, - field_scrub_callback_.get())); + field_scrub_callback_)); child = node.get(); current_->AddChild(node.release()); } @@ -618,7 +616,7 @@ void DefaultValueObjectWriter::RenderDataPiece(StringPiece name, CreateNewNode(std::string(name), nullptr, PRIMITIVE, data, false, child == nullptr ? current_->path() : child->path(), suppress_empty_list_, preserve_proto_field_names_, - use_ints_for_enums_, field_scrub_callback_.get())); + use_ints_for_enums_, field_scrub_callback_)); current_->AddChild(node.release()); } else { child->set_data(data); diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index e3f34a7c9f..2975513a9a 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -31,11 +31,11 @@ #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ #define GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ +#include #include #include #include -#include #include #include #include @@ -44,6 +44,7 @@ #include #include +// Must be included last. #include namespace google { @@ -70,14 +71,11 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // "b", "c" }. // // The Field* should point to the google::protobuf::Field of "c". - typedef ResultCallback2& /*path of the field*/, - const google::protobuf::Field* /*field*/> + typedef std::function& /*path of the field*/, + const google::protobuf::Field* /*field*/)> FieldScrubCallBack; - // A unique pointer to a DefaultValueObjectWriter::FieldScrubCallBack. - typedef std::unique_ptr FieldScrubCallBackPtr; - DefaultValueObjectWriter(TypeResolver* type_resolver, const google::protobuf::Type& type, ObjectWriter* ow); @@ -121,9 +119,8 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { virtual DefaultValueObjectWriter* RenderNull(StringPiece name); - // Register the callback for scrubbing of fields. Owership of - // field_scrub_callback pointer is also transferred to this class - void RegisterFieldScrubCallBack(FieldScrubCallBackPtr field_scrub_callback); + // Register the callback for scrubbing of fields. + void RegisterFieldScrubCallBack(FieldScrubCallBack field_scrub_callback); // If set to true, empty lists are suppressed from output when default values // are written. @@ -154,7 +151,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { NodeKind kind, const DataPiece& data, bool is_placeholder, const std::vector& path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, - FieldScrubCallBack* field_scrub_callback); + FieldScrubCallBack field_scrub_callback); virtual ~Node() { for (int i = 0; i < children_.size(); ++i) { delete children_[i]; @@ -239,9 +236,8 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Whether to always print enums as ints bool use_ints_for_enums_; - // Pointer to function for determining whether a field needs to be scrubbed - // or not. This callback is owned by the creator of this node. - FieldScrubCallBack* field_scrub_callback_; + // Function for determining whether a field needs to be scrubbed or not. + FieldScrubCallBack field_scrub_callback_; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node); @@ -255,7 +251,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, - FieldScrubCallBack* field_scrub_callback); + FieldScrubCallBack field_scrub_callback); // Creates a DataPiece containing the default value of the type of the field. static DataPiece CreateDefaultDataPieceForField( @@ -317,9 +313,8 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Whether to always print enums as ints bool use_ints_for_enums_; - // Unique Pointer to function for determining whether a field needs to be - // scrubbed or not. - FieldScrubCallBackPtr field_scrub_callback_; + // Function for determining whether a field needs to be scrubbed or not. + FieldScrubCallBack field_scrub_callback_; ObjectWriter* ow_; diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc index 04908c55d5..faa00f79e3 100644 --- a/src/google/protobuf/util/internal/json_objectwriter.cc +++ b/src/google/protobuf/util/internal/json_objectwriter.cc @@ -36,7 +36,6 @@ #include #include #include - #include #include #include diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index b7a8c7872f..8fb6e959b9 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -40,7 +40,6 @@ #include #include #include - #include #include #include 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 7916085d2a..b7db879082 100644 --- a/src/google/protobuf/util/internal/json_stream_parser_test.cc +++ b/src/google/protobuf/util/internal/json_stream_parser_test.cc @@ -37,7 +37,6 @@ #include #include #include - #include diff --git a/src/google/protobuf/util/internal/protostream_objectsource.cc b/src/google/protobuf/util/internal/protostream_objectsource.cc index 1e247eb587..495ccc29c0 100644 --- a/src/google/protobuf/util/internal/protostream_objectsource.cc +++ b/src/google/protobuf/util/internal/protostream_objectsource.cc @@ -49,8 +49,6 @@ #include #include #include - - #include #include diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 7865f78537..17b17d8436 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -43,8 +43,6 @@ #include #include #include - - #include #include @@ -879,7 +877,32 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, const DataPiece& data) { std::string struct_field_name; switch (data.type()) { - // Our JSON parser parses numbers as either int64, uint64, or double. + case DataPiece::TYPE_INT32: { + if (ow->options_.struct_integers_as_strings) { + StatusOr int_value = data.ToInt32(); + if (int_value.ok()) { + ow->ProtoWriter::RenderDataPiece( + "string_value", + DataPiece(SimpleDtoa(int_value.ValueOrDie()), true)); + return Status(); + } + } + struct_field_name = "number_value"; + break; + } + case DataPiece::TYPE_UINT32: { + if (ow->options_.struct_integers_as_strings) { + StatusOr int_value = data.ToUint32(); + if (int_value.ok()) { + ow->ProtoWriter::RenderDataPiece( + "string_value", + DataPiece(SimpleDtoa(int_value.ValueOrDie()), true)); + return Status(); + } + } + struct_field_name = "number_value"; + break; + } case DataPiece::TYPE_INT64: { // If the option to treat integers as strings is set, then render them as // strings. Otherwise, fallback to rendering them as double. @@ -910,6 +933,19 @@ Status ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow, struct_field_name = "number_value"; break; } + case DataPiece::TYPE_FLOAT: { + if (ow->options_.struct_integers_as_strings) { + StatusOr float_value = data.ToFloat(); + if (float_value.ok()) { + ow->ProtoWriter::RenderDataPiece( + "string_value", + DataPiece(SimpleDtoa(float_value.ValueOrDie()), true)); + return Status(); + } + } + struct_field_name = "number_value"; + break; + } case DataPiece::TYPE_DOUBLE: { if (ow->options_.struct_integers_as_strings) { StatusOr double_value = data.ToDouble(); diff --git a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc index c4baaedb39..2148933f30 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter_test.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter_test.cc @@ -1719,6 +1719,45 @@ TEST_P(ProtoStreamObjectWriterStructTest, OptionStructIntAsStringsTest) { CheckOutput(struct_type); } +TEST_P(ProtoStreamObjectWriterStructTest, Struct32BitIntsAndFloatsTest) { + StructType struct_type; + google::protobuf::Struct* s = struct_type.mutable_object(); + s->mutable_fields()->operator[]("k1").set_number_value(1.5); + s->mutable_fields()->operator[]("k2").set_number_value(100); + s->mutable_fields()->operator[]("k3").set_number_value(100); + ResetProtoWriter(); + + ow_->StartObject("") + ->StartObject("object") + ->RenderFloat("k1", 1.5) + ->RenderInt32("k2", 100) + ->RenderUint32("k3", 100) + ->EndObject() + ->EndObject(); + CheckOutput(struct_type); +} + +TEST_P(ProtoStreamObjectWriterStructTest, + Struct32BitIntsAndFloatsAsStringsTest) { + StructType struct_type; + google::protobuf::Struct* s = struct_type.mutable_object(); + s->mutable_fields()->operator[]("k1").set_string_value("1.5"); + s->mutable_fields()->operator[]("k2").set_string_value("100"); + s->mutable_fields()->operator[]("k3").set_string_value("100"); + + options_.struct_integers_as_strings = true; + ResetProtoWriter(); + + ow_->StartObject("") + ->StartObject("object") + ->RenderFloat("k1", 1.5) + ->RenderInt32("k2", 100) + ->RenderUint32("k3", 100) + ->EndObject() + ->EndObject(); + CheckOutput(struct_type); +} + TEST_P(ProtoStreamObjectWriterStructTest, ValuePreservesNull) { ValueWrapper value; value.mutable_value()->set_null_value(google::protobuf::NULL_VALUE); diff --git a/src/google/protobuf/util/internal/utility.h b/src/google/protobuf/util/internal/utility.h index c960d9e87f..703d2a7604 100644 --- a/src/google/protobuf/util/internal/utility.h +++ b/src/google/protobuf/util/internal/utility.h @@ -42,7 +42,6 @@ #include #include #include - #include #include diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 52ce331005..2f3e6c6ba5 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -43,7 +43,6 @@ #include #include #include - #include #include diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 421db45fbf..de08096b13 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -35,12 +35,12 @@ #include #include +#include #include #include -#include -#include #include +#include #include #include #include @@ -52,7 +52,6 @@ #include #include - // Always include as last one, otherwise it can break compilation #include @@ -1463,7 +1462,7 @@ namespace { // Find maximum bipartite matching using the argumenting path algorithm. class MaximumMatcher { public: - typedef ResultCallback2 NodeMatchCallback; + typedef std::function NodeMatchCallback; // MaximumMatcher takes ownership of the passed in callback and uses it to // determine whether a node on the left side of the bipartial graph matches // a node on the right side. count1 is the number of nodes on the left side @@ -1474,7 +1473,7 @@ class MaximumMatcher { // matched to the j-th node on the right side and match_list2[x] == y means // 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, + MaximumMatcher(int count1, int count2, NodeMatchCallback callback, std::vector* match_list1, std::vector* 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 @@ -1492,7 +1491,7 @@ class MaximumMatcher { int count1_; int count2_; - std::unique_ptr match_callback_; + NodeMatchCallback match_callback_; std::map, bool> cached_match_results_; std::vector* match_list1_; std::vector* match_list2_; @@ -1500,11 +1499,14 @@ class MaximumMatcher { }; MaximumMatcher::MaximumMatcher(int count1, int count2, - NodeMatchCallback* callback, + NodeMatchCallback callback, std::vector* match_list1, std::vector* match_list2) - : count1_(count1), count2_(count2), match_callback_(callback), - match_list1_(match_list1), match_list2_(match_list2) { + : count1_(count1), + count2_(count2), + match_callback_(std::move(callback)), + match_list1_(match_list1), + match_list2_(match_list2) { match_list1_->assign(count1, -1); match_list2_->assign(count2, -1); } @@ -1536,7 +1538,7 @@ bool MaximumMatcher::Match(int left, int right) { if (it != cached_match_results_.end()) { return it->second; } - cached_match_results_[p] = match_callback_->Run(left, right); + cached_match_results_[p] = match_callback_(left, right); return cached_match_results_[p]; } @@ -1605,10 +1607,12 @@ 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 augmenting path algorithm. - MaximumMatcher::NodeMatchCallback* callback = ::google::protobuf::NewPermanentCallback( - this, &MessageDifferencer::IsMatch, repeated_field, key_comparator, - &message1, &message2, parent_fields, nullptr); - MaximumMatcher matcher(count1, count2, callback, match_list1, match_list2); + auto callback = [&](int i1, int i2) { + return IsMatch(repeated_field, key_comparator, &message1, &message2, + parent_fields, nullptr, i1, i2); + }; + MaximumMatcher matcher(count1, count2, std::move(callback), match_list1, + match_list2); // If diff info is not needed, we should end the matching process as // soon as possible if not all items can be matched. bool early_return = (reporter == nullptr); diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h index e249b76e99..dd4267b512 100644 --- a/src/google/protobuf/util/message_differencer.h +++ b/src/google/protobuf/util/message_differencer.h @@ -112,11 +112,11 @@ typedef std::vector FieldDescriptorArray; // unpacks Any::value into a Message and compares its individual fields. // Messages encoded in a repeated Any cannot be compared using TreatAsMap. // -// // Note on thread-safety: MessageDifferencer is *not* thread-safe. You need to // guard it with a lock to use the same MessageDifferencer instance from // multiple threads. Note that it's fine to call static comparison methods -// (like MessageDifferencer::Equals) concurrently. +// (like MessageDifferencer::Equals) concurrently, but it's not recommended for +// performance critical code as it leads to extra allocations. class PROTOBUF_EXPORT MessageDifferencer { public: // Determines whether the supplied messages are equal. Equality is defined as diff --git a/src/google/protobuf/util/time_util.cc b/src/google/protobuf/util/time_util.cc index 68a3e675bb..e61562733d 100644 --- a/src/google/protobuf/util/time_util.cc +++ b/src/google/protobuf/util/time_util.cc @@ -37,8 +37,6 @@ #include #include - - #include namespace google { diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc index b652f9fc00..35736f1007 100644 --- a/src/google/protobuf/util/type_resolver_util.cc +++ b/src/google/protobuf/util/type_resolver_util.cc @@ -37,7 +37,6 @@ #include #include #include - #include // clang-format off diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index b48815eb85..f2017da0cd 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc @@ -37,15 +37,17 @@ #include #include #include + #include #include #include -#include +#include #include #include -#include +#include + namespace google { namespace protobuf { namespace internal { @@ -551,8 +553,7 @@ PROTOBUF_ALWAYS_INLINE static bool ReadBytesToString( inline static bool ReadBytesToString(io::CodedInputStream* input, std::string* value) { uint32 length; - return input->ReadVarint32(&length) && - input->InternalReadStringInline(value, length); + return input->ReadVarint32(&length) && input->ReadString(value, length); } bool WireFormatLite::ReadBytes(io::CodedInputStream* input, diff --git a/src/google/protobuf/wrappers.pb.cc b/src/google/protobuf/wrappers.pb.cc index 8cb2094da5..84087326fb 100644 --- a/src/google/protobuf/wrappers.pb.cc +++ b/src/google/protobuf/wrappers.pb.cc @@ -64,7 +64,7 @@ static void InitDefaultsscc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto( } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_BoolValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -78,7 +78,7 @@ static void InitDefaultsscc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_BytesValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -92,7 +92,7 @@ static void InitDefaultsscc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eprot } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_DoubleValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -106,7 +106,7 @@ static void InitDefaultsscc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_FloatValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -120,7 +120,7 @@ static void InitDefaultsscc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Int32Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -134,7 +134,7 @@ static void InitDefaultsscc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Int64Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -148,7 +148,7 @@ static void InitDefaultsscc_info_StringValue_google_2fprotobuf_2fwrappers_2eprot } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_StringValue_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -162,7 +162,7 @@ static void InitDefaultsscc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eprot } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_UInt32Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; static void InitDefaultsscc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -176,7 +176,7 @@ static void InitDefaultsscc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eprot } PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsscc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_UInt64Value_google_2fprotobuf_2fwrappers_2eproto}, {}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fwrappers_2eproto[9]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_google_2fprotobuf_2fwrappers_2eproto = nullptr; @@ -2043,8 +2043,8 @@ StringValue::StringValue(const StringValue& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.value().empty()) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value(), + if (!from._internal_value().empty()) { + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_value(), GetArenaNoVirtual()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue) @@ -2102,7 +2102,7 @@ const char* StringValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID // string value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(mutable_value(), ptr, ctx, "google.protobuf.StringValue.value"); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8(_internal_mutable_value(), ptr, ctx, "google.protobuf.StringValue.value"); CHK_(ptr); } else goto handle_unusual; continue; @@ -2140,9 +2140,9 @@ bool StringValue::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( - input, this->mutable_value())); + input, this->_internal_mutable_value())); DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->value().data(), static_cast(this->value().length()), + this->_internal_value().data(), static_cast(this->_internal_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::PARSE, "google.protobuf.StringValue.value")); } else { @@ -2181,11 +2181,11 @@ failure: // string value = 1; if (this->value().size() > 0) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->value().data(), static_cast(this->value().length()), + this->_internal_value().data(), static_cast(this->_internal_value().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.StringValue.value"); target = stream->WriteStringMaybeAliased( - 1, this->value(), target); + 1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -2208,7 +2208,7 @@ size_t StringValue::ByteSizeLong() const { if (this->value().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->value()); + this->_internal_value()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -2243,7 +2243,7 @@ void StringValue::MergeFrom(const StringValue& from) { (void) cached_has_bits; if (from.value().size() > 0) { - set_value(from.value()); + _internal_set_value(from._internal_value()); } } @@ -2302,8 +2302,8 @@ BytesValue::BytesValue(const BytesValue& from) _internal_metadata_(nullptr) { _internal_metadata_.MergeFrom(from._internal_metadata_); value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (!from.value().empty()) { - value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.value(), + if (!from._internal_value().empty()) { + value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_value(), GetArenaNoVirtual()); } // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue) @@ -2361,7 +2361,7 @@ const char* BytesValue::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID: // bytes value = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { - ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(mutable_value(), ptr, ctx); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(_internal_mutable_value(), ptr, ctx); CHK_(ptr); } else goto handle_unusual; continue; @@ -2399,7 +2399,7 @@ bool BytesValue::MergePartialFromCodedStream( case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (10 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadBytes( - input, this->mutable_value())); + input, this->_internal_mutable_value())); } else { goto handle_unusual; } @@ -2436,7 +2436,7 @@ failure: // bytes value = 1; if (this->value().size() > 0) { target = stream->WriteBytesMaybeAliased( - 1, this->value(), target); + 1, this->_internal_value(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -2459,7 +2459,7 @@ size_t BytesValue::ByteSizeLong() const { if (this->value().size() > 0) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( - this->value()); + this->_internal_value()); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -2494,7 +2494,7 @@ void BytesValue::MergeFrom(const BytesValue& from) { (void) cached_has_bits; if (from.value().size() > 0) { - set_value(from.value()); + _internal_set_value(from._internal_value()); } } diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index f99c8224a6..25b5b00cd8 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -1314,6 +1314,11 @@ class PROTOBUF_EXPORT StringValue : " future release.") void unsafe_arena_set_allocated_value( std::string* value); + private: + const std::string& _internal_value() const; + void _internal_set_value(const std::string& value); + std::string* _internal_mutable_value(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.StringValue) private: @@ -1481,6 +1486,11 @@ class PROTOBUF_EXPORT BytesValue : " future release.") void unsafe_arena_set_allocated_value( std::string* value); + private: + const std::string& _internal_value() const; + void _internal_set_value(const std::string& value); + std::string* _internal_mutable_value(); + public: // @@protoc_insertion_point(class_scope:google.protobuf.BytesValue) private: @@ -1637,12 +1647,22 @@ inline void StringValue::clear_value() { } inline const std::string& StringValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value) - return value_.Get(); + return _internal_value(); } inline void StringValue::set_value(const std::string& value) { + _internal_set_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) +} +inline std::string* StringValue::mutable_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value) + return _internal_mutable_value(); +} +inline const std::string& StringValue::_internal_value() const { + return value_.Get(); +} +inline void StringValue::_internal_set_value(const std::string& value) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value) } inline void StringValue::set_value(std::string&& value) { @@ -1664,9 +1684,8 @@ inline void StringValue::set_value(const char* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value) } -inline std::string* StringValue::mutable_value() { +inline std::string* StringValue::_internal_mutable_value() { - // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value) return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* StringValue::release_value() { @@ -1714,12 +1733,22 @@ inline void BytesValue::clear_value() { } inline const std::string& BytesValue::value() const { // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value) - return value_.Get(); + return _internal_value(); } inline void BytesValue::set_value(const std::string& value) { + _internal_set_value(value); + // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) +} +inline std::string* BytesValue::mutable_value() { + // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value) + return _internal_mutable_value(); +} +inline const std::string& BytesValue::_internal_value() const { + return value_.Get(); +} +inline void BytesValue::_internal_set_value(const std::string& value) { value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual()); - // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value) } inline void BytesValue::set_value(std::string&& value) { @@ -1741,9 +1770,8 @@ inline void BytesValue::set_value(const void* value, reinterpret_cast(value), size), GetArenaNoVirtual()); // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value) } -inline std::string* BytesValue::mutable_value() { +inline std::string* BytesValue::_internal_mutable_value() { - // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value) return value_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); } inline std::string* BytesValue::release_value() { diff --git a/tests.sh b/tests.sh index 504bfdac67..27db44424b 100755 --- a/tests.sh +++ b/tests.sh @@ -147,6 +147,10 @@ build_csharp() { # Run csharp compatibility test between 3.0.0 and the current version. csharp/compatibility_tests/v3.0.0/test.sh 3.0.0 + + LAST_RELEASED=3.9.0 + # Run csharp compatibility test between last released and the current version. + csharp/compatibility_tests/v3.0.0/test.sh $LAST_RELEASED } build_golang() { diff --git a/update_compatibility_version.py b/update_compatibility_version.py new file mode 100644 index 0000000000..7e11151996 --- /dev/null +++ b/update_compatibility_version.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# Usage: ./update_compatibility_version.py .. [] +# +# Example: +# ./update_compatibility_version.py 3.7.1 + +import datetime +import re +import sys +from xml.dom import minidom + +if len(sys.argv) < 2 or len(sys.argv) > 3: + print """ +[ERROR] Please specify a version. + +./update_version.py .. [] + +Example: +./update_version.py 3.7.1 2 +""" + exit(1) + +NEW_VERSION = sys.argv[1] +NEW_VERSION_INFO = NEW_VERSION.split('.') +if len(NEW_VERSION_INFO) != 3: + print """ +[ERROR] Version must be in the format .. + +Example: +./update_version.py 3.7.3 +""" + exit(1) + +if len(sys.argv) > 2: + RC_VERSION = int(sys.argv[2]) + # Do not update compatibility versions for rc release + if RC_VERSION != 0: + exit(0) + +def RewriteTextFile(filename, line_rewriter): + lines = open(filename, 'r').readlines() + updated_lines = [] + for line in lines: + updated_lines.append(line_rewriter(line)) + if lines == updated_lines: + print '%s was not updated. Please double check.' % filename + f = open(filename, 'w') + f.write(''.join(updated_lines)) + f.close() + + +def UpdateCsharp(): + RewriteTextFile('csharp/compatibility_tests/v3.0.0/test.sh', + lambda line : re.sub( + r'LAST_RELEASED=.*$', + 'LAST_RELEASED=%s' % NEW_VERSION, + line)) + +def UpdateTests(): + RewriteTextFile('tests.sh', + lambda line : re.sub( + r'LAST_RELEASED=.*$', + 'LAST_RELEASED=%s' % NEW_VERSION, + line)) + + +UpdateCsharp() +UpdateTests() diff --git a/update_file_lists.sh b/update_file_lists.sh index 646c8ce344..e0b446f867 100755 --- a/update_file_lists.sh +++ b/update_file_lists.sh @@ -63,6 +63,7 @@ WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) COMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) +NON_MSVC_TEST_SOURCES=$(get_source_files $MAKEFILE NON_MSVC_TEST_SOURCES) LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) LITE_ARENA_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_arena_test_SOURCES) TEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES) @@ -123,6 +124,7 @@ set_cmake_value $CMAKE_DIR/tests.cmake tests_protos "" $PROTOS_BLACKLISTED set_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES +set_cmake_value $CMAKE_DIR/tests.cmake non_msvc_tests_files $CMAKE_PREFIX $NON_MSVC_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake lite_test_files $CMAKE_PREFIX $LITE_TEST_SOURCES set_cmake_value $CMAKE_DIR/tests.cmake lite_arena_test_files $CMAKE_PREFIX $LITE_ARENA_TEST_SOURCES @@ -186,6 +188,7 @@ if [ -f "$BAZEL_BUILD" ]; then set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES + set_bazel_value $BAZEL_BUILD non_msvc_test_srcs $BAZEL_PREFIX $NON_MSVC_TEST_SOURCES set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES else echo "Skipped BUILD file update." diff --git a/update_version.py b/update_version.py index 311b25c59f..ddb2480c1e 100755 --- a/update_version.py +++ b/update_version.py @@ -250,6 +250,11 @@ def UpdateObjectiveC(): r"^ s.version = '.*'$", " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), line)) + RewriteTextFile('Protobuf-C++.podspec', + lambda line : re.sub( + r"^ s.version = '.*'$", + " s.version = '%s'" % GetFullVersion(rc_suffix = '-rc'), + line)) def UpdatePhp():