diff --git a/.bazelrc b/.bazelrc index 732859d082..554440cfe3 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1 +1 @@ -build --cxxopt=-std=c++14 \ No newline at end of file +build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 diff --git a/.github/workflows/generated_cmake.yml b/.github/workflows/generated_cmake.yml index 91dcd4f1e7..640bd137ec 100644 --- a/.github/workflows/generated_cmake.yml +++ b/.github/workflows/generated_cmake.yml @@ -1,24 +1,29 @@ -name: Generated CMake File Lists +name: Generate CMake File Lists on: - - push - - pull_request + push: + branches: + - main + - '[0-9]+.x' + # The 21.x branch predates support for auto-generation of the CMake file + # lists, so we make sure to exclude it. + - '!21.x' jobs: cmake: + if: github.repository == 'protocolbuffers/protobuf' runs-on: ubuntu-latest strategy: fail-fast: false # Don't cancel all jobs if one fails. steps: - - uses: actions/checkout@v2 - - name: Set up Bazel read-only caching - run: echo "BAZEL_CACHE_AUTH=--remote_upload_local_results=false" >> $GITHUB_ENV - - name: Generate CMake files - run: cd ${{ github.workspace }} && bazel build //pkg:gen_src_file_lists --test_output=errors $BAZEL_CACHE $BAZEL_CACHE_AUTH - - name: Compare to Golden file - run: diff -du bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake - - name: Report - run: echo "::error file=cmake/update_file_lists.sh::CMake files are stale, please run cmake/update_file_lists.sh" - if: failure() + - uses: actions/checkout@v3 + with: + # Note: this token has an expiration date, so if the workflow starts + # failing then you may need to generate a fresh token. + token: ${{ secrets.BOT_ACCESS_TOKEN }} + - name: Configure name and email address in Git + run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com" + - name: Commit and push update + run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh diff --git a/BUILD.bazel b/BUILD.bazel index 67cd2dbfc4..b63b7bf984 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -294,18 +294,8 @@ alias( proto_lang_toolchain( name = "cc_toolchain", blacklisted_protos = [ - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:api_proto", "@com_google_protobuf//:compiler_plugin_proto", "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:field_mask_proto", - "@com_google_protobuf//:source_context_proto", - "@com_google_protobuf//:struct_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:type_proto", - "@com_google_protobuf//:wrappers_proto", ], command_line = "--cpp_out=$(OUT)", runtime = ":protobuf", diff --git a/CHANGES.txt b/CHANGES.txt index 8cd58aa13b..2dc86330a3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -43,6 +43,11 @@ Compiler * Print full path name of source .proto file on error +2022-09-13 version 21.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby) + +C++ +* Reduce memory consumption of MessageSet parsing + 2022-08-09 version 21.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby) PHP diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f9b7517f3..dead8be84a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,10 @@ endif() if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) endif() +# Honor visibility properties for all target types. +if(POLICY CMP0063) + cmake_policy(SET CMP0063 NEW) +endif() # Project project(protobuf C CXX) @@ -32,15 +36,32 @@ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE) get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY) endif() -# Add c++14 flags -if (CYGWIN) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14") -else() +# Add C++14 flags +if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) +endif() +if(CYGWIN) + string(REGEX_MATCH "-std=gnu\\+\\+([0-9]+)" _protobuf_CXX_STD "${CMAKE_CXX_FLAGS}") +endif() +if(NOT _protobuf_CXX_STD) + set(_protobuf_CXX_STD "${CMAKE_CXX_STANDARD}") +endif() +if(_protobuf_CXX_STD LESS "14") + message(FATAL_ERROR "Protocol Buffers requires at least C++14, but is configured for C++${_protobuf_CXX_STD}") +endif() +if(CYGWIN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++${_protobuf_CXX_STD}") +else() + set(CMAKE_CXX_STANDARD ${_protobuf_CXX_STD}) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) endif() +# For -fvisibility=hidden and -fvisibility-inlines-hidden +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + # The Intel compiler isn't able to deal with noinline member functions of # template classes defined in headers. As such it spams the output with # warning #2196: routine is both "inline" and "noinline" diff --git a/Protobuf.podspec b/Protobuf.podspec index eb87a8f81a..b3e843485e 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -5,7 +5,7 @@ # dependent projects use the :git notation to refer to the library. Pod::Spec.new do |s| s.name = 'Protobuf' - s.version = '3.21.5' + s.version = '3.21.6' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = 'BSD-3-Clause' diff --git a/conformance/README.md b/conformance/README.md index 2f62f0ff90..8569a6a7b3 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -81,7 +81,7 @@ Ruby: JRuby: $ [[ $(ruby --version) == "jruby"* ]] || echo "Switch to Java Ruby!" - $ bazel test //ruby:conformance_test --define=ruby_platform=java \ + $ bazel test //ruby:conformance_test_jruby --define=ruby_platform=java \ --action_env=PATH --action_env=GEM_PATH --action_env=GEM_HOME Testing other Protocol Buffer implementations diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 5b71f9f040..096d0a47c1 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.21.5 + 3.21.6 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/main/LICENSE diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index b5d6c0bbe3..c03b326c08 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -576,6 +576,10 @@ namespace Google.Protobuf [TestCase("-3.402823e38", -3.402823e38f)] [TestCase("1.5e1", 15f)] [TestCase("15e-1", 1.5f)] + [TestCase("3.4028235e38", float.MaxValue)] + [TestCase("-3.4028235e38", float.MinValue)] + [TestCase("3.4028235e+38", float.MaxValue)] + [TestCase("-3.4028235e+38", float.MinValue)] public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue) { string json = "{ \"singleFloat\": " + jsonValue + "}"; @@ -584,8 +588,10 @@ namespace Google.Protobuf } [Test] - [TestCase("3.402824e38", typeof(InvalidProtocolBufferException))] - [TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))] + [TestCase("3.4028236e38", typeof(InvalidProtocolBufferException))] + [TestCase("-3.4028236e38", typeof(InvalidProtocolBufferException))] + [TestCase("3.4028236e+38", typeof(InvalidProtocolBufferException))] + [TestCase("-3.4028236e+38", typeof(InvalidProtocolBufferException))] [TestCase("1,0", typeof(InvalidJsonException))] [TestCase("1.0.0", typeof(InvalidJsonException))] [TestCase("+1", typeof(InvalidJsonException))] diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index eb5df6fa4d..af93a2c6d9 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.21.5 + 3.21.6 10.0 Google Inc. netstandard1.1;netstandard2.0;net45;net50 diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 3575e2529e..6cb98d6e24 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -642,19 +642,15 @@ namespace Google.Protobuf { return float.NaN; } - if (value > float.MaxValue || value < float.MinValue) + float converted = (float) value; + // If the value is out of range of float, the cast representation will be infinite. + // If the original value was infinite as well, that's fine - we'll return the 32-bit + // version (with the correct sign). + if (float.IsInfinity(converted) && !double.IsInfinity(value)) { - if (double.IsPositiveInfinity(value)) - { - return float.PositiveInfinity; - } - if (double.IsNegativeInfinity(value)) - { - return float.NegativeInfinity; - } throw new InvalidProtocolBufferException($"Value out of range: {value}"); } - return (float) value; + return converted; case FieldType.Enum: CheckInteger(value); // Just return it as an int, and let the CLR convert it. diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index c290558135..e252372edd 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -6641,6 +6641,10 @@ namespace Google.Protobuf.Reflection { private bool mapEntry_; /// + /// NOTE: Do not set the option in .proto files. Always use the maps syntax + /// instead. The option should only be implicitly set by the proto compiler + /// parser. + /// /// Whether the message is an automatically generated map entry type for the /// maps field. /// @@ -6658,10 +6662,6 @@ namespace Google.Protobuf.Reflection { /// use a native map in the target language to hold the keys and values. /// The reflection APIs in such implementations still need to work as /// if the field is a repeated message field. - /// - /// NOTE: Do not set the option in .proto files. Always use the maps syntax - /// instead. The option should only be implicitly set by the proto compiler - /// parser. /// [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] diff --git a/docs/options.md b/docs/options.md index dc19688235..87f7dca50b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -344,3 +344,7 @@ with info about your project (name and website) so we can add an entry for you. 1. mypy-protobuf * Website: https://github.com/nipunn1313/mypy-protobuf * Extension: 1151-1154 + +1. Pigweed protobuf compiler + * Website: https://pigweed.dev/pw_protobuf + * Extension: 1155 diff --git a/examples/.bazelrc b/examples/.bazelrc new file mode 100644 index 0000000000..554440cfe3 --- /dev/null +++ b/examples/.bazelrc @@ -0,0 +1 @@ +build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 diff --git a/java/README.md b/java/README.md index 3a022f0929..6a23c0d9e8 100644 --- a/java/README.md +++ b/java/README.md @@ -23,7 +23,7 @@ If you are using Maven, use the following: com.google.protobuf protobuf-java - 3.21.5 + 3.21.6 ``` @@ -37,7 +37,7 @@ protobuf-java-util package: com.google.protobuf protobuf-java-util - 3.21.5 + 3.21.6 ``` @@ -45,7 +45,7 @@ protobuf-java-util package: If you are using Gradle, add the following to your `build.gradle` file's dependencies: ``` - implementation 'com.google.protobuf:protobuf-java:3.21.5' + implementation 'com.google.protobuf:protobuf-java:3.21.6' ``` Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using. diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 4504729f9c..1196d3685c 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.21.5 + 3.21.6 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 9315004516..7e5e8df1d7 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 protobuf-java 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 7fba30a04e..aa1cc34a6a 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java @@ -61,7 +61,6 @@ public final class TextFormat { private static final String DEBUG_STRING_SILENT_MARKER = "\t "; - /** * Outputs a textual representation of the Protocol Message supplied into the parameter output. * (This representation is the new version of the classic "ProtocolPrinter" output from the @@ -739,9 +738,9 @@ public final class TextFormat { // Groups must be serialized with their original capitalization. generator.print(field.getMessageType().getName()); } else { - generator.print(field.getName()); - } + generator.print(field.getName()); } + } if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { generator.print(" {"); @@ -1836,16 +1835,16 @@ public final class TextFormat { extension = target.findExtensionByName(extensionRegistry, name); if (extension == null) { - String message = - (tokenizer.getPreviousLine() + 1) - + ":" - + (tokenizer.getPreviousColumn() + 1) - + ":\t" - + type.getFullName() - + ".[" - + name - + "]"; - unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION)); + String message = + (tokenizer.getPreviousLine() + 1) + + ":" + + (tokenizer.getPreviousColumn() + 1) + + ":\t" + + type.getFullName() + + ".[" + + name + + "]"; + unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION)); } else { if (extension.descriptor.getContainingType() != type) { throw tokenizer.parseExceptionPreviousToken( diff --git a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto index 4ec968819b..95ab8c06d4 100644 --- a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto +++ b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto @@ -125,6 +125,3 @@ message ReservedAsMapFieldWithEnumValue { // null is not a 'reserved word' per se but as a literal needs similar care map null = 10; } -package map_for_proto2_lite_test; -option java_package = "map_lite_test"; -option optimize_for = LITE_RUNTIME; diff --git a/java/kotlin-lite/pom.xml b/java/kotlin-lite/pom.xml index 03f28f5901..52bc1b3675 100644 --- a/java/kotlin-lite/pom.xml +++ b/java/kotlin-lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 protobuf-kotlin-lite diff --git a/java/kotlin/pom.xml b/java/kotlin/pom.xml index 5fefa8157c..bc935c8c23 100644 --- a/java/kotlin/pom.xml +++ b/java/kotlin/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 protobuf-kotlin diff --git a/java/lite.md b/java/lite.md index 2445ec3a88..6f003ed543 100644 --- a/java/lite.md +++ b/java/lite.md @@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following: com.google.protobuf protobuf-javalite - 3.21.5 + 3.21.6 ``` diff --git a/java/lite/pom.xml b/java/lite/pom.xml index c5ef4abc0d..ba65f5cbf4 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index f8083c430a..197e7cd584 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 987163247d..0f02bb84df 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.21.5 + 3.21.6 protobuf-java-util diff --git a/kokoro/linux/32-bit/test_php.sh b/kokoro/linux/32-bit/test_php.sh index 3770b84af3..739467b20c 100644 --- a/kokoro/linux/32-bit/test_php.sh +++ b/kokoro/linux/32-bit/test_php.sh @@ -36,9 +36,13 @@ build_php_c() { test_php_c } -cmake . -cmake --build . --target protoc -- -j20 +mkdir build +pushd build +cmake .. +cmake --build . -- -j20 +ctest --verbose --parallel 20 export PROTOC=$(pwd)/protoc +popd build_php 7.0 build_php 7.1 @@ -49,3 +53,6 @@ build_php_c 7.4 build_php_c 7.1-zts build_php_c 7.2-zts build_php_c 7.5-zts + +# Cleanup after CMake build +rm -rf build diff --git a/kokoro/linux/bazel/common.cfg b/kokoro/linux/bazel/common.cfg index 6d35d8bbaa..cd41cb2cb8 100644 --- a/kokoro/linux/bazel/common.cfg +++ b/kokoro/linux/bazel/common.cfg @@ -6,7 +6,7 @@ timeout_mins: 15 env_vars { key: "BAZEL_TARGETS" - value: "//src/..." + value: "//src/... @com_google_protobuf_examples//..." } action { diff --git a/kokoro/linux/cmake/build.sh b/kokoro/linux/cmake/build.sh index 523253da25..ee06d95cf9 100755 --- a/kokoro/linux/cmake/build.sh +++ b/kokoro/linux/cmake/build.sh @@ -19,7 +19,7 @@ docker run \ --cidfile $tmpfile \ -v $GIT_REPO_ROOT:/workspace \ $CONTAINER_IMAGE \ - /test.sh -Dprotobuf_BUILD_CONFORMANCE=ON + /test.sh -Dprotobuf_BUILD_CONFORMANCE=ON -Dprotobuf_BUILD_EXAMPLES=ON # Save logs for Kokoro docker cp \ diff --git a/kokoro/macos/ruby31/build.sh b/kokoro/macos/ruby31/build.sh index 57914bd060..6e4beda2cc 100644 --- a/kokoro/macos/ruby31/build.sh +++ b/kokoro/macos/ruby31/build.sh @@ -5,6 +5,9 @@ # Change to repo root cd $(dirname $0)/../../.. +# Fix locale issues in Monterey. +export LC_ALL=en_US.UTF-8 + # Prepare worker environment to run tests KOKORO_INSTALL_RVM=yes source kokoro/macos/prepare_build_macos_rc diff --git a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh index ae973fce43..4002d6d1f7 100755 --- a/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh +++ b/kokoro/release/ruby/macos/ruby/ruby_build_environment.sh @@ -2,6 +2,10 @@ set -ex +# Fix permissions +sudo chown -R $(whoami) $HOME/.rvm/ +sudo chown -R $(whoami) /Library/Ruby/ + set +ex # rvm script is very verbose and exits with errorcode # Fix permissions diff --git a/kokoro/windows/bazel/build.bat b/kokoro/windows/bazel/build.bat index 0b2ba9fc13..55fba16579 100644 --- a/kokoro/windows/bazel/build.bat +++ b/kokoro/windows/bazel/build.bat @@ -24,7 +24,7 @@ bazel %BAZEL_STARTUP% build //:protoc //:protobuf //:protobuf_lite %BAZEL_FLAGS% @rem TODO(b/241484899) Enable conformance tests on windows. bazel %BAZEL_STARTUP% test %BAZEL_FLAGS% ^ --test_tag_filters=-conformance --build_tag_filters=-conformance ^ - //src/... || goto :error + //src/... @com_google_protobuf_examples//... || goto :error goto :EOF diff --git a/kokoro/windows/cmake/build.bat b/kokoro/windows/cmake/build.bat index 29d012ba1c..d24e635d24 100644 --- a/kokoro/windows/cmake/build.bat +++ b/kokoro/windows/cmake/build.bat @@ -6,13 +6,14 @@ call kokoro\windows\prepare_build_win64.bat || goto :error @rem TODO(b/241475022) Use docker to guarantee better stability. @rem TODO(b/241484899) Run conformance tests in windows. -md build -ea 0 -md %KOKORO_ARTIFACTS_DIR%\logs -ea 0 +md build +md %KOKORO_ARTIFACTS_DIR%\logs cd build cmake .. ^ -G "Visual Studio 15 2017" -A x64 ^ + -Dprotobuf_BUILD_EXAMPLES=ON ^ -Dprotobuf_BUILD_CONFORMANCE=OFF ^ -Dprotobuf_WITH_ZLIB=OFF ^ -Dprotobuf_TEST_XML_OUTDIR=%KOKORO_ARTIFACTS_DIR%\logs\ || goto :error diff --git a/kokoro/windows/cmake_install/build.bat b/kokoro/windows/cmake_install/build.bat index 5392f9e664..c5878de338 100644 --- a/kokoro/windows/cmake_install/build.bat +++ b/kokoro/windows/cmake_install/build.bat @@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error @rem TODO(b/241475022) Use docker to guarantee better stability. @rem TODO(b/241484899) Run conformance tests in windows. -md build -ea 0 -md %KOKORO_ARTIFACTS_DIR%\logs -ea 0 +md build +md %KOKORO_ARTIFACTS_DIR%\logs cd build diff --git a/kokoro/windows/cmake_nmake/build.bat b/kokoro/windows/cmake_nmake/build.bat index a0807714fc..7b03678dbc 100644 --- a/kokoro/windows/cmake_nmake/build.bat +++ b/kokoro/windows/cmake_nmake/build.bat @@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error @rem TODO(b/241475022) Use docker to guarantee better stability. @rem TODO(b/241484899) Run conformance tests in windows. -md build -ea 0 -md %KOKORO_ARTIFACTS_DIR%\logs -ea 0 +md build +md %KOKORO_ARTIFACTS_DIR%\logs cd build diff --git a/kokoro/windows/cmake_shared/build.bat b/kokoro/windows/cmake_shared/build.bat index bcd5244608..d4bb2b16ee 100644 --- a/kokoro/windows/cmake_shared/build.bat +++ b/kokoro/windows/cmake_shared/build.bat @@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error @rem TODO(b/241475022) Use docker to guarantee better stability. @rem TODO(b/241484899) Run conformance tests in windows. -md build -ea 0 -md %KOKORO_ARTIFACTS_DIR%\logs -ea 0 +md build +md %KOKORO_ARTIFACTS_DIR%\logs cd build diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h index 1886ccf61b..b7e1c7e6ab 100644 --- a/objectivec/GPBCodedInputStream.h +++ b/objectivec/GPBCodedInputStream.h @@ -30,8 +30,9 @@ #import +#import "GPBExtensionRegistry.h" + @class GPBMessage; -@class GPBExtensionRegistry; NS_ASSUME_NONNULL_BEGIN @@ -184,7 +185,7 @@ CF_EXTERN_C_END * extensions for message. **/ - (void)readMessage:(GPBMessage *)message - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; + extensionRegistry:(nullable id)extensionRegistry; /** * Reads and discards a single field, given its tag value. diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m index c459391e08..25dde75320 100644 --- a/objectivec/GPBCodedInputStream.m +++ b/objectivec/GPBCodedInputStream.m @@ -434,7 +434,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, - (void)readGroup:(int32_t)fieldNumber message:(GPBMessage *)message - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { CheckRecursionLimit(&state_); ++state_.recursionDepth; [message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry]; @@ -454,7 +454,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, } - (void)readMessage:(GPBMessage *)message - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { CheckRecursionLimit(&state_); int32_t length = ReadRawVarint32(&state_); size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length); @@ -466,7 +466,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, } - (void)readMapEntry:(id)mapDictionary - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry field:(GPBFieldDescriptor *)field parentMessage:(GPBMessage *)parentMessage { CheckRecursionLimit(&state_); diff --git a/objectivec/GPBCodedInputStream_PackagePrivate.h b/objectivec/GPBCodedInputStream_PackagePrivate.h index 43ec6e79b2..cdfb0dcc3f 100644 --- a/objectivec/GPBCodedInputStream_PackagePrivate.h +++ b/objectivec/GPBCodedInputStream_PackagePrivate.h @@ -61,7 +61,7 @@ typedef struct GPBCodedInputStreamState { // support for older data. - (void)readGroup:(int32_t)fieldNumber message:(GPBMessage *)message - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; + extensionRegistry:(id)extensionRegistry; // Reads a group field value from the stream and merges it into the given // UnknownFieldSet. @@ -70,7 +70,7 @@ typedef struct GPBCodedInputStreamState { // Reads a map entry. - (void)readMapEntry:(id)mapDictionary - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry field:(GPBFieldDescriptor *)field parentMessage:(GPBMessage *)parentMessage; @end diff --git a/objectivec/GPBDictionary.m b/objectivec/GPBDictionary.m index 187a97092f..77642c27f9 100644 --- a/objectivec/GPBDictionary.m +++ b/objectivec/GPBDictionary.m @@ -386,7 +386,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescri static void ReadValue(GPBCodedInputStream *stream, GPBGenericValue *valueToFill, GPBDataType type, - GPBExtensionRegistry *registry, + idregistry, GPBFieldDescriptor *field) { switch (type) { case GPBDataTypeBool: @@ -454,7 +454,7 @@ static void ReadValue(GPBCodedInputStream *stream, void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream, - GPBExtensionRegistry *registry, + idregistry, GPBFieldDescriptor *field, GPBMessage *parentMessage) { GPBDataType keyDataType = field.mapKeyDataType; diff --git a/objectivec/GPBDictionary_PackagePrivate.h b/objectivec/GPBDictionary_PackagePrivate.h index 15e4283264..d494b7ee88 100644 --- a/objectivec/GPBDictionary_PackagePrivate.h +++ b/objectivec/GPBDictionary_PackagePrivate.h @@ -34,7 +34,7 @@ @class GPBCodedInputStream; @class GPBCodedOutputStream; -@class GPBExtensionRegistry; +@protocol GPBExtensionRegistry; @class GPBFieldDescriptor; @protocol GPBDictionaryInternalsProtocol @@ -493,7 +493,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, // Helper to read a map instead. void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream, - GPBExtensionRegistry *registry, + idregistry, GPBFieldDescriptor *field, GPBMessage *parentMessage); diff --git a/objectivec/GPBExtensionInternals.h b/objectivec/GPBExtensionInternals.h index 2b980aefa4..854b57fe89 100644 --- a/objectivec/GPBExtensionInternals.h +++ b/objectivec/GPBExtensionInternals.h @@ -34,12 +34,12 @@ @class GPBCodedInputStream; @class GPBCodedOutputStream; -@class GPBExtensionRegistry; +@protocol GPBExtensionRegistry; void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream, GPBCodedInputStream *input, - GPBExtensionRegistry *extensionRegistry, + idextensionRegistry, GPBMessage *message); size_t GPBComputeExtensionSerializedSizeIncludingTag( diff --git a/objectivec/GPBExtensionInternals.m b/objectivec/GPBExtensionInternals.m index bacec5740a..b74591e0a0 100644 --- a/objectivec/GPBExtensionInternals.m +++ b/objectivec/GPBExtensionInternals.m @@ -40,7 +40,7 @@ static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension, GPBCodedInputStream *input, - GPBExtensionRegistry *extensionRegistry, + idextensionRegistry, GPBMessage *existingValue) __attribute__((ns_returns_retained)); @@ -273,7 +273,7 @@ static void WriteArrayIncludingTagsToCodedOutputStream( void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension, BOOL isPackedOnStream, GPBCodedInputStream *input, - GPBExtensionRegistry *extensionRegistry, + idextensionRegistry, GPBMessage *message) { GPBExtensionDescription *description = extension->description_; GPBCodedInputStreamState *state = &input->state_; @@ -334,7 +334,7 @@ size_t GPBComputeExtensionSerializedSizeIncludingTag( // Note that this returns a retained value intentionally. static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension, GPBCodedInputStream *input, - GPBExtensionRegistry *extensionRegistry, + idextensionRegistry, GPBMessage *existingValue) { GPBExtensionDescription *description = extension->description_; GPBCodedInputStreamState *state = &input->state_; diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h index d79632d28b..b1850568d9 100644 --- a/objectivec/GPBExtensionRegistry.h +++ b/objectivec/GPBExtensionRegistry.h @@ -41,6 +41,24 @@ NS_ASSUME_NONNULL_BEGIN * GPBExtensionRegistry in which you have registered any extensions that you * want to be able to parse. Otherwise, those extensions will just be treated * like unknown fields. + **/ +@protocol GPBExtensionRegistry + +/** + * Looks for the extension registered for the given field number on a given + * GPBDescriptor. + * + * @param descriptor The descriptor to look for a registered extension on. + * @param fieldNumber The field number of the extension to look for. + * + * @return The registered GPBExtensionDescriptor or nil if none was found. + **/ +- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor + fieldNumber:(NSInteger)fieldNumber; +@end + +/** + * A concrete implementation of `GPBExtensionRegistry`. * * The *Root classes provide `+extensionRegistry` for the extensions defined * in a given file *and* all files it imports. You can also create a @@ -54,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN * MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError]; * ``` **/ -@interface GPBExtensionRegistry : NSObject +@interface GPBExtensionRegistry : NSObject /** * Adds the given GPBExtensionDescriptor to this registry. @@ -70,18 +88,6 @@ NS_ASSUME_NONNULL_BEGIN **/ - (void)addExtensions:(GPBExtensionRegistry *)registry; -/** - * Looks for the extension registered for the given field number on a given - * GPBDescriptor. - * - * @param descriptor The descriptor to look for a registered extension on. - * @param fieldNumber The field number of the extension to look for. - * - * @return The registered GPBExtensionDescriptor or nil if none was found. - **/ -- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor - fieldNumber:(NSInteger)fieldNumber; - @end NS_ASSUME_NONNULL_END diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h index 01253a4afc..f80778bc39 100644 --- a/objectivec/GPBMessage.h +++ b/objectivec/GPBMessage.h @@ -31,12 +31,12 @@ #import #import "GPBBootstrap.h" +#import "GPBExtensionRegistry.h" @class GPBDescriptor; @class GPBCodedInputStream; @class GPBCodedOutputStream; @class GPBExtensionDescriptor; -@class GPBExtensionRegistry; @class GPBFieldDescriptor; @class GPBUnknownFieldSet; @@ -147,7 +147,7 @@ CF_EXTERN_C_END * @return A new instance of the generated class. **/ + (nullable instancetype)parseFromData:(NSData *)data - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(nullable id)extensionRegistry error:(NSError **)errorPtr; /** @@ -171,7 +171,7 @@ CF_EXTERN_C_END **/ + (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (nullable GPBExtensionRegistry *)extensionRegistry + (nullable id)extensionRegistry error:(NSError **)errorPtr; /** @@ -196,7 +196,7 @@ CF_EXTERN_C_END **/ + (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (nullable GPBExtensionRegistry *)extensionRegistry + (nullable id)extensionRegistry error:(NSError **)errorPtr; /** @@ -239,7 +239,7 @@ CF_EXTERN_C_END * @return An initialized instance of the generated class. **/ - (nullable instancetype)initWithData:(NSData *)data - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(nullable id)extensionRegistry error:(NSError **)errorPtr; /** @@ -264,7 +264,7 @@ CF_EXTERN_C_END **/ - (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (nullable GPBExtensionRegistry *)extensionRegistry + (nullable id)extensionRegistry error:(NSError **)errorPtr; /** @@ -278,7 +278,7 @@ CF_EXTERN_C_END * unsuccessful. **/ - (void)mergeFromData:(NSData *)data - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; + extensionRegistry:(nullable id)extensionRegistry; /** * Merges the fields from another message (of the same type) into this diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index ee94dee8ed..b293604608 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -881,7 +881,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } - (instancetype)initWithData:(NSData *)data - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry error:(NSError **)errorPtr { if ((self = [self init])) { @try { @@ -912,7 +912,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { - (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (GPBExtensionRegistry *)extensionRegistry + (id)extensionRegistry error:(NSError **)errorPtr { if ((self = [self init])) { @try { @@ -1973,7 +1973,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { #pragma mark - mergeFrom - (void)mergeFromData:(NSData *)data - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data]; [self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry]; [input checkLastTagWas:0]; @@ -1983,7 +1983,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { #pragma mark - mergeDelimitedFrom - (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { GPBCodedInputStreamState *state = &input->state_; if (GPBCodedInputStreamIsAtEnd(state)) { return; @@ -2003,7 +2003,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } + (instancetype)parseFromData:(NSData *)data - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry error:(NSError **)errorPtr { return [[[self alloc] initWithData:data extensionRegistry:extensionRegistry @@ -2011,7 +2011,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } + (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry error:(NSError **)errorPtr { return [[[self alloc] initWithCodedInputStream:input @@ -2023,7 +2023,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { + (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (GPBExtensionRegistry *)extensionRegistry + (id)extensionRegistry error:(NSError **)errorPtr { GPBMessage *message = [[[self alloc] init] autorelease]; @try { @@ -2065,7 +2065,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } - (void)parseMessageSet:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { uint32_t typeId = 0; NSData *rawBytes = nil; GPBExtensionDescriptor *extension = nil; @@ -2117,7 +2117,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { } - (BOOL)parseUnknownField:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry + extensionRegistry:(id)extensionRegistry tag:(uint32_t)tag { GPBWireFormat wireType = GPBWireFormatGetTagWireType(tag); int32_t fieldNumber = GPBWireFormatGetTagFieldNumber(tag); @@ -2170,7 +2170,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { static void MergeSingleFieldFromCodedInputStream( GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax, - GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) { + GPBCodedInputStream *input, idextensionRegistry) { GPBDataType fieldDataType = GPBGetFieldDataType(field); switch (fieldDataType) { #define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \ @@ -2306,7 +2306,7 @@ static void MergeRepeatedPackedFieldFromCodedInputStream( static void MergeRepeatedNotPackedFieldFromCodedInputStream( GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax, - GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) { + GPBCodedInputStream *input, idextensionRegistry) { GPBCodedInputStreamState *state = &input->state_; id genericArray = GetOrCreateArrayIvarWithField(self, field); switch (GPBGetFieldDataType(field)) { @@ -2371,7 +2371,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream( } - (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry { + extensionRegistry:(id)extensionRegistry { GPBDescriptor *descriptor = [self descriptor]; GPBFileSyntax syntax = descriptor.file.syntax; GPBCodedInputStreamState *state = &input->state_; diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h index ca10983b3c..a8755a29ce 100644 --- a/objectivec/GPBMessage_PackagePrivate.h +++ b/objectivec/GPBMessage_PackagePrivate.h @@ -78,13 +78,13 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr; // or zero for EOF. // NOTE: This will throw if there is an error while parsing. - (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input - extensionRegistry:(GPBExtensionRegistry *)extensionRegistry; + extensionRegistry:(id)extensionRegistry; // Parses the next delimited message of this type from the input and merges it // with this message. - (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input extensionRegistry: - (GPBExtensionRegistry *)extensionRegistry; + (id)extensionRegistry; - (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data; diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index ccf1d414fd..4f0b8b4277 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-packages@google.com yes - 2022-08-09 - + 2022-09-13 + - 3.21.5 - 3.21.5 + 3.21.6 + 3.21.6 stable @@ -1403,5 +1403,20 @@ G A release. + + + 3.21.6 + 3.21.6 + + + stable + stable + + 2022-09-13 + + BSD-3-Clause + + + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 836bb8b74e..4f14ab526a 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -127,7 +127,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#define PHP_PROTOBUF_VERSION "3.21.5" +#define PHP_PROTOBUF_VERSION "3.21.6" // ptr -> PHP object cache. This is a weak map that caches lazily-created // wrapper objects around upb types: diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh index 1a600abc63..0e5be35e24 100755 --- a/php/generate_descriptor_protos.sh +++ b/php/generate_descriptor_protos.sh @@ -5,7 +5,9 @@ set -e -PROTOC=$(realpath protoc) +if [[ -z "${PROTOC}" ]]; then + PROTOC=$(realpath protoc) +fi if [ ! -f $PROTOC ]; then bazel build -c opt //:protoc PROTOC=$(realpath bazel-bin/protoc) diff --git a/php/generate_test_protos.sh b/php/generate_test_protos.sh index 565c7ec1cd..6d06f959b9 100755 --- a/php/generate_test_protos.sh +++ b/php/generate_test_protos.sh @@ -4,7 +4,9 @@ set -ex cd `dirname $0`/.. -PROTOC=$(pwd)/protoc +if [[ -z "${PROTOC}" ]]; then + PROTOC=$(pwd)/protoc +fi if [ ! -f $PROTOC ]; then bazel build -c opt //:protoc PROTOC=$(pwd)/bazel-bin/protoc diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index 5c6158019c..96e6f5291e 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -53,6 +53,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message */ protected $deprecated = null; /** + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. * Whether the message is an automatically generated map entry type for the * maps field. * For maps fields: @@ -68,9 +71,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * use a native map in the target language to hold the keys and values. * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. * * Generated from protobuf field optional bool map_entry = 7; */ @@ -114,6 +114,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * for the message, or it will be completely ignored; in the very least, * this is a formalization for deprecating messages. * @type bool $map_entry + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. * Whether the message is an automatically generated map entry type for the * maps field. * For maps fields: @@ -129,9 +132,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * use a native map in the target language to hold the keys and values. * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. * @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option * The parser stores options it doesn't recognize here. See above. * } @@ -288,6 +288,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. * Whether the message is an automatically generated map entry type for the * maps field. * For maps fields: @@ -303,9 +306,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * use a native map in the target language to hold the keys and values. * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. * * Generated from protobuf field optional bool map_entry = 7; * @return bool @@ -326,6 +326,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message } /** + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. * Whether the message is an automatically generated map entry type for the * maps field. * For maps fields: @@ -341,9 +344,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * use a native map in the target language to hold the keys and values. * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. * * Generated from protobuf field optional bool map_entry = 7; * @param bool $var diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 812224c0e9..65dc37c0c6 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -365,7 +365,8 @@ cc_dist_library( }), tags = ["manual"], deps = [ - "//src/google/protobuf", + "//src/google/protobuf:wkt_cc_proto", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf:arena", "//src/google/protobuf:protobuf_lite", "//src/google/protobuf/compiler:importer", diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 253aaac46d..fdd9b5fe57 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -1,3 +1,3 @@ -PROTOC_VERSION = '21.5' -PROTOBUF_JAVA_VERSION = '3.21.5' -PROTOBUF_PYTHON_VERSION = '4.21.5' +PROTOC_VERSION = '21.6' +PROTOBUF_JAVA_VERSION = '3.21.6' +PROTOBUF_PYTHON_VERSION = '4.21.6' diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index c863376dfc..19e700d4d3 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.21.5 + 3.21.6 pom Protobuf Compiler diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py index 5024ed89d7..f35a432126 100644 --- a/python/google/protobuf/json_format.py +++ b/python/google/protobuf/json_format.py @@ -109,7 +109,8 @@ def MessageToJson( names as defined in the .proto file. If False, convert the field names to lowerCamelCase. indent: The JSON object will be pretty-printed with this indent level. - An indent level of 0 or negative will only insert newlines. + An indent level of 0 or negative will only insert newlines. If the + indent level is None, no newlines will be inserted. sort_keys: If True, then the output will be sorted by field names. use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index fc83acf01a..fc97b0fa6c 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -58,6 +58,37 @@ : 0) \ : PyBytes_AsStringAndSize(ob, (charpp), (sizep))) +#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION) +static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame) +{ + Py_INCREF(frame->f_code); + return frame->f_code; +} + +static PyFrameObject* PyFrame_GetBack(PyFrameObject *frame) +{ + Py_XINCREF(frame->f_back); + return frame->f_back; +} +#endif + +#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION) +static PyObject* PyFrame_GetLocals(PyFrameObject *frame) +{ + if (PyFrame_FastToLocalsWithError(frame) < 0) { + return NULL; + } + Py_INCREF(frame->f_locals); + return frame->f_locals; +} + +static PyObject* PyFrame_GetGlobals(PyFrameObject *frame) +{ + Py_INCREF(frame->f_globals); + return frame->f_globals; +} +#endif + namespace google { namespace protobuf { namespace python { @@ -96,48 +127,66 @@ bool _CalledFromGeneratedFile(int stacklevel) { // This check is not critical and is somewhat difficult to implement correctly // in PyPy. PyFrameObject* frame = PyEval_GetFrame(); + PyCodeObject* frame_code = nullptr; + PyObject* frame_globals = nullptr; + PyObject* frame_locals = nullptr; + bool result = false; + if (frame == nullptr) { - return false; + goto exit; } + Py_INCREF(frame); while (stacklevel-- > 0) { - frame = frame->f_back; + PyFrameObject* next_frame = PyFrame_GetBack(frame); + Py_DECREF(frame); + frame = next_frame; if (frame == nullptr) { - return false; + goto exit; } } - if (frame->f_code->co_filename == nullptr) { - return false; + frame_code = PyFrame_GetCode(frame); + if (frame_code->co_filename == nullptr) { + goto exit; } char* filename; Py_ssize_t filename_size; - if (PyString_AsStringAndSize(frame->f_code->co_filename, + if (PyString_AsStringAndSize(frame_code->co_filename, &filename, &filename_size) < 0) { // filename is not a string. PyErr_Clear(); - return false; + goto exit; } if ((filename_size < 3) || (strcmp(&filename[filename_size - 3], ".py") != 0)) { // Cython's stack does not have .py file name and is not at global module // scope. - return true; + result = true; + goto exit; } if (filename_size < 7) { // filename is too short. - return false; + goto exit; } if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) { // Filename is not ending with _pb2. - return false; + goto exit; } - if (frame->f_globals != frame->f_locals) { + frame_globals = PyFrame_GetGlobals(frame); + frame_locals = PyFrame_GetLocals(frame); + if (frame_globals != frame_locals) { // Not at global module scope - return false; + goto exit; } #endif - return true; + result = true; +exit: + Py_XDECREF(frame_globals); + Py_XDECREF(frame_locals); + Py_XDECREF(frame_code); + Py_XDECREF(frame); + return result; } // If the calling code is not a _pb2.py file, raise AttributeError. diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc index 5d287d3da2..76c4d888a2 100644 --- a/python/google/protobuf/pyext/map_container.cc +++ b/python/google/protobuf/pyext/map_container.cc @@ -45,7 +45,6 @@ #include "google/protobuf/pyext/message_factory.h" #include "google/protobuf/pyext/repeated_composite_container.h" #include "google/protobuf/pyext/scoped_pyobject_ptr.h" -#include "util/gtl/map_util.h" namespace google { namespace protobuf { diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index ca36458531..ebad6b4b4a 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc @@ -42,7 +42,7 @@ #include #include -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #ifndef PyVarObject_HEAD_INIT #define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, @@ -70,11 +70,11 @@ #include "google/protobuf/pyext/unknown_field_set.h" #include "google/protobuf/pyext/unknown_fields.h" #include "google/protobuf/util/message_differencer.h" +#include "google/protobuf/stubs/strutil.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/strtod.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h" -#include "util/gtl/map_util.h" // clang-format off #include "google/protobuf/port_def.inc" @@ -410,7 +410,7 @@ static PyObject* GetClassAttribute(CMessageClass *self, PyObject* name) { Py_ssize_t attr_size; static const char kSuffix[] = "_FIELD_NUMBER"; if (PyString_AsStringAndSize(name, &attr, &attr_size) >= 0 && - HasSuffixString(absl::string_view(attr, attr_size), kSuffix)) { + absl::EndsWith(absl::string_view(attr, attr_size), kSuffix)) { std::string field_name(attr, attr_size - sizeof(kSuffix) + 1); LowerString(&field_name); @@ -2678,22 +2678,22 @@ CMessage* CMessage::BuildSubMessageFromPointer( if (!this->child_submessages) { this->child_submessages = new CMessage::SubMessagesMap(); } - CMessage* cmsg = gtl::FindPtrOrNull( - *this->child_submessages, sub_message); - if (cmsg) { - Py_INCREF(cmsg); - } else { - cmsg = cmessage::NewEmptyMessage(message_class); + auto it = this->child_submessages->find(sub_message); + if (it != this->child_submessages->end()) { + Py_INCREF(it->second); + return it->second; + } - if (cmsg == nullptr) { - return nullptr; - } - cmsg->message = sub_message; - Py_INCREF(this); - cmsg->parent = this; - cmsg->parent_field_descriptor = field_descriptor; - cmessage::SetSubmessage(this, cmsg); + CMessage* cmsg = cmessage::NewEmptyMessage(message_class); + + if (cmsg == nullptr) { + return nullptr; } + cmsg->message = sub_message; + Py_INCREF(this); + cmsg->parent = this; + cmsg->parent_field_descriptor = field_descriptor; + cmessage::SetSubmessage(this, cmsg); return cmsg; } @@ -2701,11 +2701,10 @@ CMessage* CMessage::MaybeReleaseSubMessage(Message* sub_message) { if (!this->child_submessages) { return nullptr; } - CMessage* released = gtl::FindPtrOrNull( - *this->child_submessages, sub_message); - if (!released) { - return nullptr; - } + auto it = this->child_submessages->find(sub_message); + if (it == this->child_submessages->end()) return nullptr; + CMessage* released = it->second; + // The target message will now own its content. Py_CLEAR(released->parent); released->parent_field_descriptor = nullptr; diff --git a/python/google/protobuf/pyext/repeated_composite_container.cc b/python/google/protobuf/pyext/repeated_composite_container.cc index c813e32221..a191670876 100644 --- a/python/google/protobuf/pyext/repeated_composite_container.cc +++ b/python/google/protobuf/pyext/repeated_composite_container.cc @@ -46,7 +46,6 @@ #include "google/protobuf/pyext/message.h" #include "google/protobuf/pyext/message_factory.h" #include "google/protobuf/pyext/scoped_pyobject_ptr.h" -#include "util/gtl/map_util.h" namespace google { namespace protobuf { diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index 2b794287ae..57696f04f9 100644 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py @@ -1013,6 +1013,8 @@ class _Parser(object): if not tokenizer.TryConsume(','): tokenizer.TryConsume(';') + + def _LogSilentMarker(self, field_name): pass def _DetectSilentMarker(self, tokenizer, field_name): diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 3d776fecea..9dc373ca3b 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.21.5" + s.version = "3.21.6" git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/ruby/pom.xml b/ruby/pom.xml index d56c99d785..4e07f84022 100644 --- a/ruby/pom.xml +++ b/ruby/pom.xml @@ -9,7 +9,7 @@ com.google.protobuf.jruby protobuf-jruby - 3.21.5 + 3.21.6 Protocol Buffer JRuby native extension Protocol Buffers are a way of encoding structured data in an efficient yet @@ -76,7 +76,7 @@ com.google.protobuf protobuf-java-util - 3.21.5 + 3.21.6 org.jruby diff --git a/src/file_lists.cmake b/src/file_lists.cmake index 220ffe0cb3..be3d61ee14 100644 --- a/src/file_lists.cmake +++ b/src/file_lists.cmake @@ -11,10 +11,18 @@ endif() # //pkg:protobuf set(libprotobuf_srcs - ${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc + ${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/arena.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.cc @@ -24,12 +32,9 @@ set(libprotobuf_srcs ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_heavy.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.cc @@ -58,16 +63,12 @@ set(libprotobuf_srcs ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/service.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.cc @@ -91,14 +92,21 @@ set(libprotobuf_srcs ${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc - ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc ) # //pkg:protobuf set(libprotobuf_hdrs - ${protobuf_SOURCE_DIR}/src/google/protobuf/any.h ${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/any.h ${protobuf_SOURCE_DIR}/src/google/protobuf/arena.h ${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.h ${protobuf_SOURCE_DIR}/src/google/protobuf/arena_impl.h @@ -109,15 +117,12 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h ${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h ${protobuf_SOURCE_DIR}/src/google/protobuf/field_access_listener.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_reflection.h ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.h ${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.h @@ -158,8 +163,6 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h ${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h ${protobuf_SOURCE_DIR}/src/google/protobuf/service.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h @@ -172,8 +175,6 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.h ${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h ${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h ${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h ${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.h ${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.h @@ -202,7 +203,6 @@ set(libprotobuf_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.h ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.h ${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h - ${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h ) # //pkg:protobuf_lite @@ -456,6 +456,7 @@ set(libprotoc_hdrs ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h + ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_options.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/php/php_generator.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.h diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index 7a6fc12db6..91aaab9e30 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel @@ -81,6 +81,57 @@ proto_library( strip_import_prefix = "/src", ) +# Generate code for the well-known types on demand. +# This needs to be done in a separate genrule because we publish protoc and the +# C++ runtime with the WKT code linked in. We need to use a stripped down +# compiler and runtime library to generate them, and cc_proto_library doesn't +# support swapping out the compiler binary (even though a custom runtime can +# be passed to proto_lang_toolchain). +# +# TODO(b/246826624) We still check in generated pb.h and pb.cc files purely to +# support CMake builds. These aren't used at all by Bazel and will be removed +# in the future once CMake can generate them too. + +WELL_KNOWN_TYPES = [ + "any", + "api", + "duration", + "empty", + "field_mask", + "source_context", + "struct", + "timestamp", + "type", + "wrappers", +] + +genrule( + name = "gen_wkt_cc_sources", + srcs = [wkt + ".proto" for wkt in WELL_KNOWN_TYPES], + exec_tools = ["//src/google/protobuf/compiler:protoc_nowkt"], + outs = + [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] + + [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES], + cmd = """ + $(execpath //src/google/protobuf/compiler:protoc_nowkt) \ + --cpp_out=$(RULEDIR)/../.. \ + --proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \ + $(SRCS) + """, + visibility = ["//visibility:private"], +) + +cc_library( + name = "wkt_cc_proto", + srcs = [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES], + hdrs = [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES], + deps = [":protobuf_nowkt"], + copts = COPTS, + include_prefix = "google/protobuf", + linkopts = LINK_OPTS, + visibility = ["//pkg:__pkg__"], +) + # Built-in runtime types proto_library( @@ -211,19 +262,14 @@ cc_library( ) cc_library( - name = "protobuf", + name = "protobuf_nowkt", srcs = [ "any.cc", - "any.pb.cc", - "api.pb.cc", "descriptor.cc", "descriptor.pb.cc", "descriptor_database.cc", - "duration.pb.cc", "dynamic_message.cc", - "empty.pb.cc", "extension_set_heavy.cc", - "field_mask.pb.cc", "generated_message_bases.cc", "generated_message_reflection.cc", "generated_message_tctable_full.cc", @@ -232,26 +278,16 @@ cc_library( "message.cc", "reflection_ops.cc", "service.cc", - "source_context.pb.cc", - "struct.pb.cc", "text_format.cc", - "timestamp.pb.cc", - "type.pb.cc", "unknown_field_set.cc", "wire_format.cc", - "wrappers.pb.cc", ], hdrs = [ - "any.pb.h", - "api.pb.h", "descriptor.h", "descriptor.pb.h", "descriptor_database.h", - "duration.pb.h", "dynamic_message.h", - "empty.pb.h", "field_access_listener.h", - "field_mask.pb.h", "generated_enum_reflection.h", "generated_message_bases.h", "generated_message_reflection.h", @@ -265,25 +301,19 @@ cc_library( "reflection_internal.h", "reflection_ops.h", "service.h", - "source_context.pb.h", - "struct.pb.h", "text_format.h", - "timestamp.pb.h", - "type.pb.h", "unknown_field_set.h", "wire_format.h", - "wrappers.pb.h", ], copts = COPTS, include_prefix = "google/protobuf", linkopts = LINK_OPTS, visibility = [ - "//:__pkg__", "//pkg:__pkg__", "//src/google/protobuf:__subpackages__", ], deps = [ - ":protobuf_lite", + ":protobuf_lite", "//src/google/protobuf/io", "//src/google/protobuf/io:gzip_stream", "//src/google/protobuf/io:printer", @@ -300,6 +330,22 @@ cc_library( ], ) +cc_library( + name = "protobuf", + deps = [ + ":protobuf_nowkt", + ":wkt_cc_proto", + ], + copts = COPTS, + include_prefix = "google/protobuf", + linkopts = LINK_OPTS, + visibility = [ + "//:__pkg__", + "//pkg:__pkg__", + "//src/google/protobuf:__subpackages__", + ], +) + # This provides just the header files for use in projects that need to build # shared libraries for dynamic loading. This target is available until Bazel # adds native support for such use cases. diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 8347eada75..8075234381 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc index fb812d70fe..a15d19fa09 100644 --- a/src/google/protobuf/any_lite.cc +++ b/src/google/protobuf/any_lite.cc @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "google/protobuf/io/zero_copy_stream_impl_lite.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/any.h" #include "google/protobuf/arenastring.h" @@ -72,7 +72,7 @@ bool AnyMetadata::InternalIs(absl::string_view type_name) const { absl::string_view type_url = type_url_->Get(); return type_url.size() >= type_name.size() + 1 && type_url[type_url.size() - type_name.size() - 1] == '/' && - HasSuffixString(type_url, type_name); + absl::EndsWith(type_url, type_name); } bool ParseAnyTypeUrl(absl::string_view type_url, std::string* url_prefix, diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index c26209da77..726c959345 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 0eb8cc9016..4b4b19e325 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc @@ -105,7 +105,7 @@ class GetDeallocator { size_t* space_allocated_; }; -SerialArena::SerialArena(Block* b, ThreadSafeArena& parent) +SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent) : parent_(parent), space_allocated_(b->size()) { set_head(b); set_ptr(b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize)); @@ -117,13 +117,13 @@ SerialArena* SerialArena::New(Memory mem, ThreadSafeArena& parent) { ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(), /*used=*/0, /*allocated=*/mem.size, /*wasted=*/0); - auto b = new (mem.ptr) Block{nullptr, mem.size}; + auto b = new (mem.ptr) ArenaBlock{nullptr, mem.size}; return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, parent); } template SerialArena::Memory SerialArena::Free(Deallocator deallocator) { - Block* b = head(); + ArenaBlock* b = head(); Memory mem = {b, b->size()}; while (b->next) { b = b->next; // We must first advance before deleting this block @@ -179,7 +179,7 @@ void SerialArena::AllocateNewBlock(size_t n) { ThreadSafeArenaStats::RecordAllocateStats(parent_.arena_stats_.MutableStats(), /*used=*/used, /*allocated=*/mem.size, wasted); - set_head(new (mem.ptr) Block{head(), mem.size}); + set_head(new (mem.ptr) ArenaBlock{head(), mem.size}); set_ptr(head()->Pointer(kBlockHeaderSize)); limit_ = head()->Pointer(head()->size()); @@ -199,7 +199,7 @@ uint64_t SerialArena::SpaceUsed() const { const uint64_t current_block_size = head()->size(); uint64_t space_used = std::min( static_cast( - ptr() - const_cast(head())->Pointer(kBlockHeaderSize)), + ptr() - const_cast(head())->Pointer(kBlockHeaderSize)), current_block_size); space_used += space_used_.load(std::memory_order_relaxed); // Remove the overhead of the SerialArena itself. @@ -208,7 +208,7 @@ uint64_t SerialArena::SpaceUsed() const { } void SerialArena::CleanupList() { - Block* b = head(); + ArenaBlock* b = head(); b->cleanup_nodes = limit_; do { char* limit = reinterpret_cast( diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 4bc39948e3..d3dec65170 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -252,9 +252,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { inline ~Arena() {} - // TODO(protobuf-team): Fix callers to use constructor and delete this method. - void Init(const ArenaOptions&) {} - // API to create proto2 message objects on the arena. If the arena passed in // is nullptr, then a heap allocated object is returned. Type T must be a // message defined in a .proto file with cc_enable_arenas set to true, diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h index 2eb6c505ad..b8969a52ca 100644 --- a/src/google/protobuf/arena_impl.h +++ b/src/google/protobuf/arena_impl.h @@ -90,6 +90,29 @@ inline PROTOBUF_ALWAYS_INLINE void* AlignTo(void* p, size_t a) { } } +// Arena blocks are variable length malloc-ed objects. The following structure +// describes the common header for all blocks. +struct ArenaBlock { + ArenaBlock(ArenaBlock* next, size_t size) + : next(next), cleanup_nodes(nullptr), relaxed_size(size) { + GOOGLE_DCHECK_GT(size, sizeof(ArenaBlock)); + } + + char* Pointer(size_t n) { + GOOGLE_DCHECK(n <= size()); + return reinterpret_cast(this) + n; + } + + size_t size() const { return relaxed_size.load(std::memory_order_relaxed); } + + ArenaBlock* const next; + void* cleanup_nodes; + + private: + const std::atomic relaxed_size; + // data follows +}; + namespace cleanup { template @@ -545,29 +568,8 @@ class PROTOBUF_EXPORT SerialArena { template Memory Free(Deallocator deallocator); - // Blocks are variable length malloc-ed objects. The following structure - // describes the common header for all blocks. - struct Block { - Block(Block* next, size_t size) - : next(next), cleanup_nodes(nullptr), relaxed_size(size) {} - - char* Pointer(size_t n) { - GOOGLE_DCHECK(n <= size()); - return reinterpret_cast(this) + n; - } - - size_t size() const { return relaxed_size.load(std::memory_order_relaxed); } - - Block* const next; - void* cleanup_nodes; - - private: - const std::atomic relaxed_size; - // data follows - }; - ThreadSafeArena& parent_; - std::atomic head_; // Head of linked list of blocks. + std::atomic head_; // Head of linked list of blocks. std::atomic space_used_{0}; // Necessary for metrics. std::atomic space_allocated_; @@ -577,9 +579,11 @@ class PROTOBUF_EXPORT SerialArena { std::atomic ptr_; // Helper getters/setters to handle relaxed operations on atomic variables. - Block* head() { return head_.load(std::memory_order_relaxed); } - const Block* head() const { return head_.load(std::memory_order_relaxed); } - void set_head(Block* head) { + ArenaBlock* head() { return head_.load(std::memory_order_relaxed); } + const ArenaBlock* head() const { + return head_.load(std::memory_order_relaxed); + } + void set_head(ArenaBlock* head) { return head_.store(head, std::memory_order_relaxed); } char* ptr() { return ptr_.load(std::memory_order_relaxed); } @@ -604,7 +608,8 @@ class PROTOBUF_EXPORT SerialArena { CachedBlock** cached_blocks_ = nullptr; // Constructor is private as only New() should be used. - inline SerialArena(Block* b, ThreadSafeArena& parent); + inline SerialArena(ArenaBlock* b, ThreadSafeArena& parent); + void* AllocateAlignedFallback(size_t n); void* AllocateAlignedWithCleanupFallback(size_t n, size_t align, void (*destructor)(void*)); @@ -612,7 +617,7 @@ class PROTOBUF_EXPORT SerialArena { void AllocateNewBlock(size_t n); public: - static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block)); + static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(ArenaBlock)); }; // Tag type used to invoke the constructor of message-owned arena. diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel index 62e0d3992a..50901c3c11 100644 --- a/src/google/protobuf/compiler/BUILD.bazel +++ b/src/google/protobuf/compiler/BUILD.bazel @@ -11,7 +11,7 @@ load( ) load("@rules_proto//proto:defs.bzl", "proto_library") load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test") -load("//build_defs:cpp_opts.bzl", "COPTS") +load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS") proto_library( name = "plugin_proto", @@ -37,7 +37,7 @@ cc_library( include_prefix = "google/protobuf/compiler", visibility = ["//visibility:public"], deps = [ - "//src/google/protobuf", + "//src/google/protobuf:protobuf_nowkt", "@com_google_absl//absl/strings", ], ) @@ -59,7 +59,7 @@ cc_library( include_prefix = "google/protobuf/compiler", visibility = ["//visibility:public"], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "@com_google_absl//absl/strings", ], ) @@ -82,26 +82,22 @@ cc_library( deps = [ ":code_generator", ":importer", - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "@com_google_absl//absl/strings", ], ) cc_library( - name = "protoc_lib", + name = "protoc_lib_nowkt", srcs = [ "main.cc", ], copts = COPTS, - visibility = [ - "//:__pkg__", - "//pkg:__pkg__", - ], deps = [ ":code_generator", ":command_line_interface", ":importer", - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler/cpp", "//src/google/protobuf/compiler/csharp", "//src/google/protobuf/compiler/java", @@ -112,6 +108,29 @@ cc_library( ], ) +cc_binary( + name = "protoc_nowkt", + copts = COPTS, + linkopts = LINK_OPTS + PROTOC_LINK_OPTS, + visibility = [ + "//src/google/protobuf:__pkg__", + ], + deps = [":protoc_lib_nowkt"], +) + +cc_library( + name = "protoc_lib", + copts = COPTS, + visibility = [ + "//:__pkg__", + "//pkg:__pkg__", + ], + deps = [ + "//:protobuf", + ":protoc_lib_nowkt", + ], +) + # Note: this is an alias for now. In the future, this rule will become the # cc_binary for protoc, and //:protoc will become an alias. alias( diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index 6c1a967a11..3f48e37770 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -38,8 +38,8 @@ #include "google/protobuf/stubs/common.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" #include "absl/strings/str_split.h" +#include "absl/strings/strip.h" namespace google { namespace protobuf { @@ -126,10 +126,10 @@ void ParseGeneratorParameter( // Strips ".proto" or ".protodevel" from the end of a filename. std::string StripProto(const std::string& filename) { - if (HasSuffixString(filename, ".protodevel")) { - return StripSuffixString(filename, ".protodevel"); + if (absl::EndsWith(filename, ".protodevel")) { + return std::string(absl::StripSuffix(filename, ".protodevel")); } else { - return StripSuffixString(filename, ".proto"); + return std::string(absl::StripSuffix(filename, ".proto")); } } diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 09d82f039b..dba9729834 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -75,6 +75,7 @@ #include "google/protobuf/compiler/subprocess.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" @@ -1065,9 +1066,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { if (mode_ == MODE_COMPILE) { for (int i = 0; i < output_directives_.size(); i++) { std::string output_location = output_directives_[i].output_location; - if (!HasSuffixString(output_location, ".zip") && - !HasSuffixString(output_location, ".jar") && - !HasSuffixString(output_location, ".srcjar")) { + if (!absl::EndsWith(output_location, ".zip") && + !absl::EndsWith(output_location, ".jar") && + !absl::EndsWith(output_location, ".srcjar")) { AddTrailingSlash(&output_location); } @@ -1088,12 +1089,12 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { for (const auto& pair : output_directories) { const std::string& location = pair.first; GeneratorContextImpl* directory = pair.second.get(); - if (HasSuffixString(location, "/")) { + if (absl::EndsWith(location, "/")) { if (!directory->WriteAllToDisk(location)) { return 1; } } else { - if (HasSuffixString(location, ".jar")) { + if (absl::EndsWith(location, ".jar")) { directory->AddJarManifest(); } @@ -1971,7 +1972,7 @@ CommandLineInterface::InterpretArgument(const std::string& name, // Some other flag. Look it up in the generators list. const GeneratorInfo* generator_info = FindGeneratorByFlag(name); if (generator_info == nullptr && - (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { + (plugin_prefix_.empty() || !absl::EndsWith(name, "_out"))) { // Check if it's a generator option flag. generator_info = FindGeneratorByOption(name); if (generator_info != nullptr) { @@ -1981,7 +1982,7 @@ CommandLineInterface::InterpretArgument(const std::string& name, parameters->append(","); } parameters->append(value); - } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) { + } else if (absl::StartsWith(name, "--") && absl::EndsWith(name, "_opt")) { std::string* parameters = &plugin_parameters_[PluginName(plugin_prefix_, name)]; if (!parameters->empty()) { @@ -2165,8 +2166,8 @@ bool CommandLineInterface::GenerateOutput( std::string error; if (output_directive.generator == nullptr) { // This is a plugin. - GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") && - HasSuffixString(output_directive.name, "_out")) + GOOGLE_CHECK(absl::StartsWith(output_directive.name, "--") && + absl::EndsWith(output_directive.name, "_out")) << "Bad name for plugin generator: " << output_directive.name; std::string plugin_name = PluginName(plugin_prefix_, output_directive.name); diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 6b330b8ff1..1ac81e6a77 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -794,6 +794,7 @@ TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) { "bar.proto", "Bar"); } + TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport_DescriptorSetIn) { // Test parsing multiple input files with an import of a separate file. FileDescriptorSet file_descriptor_set; diff --git a/src/google/protobuf/compiler/cpp/BUILD.bazel b/src/google/protobuf/compiler/cpp/BUILD.bazel index 1798fce624..bf95ffef03 100644 --- a/src/google/protobuf/compiler/cpp/BUILD.bazel +++ b/src/google/protobuf/compiler/cpp/BUILD.bazel @@ -53,9 +53,10 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:layout", diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index dff09a8690..729e66e240 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc @@ -38,21 +38,32 @@ #include #include #include +#include #include #include #include #include "google/protobuf/compiler/scc.h" +#include "absl/container/btree_map.h" +#include "absl/container/btree_set.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" +#include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/cpp/enum.h" #include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/message.h" +#include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/service.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/printer.h" // Must be last. #include "google/protobuf/port_def.inc" @@ -61,103 +72,101 @@ namespace google { namespace protobuf { namespace compiler { namespace cpp { - namespace { - -// When we forward-declare things, we want to create a sorted order so our -// output is deterministic and minimizes namespace changes. -template -std::string GetSortKey(const T& val) { - return val.full_name(); -} - -template <> -std::string GetSortKey(const FileDescriptor& val) { - return val.name(); -} - -template -bool CompareSortKeys(const T* a, const T* b) { - return GetSortKey(*a) < GetSortKey(*b); -} - -template -std::vector Sorted(const std::unordered_set& vals) { - std::vector sorted(vals.begin(), vals.end()); - std::sort(sorted.begin(), sorted.end(), CompareSortKeys); - return sorted; +absl::flat_hash_map FileVars( + const FileDescriptor* file, const Options& options) { + return { + {"filename", file->name()}, + {"package_ns", Namespace(file, options)}, + {"tablename", UniqueName("TableStruct", file, options)}, + {"desc_table", DescriptorTableName(file, options)}, + {"dllexport_decl", options.dllexport_decl}, + {"file_level_metadata", UniqueName("file_level_metadata", file, options)}, + {"file_level_enum_descriptors", + UniqueName("file_level_enum_descriptors", file, options)}, + {"file_level_service_descriptors", + UniqueName("file_level_service_descriptors", file, options)}, + }; } // TODO(b/203101078): remove pragmas that suppresses uninitialized warnings when // clang bug is fixed. -inline void MuteWuninitialized(Formatter& format) { - format( - "#if defined(__llvm__)\n" - " #pragma clang diagnostic push\n" - " #pragma clang diagnostic ignored \"-Wuninitialized\"\n" - "#endif // __llvm__\n"); +void MuteWuninitialized(io::Printer* p) { + p->Emit(R"( + #if defined(__llvm__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wuninitialized" + #endif // __llvm__ + )"); } -inline void UnmuteWuninitialized(Formatter& format) { - format( - "#if defined(__llvm__)\n" - " #pragma clang diagnostic pop\n" - "#endif // __llvm__\n"); +void UnmuteWuninitialized(io::Printer* p) { + p->Emit(R"( + #if defined(__llvm__) + #pragma clang diagnostic pop + #endif // __llvm__ + )"); } - } // namespace FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) : file_(file), options_(options), scc_analyzer_(options) { - // These variables are the same on a file level - variables_["dllexport_decl"] = options.dllexport_decl; - variables_["tablename"] = UniqueName("TableStruct", file_, options_); - variables_["file_level_metadata"] = - UniqueName("file_level_metadata", file_, options_); - variables_["desc_table"] = DescriptorTableName(file_, options_); - variables_["file_level_enum_descriptors"] = - UniqueName("file_level_enum_descriptors", file_, options_); - variables_["file_level_service_descriptors"] = - UniqueName("file_level_service_descriptors", file_, options_); - variables_["filename"] = file_->name(); - variables_["package_ns"] = Namespace(file_, options); - std::vector msgs = FlattenMessagesInFile(file); - for (int i = 0; i < msgs.size(); i++) { - // Deleted in destructor - MessageGenerator* msg_gen = - new MessageGenerator(msgs[i], variables_, i, options, &scc_analyzer_); - message_generators_.emplace_back(msg_gen); - msg_gen->AddGenerators(&enum_generators_, &extension_generators_); + + for (int i = 0; i < msgs.size(); ++i) { + message_generators_.push_back(absl::make_unique( + msgs[i], variables_, i, options, &scc_analyzer_)); + message_generators_.back()->AddGenerators(&enum_generators_, + &extension_generators_); } - for (int i = 0; i < file->enum_type_count(); i++) { - enum_generators_.emplace_back( - new EnumGenerator(file->enum_type(i), variables_, options)); + for (int i = 0; i < file->enum_type_count(); ++i) { + enum_generators_.push_back(absl::make_unique( + file->enum_type(i), variables_, options)); } - for (int i = 0; i < file->service_count(); i++) { - service_generators_.emplace_back( - new ServiceGenerator(file->service(i), variables_, options)); + for (int i = 0; i < file->service_count(); ++i) { + service_generators_.push_back(absl::make_unique( + file->service(i), variables_, options)); } if (HasGenericServices(file_, options_)) { - for (int i = 0; i < service_generators_.size(); i++) { + for (int i = 0; i < service_generators_.size(); ++i) { service_generators_[i]->index_in_metadata_ = i; } } - for (int i = 0; i < file->extension_count(); i++) { - extension_generators_.emplace_back( - new ExtensionGenerator(file->extension(i), options, &scc_analyzer_)); + + for (int i = 0; i < file->extension_count(); ++i) { + extension_generators_.push_back(absl::make_unique( + file->extension(i), options, &scc_analyzer_)); } + for (int i = 0; i < file->weak_dependency_count(); ++i) { weak_deps_.insert(file->weak_dependency(i)); } } -FileGenerator::~FileGenerator() = default; +void FileGenerator::GenerateFile(io::Printer* p, GeneratedFileType file_type, + std::function cb) { + auto v = p->WithVars(FileVars(file_, options_)); + auto guard = IncludeGuard(file_, file_type, options_); + p->Emit({{"cb", cb}, {"guard", guard}}, R"( + // Generated by the protocol buffer compiler. DO NOT EDIT! + // source: $filename$ + + #ifndef $guard$ + #define $guard$ + + #include + #include + #include + + $cb$; + + #endif // $guard$ + )"); +} -void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateMacroUndefs(io::Printer* p) { // Only do this for protobuf's own types. There are some google3 protos using // macros as field names and the generated code compiles after the macro // expansion. Undefing these macros actually breaks such code. @@ -165,412 +174,471 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { file_->name() != "google/protobuf/compiler/plugin.proto") { return; } - std::vector names_to_undef; + std::vector fields; ListAllFields(file_, &fields); - for (int i = 0; i < fields.size(); i++) { - const std::string& name = fields[i]->name(); - static const char* kMacroNames[] = {"major", "minor"}; - for (int j = 0; j < ABSL_ARRAYSIZE(kMacroNames); ++j) { - if (name == kMacroNames[j]) { - names_to_undef.push_back(name); - break; - } - } - } - for (int i = 0; i < names_to_undef.size(); ++i) { - format( - "#ifdef $1$\n" - "#undef $1$\n" - "#endif\n", - names_to_undef[i]); - } -} - -void FileGenerator::GenerateHeader(io::Printer* printer) { - Formatter format(printer, variables_); - - // port_def.inc must be included after all other includes. - IncludeFile("net/proto2/public/port_def.inc", printer); - format("#define $1$$ dllexport_decl$\n", FileDllExport(file_, options_)); - GenerateMacroUndefs(printer); - - // For Any support with lite protos, we need to friend AnyMetadata, so we - // forward-declare it here. - format( - "PROTOBUF_NAMESPACE_OPEN\n" - "namespace internal {\n" - "class AnyMetadata;\n" - "} // namespace internal\n" - "PROTOBUF_NAMESPACE_CLOSE\n"); - - GenerateGlobalStateFunctionDeclarations(printer); - - GenerateForwardDeclarations(printer); - - { - NamespaceOpener ns(Namespace(file_, options_), format); - - format("\n"); - - GenerateEnumDefinitions(printer); - - format(kThickSeparator); - format("\n"); - GenerateMessageDefinitions(printer); - - format("\n"); - format(kThickSeparator); - format("\n"); - - GenerateServiceDefinitions(printer); - - GenerateExtensionIdentifiers(printer); - - format("\n"); - format(kThickSeparator); - format("\n"); + absl::flat_hash_set all_fields; + for (const FieldDescriptor* field : fields) { + all_fields.insert(field->name()); + } - GenerateInlineFunctionDefinitions(printer); + for (absl::string_view name : {"major", "minor"}) { + if (!all_fields.contains(name)) { + continue; + } - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n" - "\n"); + p->Emit({{"name", std::string(name)}}, R"( + #ifdef $name$ + #undef $name$ + #endif // $name$ + )"); } +} - // We need to specialize some templates in the ::google::protobuf namespace: - GenerateProto2NamespaceEnumSpecializations(printer); - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - IncludeFile("net/proto2/public/port_undef.inc", printer); +void FileGenerator::GenerateSharedHeaderCode(io::Printer* p) { + p->Emit( + { + {"port_def", + [&] { IncludeFile("net/proto2/public/port_def.inc", p); }}, + {"port_undef", + [&] { IncludeFile("net/proto2/public/port_undef.inc", p); }}, + {"dllexport_macro", FileDllExport(file_, options_)}, + {"undefs", [&] { GenerateMacroUndefs(p); }}, + {"global_state_decls", + [&] { GenerateGlobalStateFunctionDeclarations(p); }}, + {"fwd_decls", [&] { GenerateForwardDeclarations(p); }}, + {"proto2_ns_enums", + [&] { GenerateProto2NamespaceEnumSpecializations(p); }}, + {"main_decls", + [&] { + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit( + { + {"enums", [&] { GenerateEnumDefinitions(p); }}, + {"messages", [&] { GenerateMessageDefinitions(p); }}, + {"services", [&] { GenerateServiceDefinitions(p); }}, + {"extensions", [&] { GenerateExtensionIdentifiers(p); }}, + {"inline_fns", + [&] { GenerateInlineFunctionDefinitions(p); }}, + }, + R"( + $enums$ + + $hrule_thick$ + + $messages$ + + $hrule_thick$ + + $services$ + + $extensions$ + + $hrule_thick$ + + $inline_fns$ + + // @@protoc_insertion_point(namespace_scope) + )"); + }}, + }, + R"( + // Must be included last. + $port_def$ + + #define $dllexport_macro$$ dllexport_decl$ + $undefs$ + + PROTOBUF_NAMESPACE_OPEN + namespace internal { + class AnyMetadata; + } // namespace internal + PROTOBUF_NAMESPACE_CLOSE + + $global_state_decls$; + $fwd_decls$ + + $main_decls$ + + $proto2_ns_enums$ + + // @@protoc_insertion_point(global_scope) + + $port_undef$ + )"); } -void FileGenerator::GenerateProtoHeader(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); +void FileGenerator::GenerateProtoHeader(io::Printer* p, + absl::string_view info_path) { if (!options_.proto_h) { return; } - GenerateTopHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kProtoH); - - if (!options_.opensource_runtime) { - format( - "#ifdef SWIG\n" - "#error \"Do not SWIG-wrap protobufs.\"\n" - "#endif // SWIG\n" - "\n"); - } - - if (IsBootstrapProto(options_, file_)) { - format("// IWYU pragma: private, include \"$1$.proto.h\"\n\n", - StripProto(file_->name())); - } - - GenerateLibraryIncludes(printer); - - for (int i = 0; i < file_->public_dependency_count(); i++) { - const FileDescriptor* dep = file_->public_dependency(i); - format("#include \"$1$.proto.h\"\n", StripProto(dep->name())); - } - - format("// @@protoc_insertion_point(includes)\n"); - - GenerateMetadataPragma(printer, info_path); - - GenerateHeader(printer); - - GenerateBottomHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kProtoH); -} - -void FileGenerator::GeneratePBHeader(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); - GenerateTopHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kPbH); - - if (options_.proto_h) { - std::string target_basename = StripProto(file_->name()); + GenerateFile(p, GeneratedFileType::kProtoH, [&] { if (!options_.opensource_runtime) { - GetBootstrapBasename(options_, target_basename, &target_basename); + p->Emit(R"( + #ifdef SWIG + #error "Do not SWIG-wrap protobufs." + #endif // SWIG + )"); } - format("#include \"$1$.proto.h\" // IWYU pragma: export\n", - target_basename); - } else { - GenerateLibraryIncludes(printer); - } - - if (options_.transitive_pb_h) { - GenerateDependencyIncludes(printer); - } - - // This is unfortunately necessary for some plugins. I don't see why we - // need two of the same insertion points. - // TODO(gerbens) remove this. - format("// @@protoc_insertion_point(includes)\n"); - - GenerateMetadataPragma(printer, info_path); - - if (!options_.proto_h) { - GenerateHeader(printer); - } else { - { - NamespaceOpener ns(Namespace(file_, options_), format); - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + if (IsBootstrapProto(options_, file_)) { + p->Emit({{"name", StripProto(file_->name())}}, R"cc( + // IWYU pragma: private, include "$name$.proto.h" + )cc"); } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - } - GenerateBottomHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kPbH); + p->Emit( + { + {"library_includes", [&] { GenerateLibraryIncludes(p); }}, + {"proto_includes", + [&] { + for (int i = 0; i < file_->public_dependency_count(); ++i) { + const FileDescriptor* dep = file_->public_dependency(i); + p->Emit({{"name", StripProto(dep->name())}}, R"( + #include "$name$.proto.h" + )"); + } + }}, + {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }}, + {"header_main", [&] { GenerateSharedHeaderCode(p); }}, + }, + R"cc( + $library_includes$; + $proto_includes$; + // @@protoc_insertion_point(includes) + + $metadata_pragma$; + $header_main$; + )cc"); + }); +} + +void FileGenerator::GeneratePBHeader(io::Printer* p, + absl::string_view info_path) { + GenerateFile(p, GeneratedFileType::kPbH, [&] { + p->Emit( + { + {"library_includes", + [&] { + if (options_.proto_h) { + std::string target_basename = StripProto(file_->name()); + if (!options_.opensource_runtime) { + GetBootstrapBasename(options_, target_basename, + &target_basename); + } + p->Emit({{"name", target_basename}}, R"( + #include "$name$.proto.h" // IWYU pragma: export + )"); + } else { + GenerateLibraryIncludes(p); + } + }}, + {"proto_includes", + [&] { + if (options_.transitive_pb_h) { + GenerateDependencyIncludes(p); + } + }}, + {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }}, + {"header_main", + [&] { + if (!options_.proto_h) { + GenerateSharedHeaderCode(p); + return; + } + + { + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit(R"cc( + + // @@protoc_insertion_point(namespace_scope) + )cc"); + } + p->Emit(R"cc( + + // @@protoc_insertion_point(global_scope) + )cc"); + }}, + }, + R"cc( + $library_includes$; + $proto_includes$; + // @@protoc_insertion_point(includes) + + $metadata_pragma$; + $header_main$; + )cc"); + }); } -void FileGenerator::DoIncludeFile(const std::string& google3_name, - bool do_export, io::Printer* printer) { - Formatter format(printer, variables_); - const std::string prefix = "net/proto2/"; - GOOGLE_CHECK(google3_name.find(prefix) == 0) << google3_name; +void FileGenerator::DoIncludeFile(absl::string_view google3_name, + bool do_export, io::Printer* p) { + absl::string_view prefix = "net/proto2/"; + GOOGLE_CHECK(absl::StartsWith(google3_name, prefix)) << google3_name; + + auto v = p->WithVars( + {{"export_suffix", do_export ? "// IWYU pragma: export" : ""}}); if (options_.opensource_runtime) { - std::string path = google3_name.substr(prefix.size()); + absl::ConsumePrefix(&google3_name, prefix); + std::string path(google3_name); path = StringReplace(path, "internal/", "", false); path = StringReplace(path, "proto/", "", false); path = StringReplace(path, "public/", "", false); + if (options_.runtime_include_base.empty()) { - format("#include \"google/protobuf/$1$\"", path); + p->Emit({{"path", path}}, R"( + #include "google/protobuf/$path$"$ export_suffix$ + )"); } else { - format("#include \"$1$google/protobuf/$2$\"", - options_.runtime_include_base, path); + p->Emit({{"base", options_.runtime_include_base}, {"path", path}}, R"( + #include "$base$google/protobuf/$path$"$ export_suffix$ + )"); } } else { - std::string path = google3_name; + std::string path(google3_name); // The bootstrapped proto generated code needs to use the // third_party/protobuf header paths to avoid circular dependencies. if (options_.bootstrap) { - path = StringReplace(google3_name, "net/proto2/public", - "third_party/protobuf", false); + path = StringReplace(path, "net/proto2/public", "third_party/protobuf", + false); } - format("#include \"$1$\"", path); - } - if (do_export) { - format(" // IWYU pragma: export"); + p->Emit({{"path", path}}, R"( + #include "$path$"$ export_suffix$ + )"); } - - format("\n"); } -std::string FileGenerator::CreateHeaderInclude(const std::string& basename, +std::string FileGenerator::CreateHeaderInclude(absl::string_view basename, const FileDescriptor* file) { - bool use_system_include = false; - std::string name = basename; - - if (options_.opensource_runtime) { - if (IsWellKnownMessage(file)) { - if (options_.runtime_include_base.empty()) { - use_system_include = true; - } else { - name = options_.runtime_include_base + basename; - } - } + if (options_.opensource_runtime && IsWellKnownMessage(file) && + !options_.runtime_include_base.empty()) { + return absl::StrCat("\"", options_.runtime_include_base, basename, "\""); } - std::string left = "\""; - std::string right = "\""; - if (use_system_include) { - left = "<"; - right = ">"; - } - return left + name + right; + return absl::StrCat("\"", basename, "\""); } -void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateSourceIncludes(io::Printer* p) { std::string target_basename = StripProto(file_->name()); if (!options_.opensource_runtime) { GetBootstrapBasename(options_, target_basename, &target_basename); } - target_basename += options_.proto_h ? ".proto.h" : ".pb.h"; - format( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - "#include $1$\n" - "\n" - "#include \n" // for swap() - "\n", - CreateHeaderInclude(target_basename, file_)); - - IncludeFile("net/proto2/io/public/coded_stream.h", printer); + + absl::StrAppend(&target_basename, options_.proto_h ? ".proto.h" : ".pb.h"); + p->Emit({{"h_include", CreateHeaderInclude(target_basename, file_)}}, + R"( + // Generated by the protocol buffer compiler. DO NOT EDIT! + // source: $filename$ + + #include $h_include$ + + #include + )"); + + IncludeFile("net/proto2/io/public/coded_stream.h", p); // TODO(gerbens) This is to include parse_context.h, we need a better way - IncludeFile("net/proto2/public/extension_set.h", printer); - IncludeFile("net/proto2/public/wire_format_lite.h", printer); + IncludeFile("net/proto2/public/extension_set.h", p); + IncludeFile("net/proto2/public/wire_format_lite.h", p); // Unknown fields implementation in lite mode uses StringOutputStream if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { - IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", printer); + IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", p); } if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/descriptor.h", printer); - IncludeFile("net/proto2/public/generated_message_reflection.h", printer); - IncludeFile("net/proto2/public/reflection_ops.h", printer); - IncludeFile("net/proto2/public/wire_format.h", printer); + IncludeFile("net/proto2/public/descriptor.h", p); + IncludeFile("net/proto2/public/generated_message_reflection.h", p); + IncludeFile("net/proto2/public/reflection_ops.h", p); + IncludeFile("net/proto2/public/wire_format.h", p); } if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - IncludeFile("net/proto2/public/generated_message_tctable_impl.h", printer); + IncludeFile("net/proto2/public/generated_message_tctable_impl.h", p); } if (options_.proto_h) { // Use the smaller .proto.h files. - for (int i = 0; i < file_->dependency_count(); i++) { + for (int i = 0; i < file_->dependency_count(); ++i) { const FileDescriptor* dep = file_->dependency(i); - // Do not import weak deps. - if (!options_.opensource_runtime && IsDepWeak(dep)) continue; + + if (!options_.opensource_runtime && + IsDepWeak(dep)) { // Do not import weak deps. + continue; + } + std::string basename = StripProto(dep->name()); if (IsBootstrapProto(options_, file_)) { GetBootstrapBasename(options_, basename, &basename); } - format("#include \"$1$.proto.h\"\n", basename); + p->Emit({{"name", basename}}, R"( + #include "$name$.proto.h" + )"); } } + if (HasCordFields(file_, options_)) { - format( - "#include \"third_party/absl/strings/internal/string_constant.h\"\n"); + p->Emit(R"( + #include "third_party/absl/strings/internal/string_constant.h" + )"); } - format("// @@protoc_insertion_point(includes)\n"); - IncludeFile("net/proto2/public/port_def.inc", printer); -} + p->Emit(R"cc( + // @@protoc_insertion_point(includes) -void FileGenerator::GenerateSourcePrelude(io::Printer* printer) { - Formatter format(printer, variables_); + // Must be included last. + )cc"); + IncludeFile("net/proto2/public/port_def.inc", p); +} +void FileGenerator::GenerateSourcePrelude(io::Printer* p) { // For MSVC builds, we use #pragma init_seg to move the initialization of our // libraries to happen before the user code. // This worksaround the fact that MSVC does not do constant initializers when // required by the standard. - format("\nPROTOBUF_PRAGMA_INIT_SEG\n"); - - // Generate convenience aliases. - format( - "\n" - "namespace _pb = ::$1$;\n" - "namespace _pbi = _pb::internal;\n", - ProtobufNamespace(options_)); + p->Emit(R"cc( + PROTOBUF_PRAGMA_INIT_SEG + namespace _pb = ::$proto_ns$; + namespace _pbi = ::$proto_ns$::internal; + )cc"); + if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - format("namespace _fl = _pbi::field_layout;\n"); + p->Emit(R"cc( + namespace _fl = ::$proto_ns$::internal::field_layout; + )cc"); } - format("\n"); } -void FileGenerator::GenerateSourceDefaultInstance(int idx, - io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) { MessageGenerator* generator = message_generators_[idx].get(); + // Generate the split instance first because it's needed in the constexpr // constructor. if (ShouldSplit(generator->descriptor_, options_)) { // Use a union to disable the destructor of the _instance member. // We can constant initialize, but the object will still have a non-trivial // destructor that we need to elide. - format( - "struct $1$ {\n" - " PROTOBUF_CONSTEXPR $1$()\n" - " : _instance{", - DefaultInstanceType(generator->descriptor_, options_, - /*split=*/true)); - generator->GenerateInitDefaultSplitInstance(printer); - format( - "} {}\n" - " union {\n" - " $1$ _instance;\n" - " };\n" - "};\n", - absl::StrCat(generator->classname_, "::Impl_::Split")); + // // NO_DESTROY is not necessary for correctness. The empty destructor is // enough. However, the empty destructor fails to be elided in some // configurations (like non-opt or with certain sanitizers). NO_DESTROY is // there just to improve performance and binary size in these builds. - format( - "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const $1$ $2$;\n", - DefaultInstanceType(generator->descriptor_, options_, /*split=*/true), - DefaultInstanceName(generator->descriptor_, options_, /*split=*/true)); - } - - generator->GenerateConstexprConstructor(printer); - format( - "struct $1$ {\n" - " PROTOBUF_CONSTEXPR $1$()\n" - " : _instance(::_pbi::ConstantInitialized{}) {}\n" - " ~$1$() {}\n" - " union {\n" - " $2$ _instance;\n" - " };\n" - "};\n", - DefaultInstanceType(generator->descriptor_, options_), - generator->classname_); - format( - "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n", - DefaultInstanceType(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); - - for (int i = 0; i < generator->descriptor_->field_count(); i++) { + p->Emit( + { + {"type", DefaultInstanceType(generator->descriptor_, options_, + /*split=*/true)}, + {"name", DefaultInstanceName(generator->descriptor_, options_, + /*split=*/true)}, + {"default", + [&] { generator->GenerateInitDefaultSplitInstance(p); }}, + {"class", absl::StrCat(generator->classname_, "::Impl_::Split")}, + }, + R"cc( + struct $type$ { + PROTOBUF_CONSTEXPR $type$() : _instance{$default$} {} + union { + $class$ _instance; + }; + }; + + PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const $type$ $name$; + )cc"); + } + + generator->GenerateConstexprConstructor(p); + + p->Emit( + { + {"type", DefaultInstanceType(generator->descriptor_, options_)}, + {"name", DefaultInstanceName(generator->descriptor_, options_)}, + {"default", [&] { generator->GenerateInitDefaultSplitInstance(p); }}, + {"class", generator->classname_}, + }, + R"cc( + struct $type$ { + PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {} + ~$type$() {} + union { + $class$ _instance; + }; + }; + + PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $type$ $name$; + )cc"); + + for (int i = 0; i < generator->descriptor_->field_count(); ++i) { const FieldDescriptor* field = generator->descriptor_->field(i); - if (IsStringInlined(field, options_)) { - // Force the initialization of the inlined string in the default instance. - format( - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type " - "$1$::Impl_::_init_inline_$2$_ = " - "($3$._instance.$4$.Init(), std::true_type{});\n", - ClassName(generator->descriptor_), FieldName(field), - DefaultInstanceName(generator->descriptor_, options_), - FieldMemberName(field, ShouldSplit(field, options_))); + if (!IsStringInlined(field, options_)) { + continue; } + + // Force the initialization of the inlined string in the default instance. + p->Emit( + { + {"class", ClassName(generator->descriptor_)}, + {"field", FieldName(field)}, + {"default", DefaultInstanceName(generator->descriptor_, options_)}, + {"member", FieldMemberName(field, ShouldSplit(field, options_))}, + }, + R"cc( + PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type + $class$::Impl_::_init_inline_$field$_ = + ($default$._instance.$member$.Init(), std::true_type{}); + )cc"); } if (options_.lite_implicit_weak_fields) { - format( - "PROTOBUF_CONSTINIT const void* $1$ =\n" - " &$2$;\n", - DefaultInstancePtr(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); + p->Emit( + { + {"ptr", DefaultInstancePtr(generator->descriptor_, options_)}, + {"name", DefaultInstanceName(generator->descriptor_, options_)}, + }, + R"cc( + PROTOBUF_CONSTINIT const void* $ptr$ = &$name$; + )cc"); } } // A list of things defined in one .pb.cc file that we need to reference from // another .pb.cc file. struct FileGenerator::CrossFileReferences { + // When we forward-declare things, we want to create a sorted order so our + // output is deterministic and minimizes namespace changes. + struct DescCompare { + template + bool operator()(const T* const& a, const T* const& b) const { + return a->full_name() < b->full_name(); + } + + bool operator()(const FileDescriptor* const& a, + const FileDescriptor* const& b) const { + return a->name() < b->name(); + } + }; + // Populated if we are referencing from messages or files. - std::unordered_set weak_default_instances; + absl::btree_set weak_default_instances; // Only if we are referencing from files. - std::unordered_set strong_reflection_files; - std::unordered_set weak_reflection_files; + absl::btree_set strong_reflection_files; + absl::btree_set weak_reflection_files; }; void FileGenerator::GetCrossFileReferencesForField(const FieldDescriptor* field, CrossFileReferences* refs) { const Descriptor* msg = field->message_type(); - if (msg == nullptr) return; + if (msg == nullptr) { + return; + } if (IsImplicitWeakField(field, options_, &scc_analyzer_) || IsWeak(field, options_)) { @@ -584,10 +652,13 @@ void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file, GetCrossFileReferencesForField(field, refs); }); - if (!HasDescriptorMethods(file, options_)) return; + if (!HasDescriptorMethods(file, options_)) { + return; + } - for (int i = 0; i < file->dependency_count(); i++) { + for (int i = 0; i < file->dependency_count(); ++i) { const FileDescriptor* dep = file->dependency(i); + if (IsDepWeak(dep)) { refs->weak_reflection_files.insert(dep); } else { @@ -598,119 +669,128 @@ void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file, // Generates references to variables defined in other files. void FileGenerator::GenerateInternalForwardDeclarations( - const CrossFileReferences& refs, io::Printer* printer) { - Formatter format(printer, variables_); - + const CrossFileReferences& refs, io::Printer* p) { { - NamespaceOpener ns(format); - for (auto instance : Sorted(refs.weak_default_instances)) { + NamespaceOpener ns(p); + for (auto instance : refs.weak_default_instances) { ns.ChangeTo(Namespace(instance, options_)); + if (options_.lite_implicit_weak_fields) { - format( - "PROTOBUF_CONSTINIT __attribute__((weak)) const void* $1$ =\n" - " &::_pbi::implicit_weak_message_default_instance;\n", - DefaultInstancePtr(instance, options_)); + p->Emit({{"ptr", DefaultInstancePtr(instance, options_)}}, R"cc( + PROTOBUF_CONSTINIT __attribute__((weak)) const void* $ptr$ = + &::_pbi::implicit_weak_message_default_instance; + )cc"); } else { - format("extern __attribute__((weak)) $1$ $2$;\n", - DefaultInstanceType(instance, options_), - DefaultInstanceName(instance, options_)); + p->Emit({{"type", DefaultInstanceType(instance, options_)}, + {"name", DefaultInstanceName(instance, options_)}}, + R"cc( + extern __attribute__((weak)) $type$ $name$; + )cc"); } } } - for (auto file : Sorted(refs.weak_reflection_files)) { - format( - "extern __attribute__((weak)) const ::_pbi::DescriptorTable $1$;\n", - DescriptorTableName(file, options_)); + for (auto file : refs.weak_reflection_files) { + p->Emit({{"table", DescriptorTableName(file, options_)}}, R"cc( + extern __attribute__((weak)) const ::_pbi::DescriptorTable $table$; + )cc"); } } -void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); - if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); + + if (IsAnyMessage(file_, options_)) { + MuteWuninitialized(p); + } CrossFileReferences refs; ForEachField(message_generators_[idx]->descriptor_, [this, &refs](const FieldDescriptor* field) { GetCrossFileReferencesForField(field, &refs); }); - GenerateInternalForwardDeclarations(refs, printer); - { // package namespace - NamespaceOpener ns(Namespace(file_, options_), format); + GenerateInternalForwardDeclarations(refs, p); - // Define default instances - GenerateSourceDefaultInstance(idx, printer); + { + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit( + { + {"defaults", [&] { GenerateSourceDefaultInstance(idx, p); }}, + {"class_methods", + [&] { message_generators_[idx]->GenerateClassMethods(p); }}, + }, + R"cc( + $defaults$; - // Generate classes. - format("\n"); - message_generators_[idx]->GenerateClassMethods(printer); + $class_methods$; - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - } // end package namespace + // @@protoc_insertion_point(namespace_scope) + )cc"); + } { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - message_generators_[idx]->GenerateSourceInProto2Namespace(printer); + NamespaceOpener proto_ns(ProtobufNamespace(options_), p); + message_generators_[idx]->GenerateSourceInProto2Namespace(p); } - if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + if (IsAnyMessage(file_, options_)) { + UnmuteWuninitialized(p); + } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n"); + p->Emit(R"cc( + // @@protoc_insertion_point(global_scope) + )cc"); } -void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); - NamespaceOpener ns(Namespace(file_, options_), format); - extension_generators_[idx]->GenerateDefinition(printer); +void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); + + NamespaceOpener ns(Namespace(file_, options_), p); + extension_generators_[idx]->GenerateDefinition(p); } -void FileGenerator::GenerateGlobalSource(io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateGlobalSource(io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. if (HasDescriptorMethods(file_, options_)) { - GenerateReflectionInitializationCode(printer); + GenerateReflectionInitializationCode(p); } } - NamespaceOpener ns(Namespace(file_, options_), format); - - // Generate enums. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateMethods(i, printer); + NamespaceOpener ns(Namespace(file_, options_), p); + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateMethods(i, p); } } -void FileGenerator::GenerateSource(io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateSource(io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); - GenerateInternalForwardDeclarations(refs, printer); + GenerateInternalForwardDeclarations(refs, p); - if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); + if (IsAnyMessage(file_, options_)) { + MuteWuninitialized(p); + } { - NamespaceOpener ns(Namespace(file_, options_), format); - - // Define default instances - for (int i = 0; i < message_generators_.size(); i++) { - GenerateSourceDefaultInstance(i, printer); + NamespaceOpener ns(Namespace(file_, options_), p); + for (int i = 0; i < message_generators_.size(); ++i) { + GenerateSourceDefaultInstance(i, p); } } @@ -718,144 +798,155 @@ void FileGenerator::GenerateSource(io::Printer* printer) { if (HasDescriptorMethods(file_, options_)) { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. - GenerateReflectionInitializationCode(printer); + GenerateReflectionInitializationCode(p); } } { - NamespaceOpener ns(Namespace(file_, options_), format); + NamespaceOpener ns(Namespace(file_, options_), p); // Actually implement the protos // Generate enums. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateMethods(i, printer); + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateMethods(i, p); } // Generate classes. - for (int i = 0; i < message_generators_.size(); i++) { - format("\n"); - format(kThickSeparator); - format("\n"); - message_generators_[i]->GenerateClassMethods(printer); + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"( + $hrule_thick$ + )"); + message_generators_[i]->GenerateClassMethods(p); } if (HasGenericServices(file_, options_)) { // Generate services. - for (int i = 0; i < service_generators_.size(); i++) { - if (i == 0) format("\n"); - format(kThickSeparator); - format("\n"); - service_generators_[i]->GenerateImplementation(printer); + for (int i = 0; i < service_generators_.size(); ++i) { + p->Emit(R"( + $hrule_thick$ + )"); + service_generators_[i]->GenerateImplementation(p); } } // Define extensions. - for (int i = 0; i < extension_generators_.size(); i++) { - extension_generators_[i]->GenerateDefinition(printer); + for (int i = 0; i < extension_generators_.size(); ++i) { + extension_generators_[i]->GenerateDefinition(p); } - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + p->Emit(R"cc( + // @@protoc_insertion_point(namespace_scope) + )cc"); } { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateSourceInProto2Namespace(printer); + NamespaceOpener proto_ns(ProtobufNamespace(options_), p); + for (int i = 0; i < message_generators_.size(); ++i) { + message_generators_[i]->GenerateSourceInProto2Namespace(p); } } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n"); + p->Emit(R"cc( + // @@protoc_insertion_point(global_scope) + )cc"); - if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + if (IsAnyMessage(file_, options_)) { + UnmuteWuninitialized(p); + } - IncludeFile("net/proto2/public/port_undef.inc", printer); + IncludeFile("net/proto2/public/port_undef.inc", p); } -void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { - Formatter format(printer, variables_); - +void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { if (!message_generators_.empty()) { - format("static ::_pb::Metadata $file_level_metadata$[$1$];\n", - message_generators_.size()); + p->Emit({{"len", absl::StrCat(message_generators_.size())}}, R"cc( + static ::_pb::Metadata $file_level_metadata$[$len$]; + )cc"); } + if (!enum_generators_.empty()) { - format( - "static const ::_pb::EnumDescriptor* " - "$file_level_enum_descriptors$[$1$];\n", - enum_generators_.size()); + p->Emit({{"len", absl::StrCat(enum_generators_.size())}}, R"cc( + static const ::_pb::EnumDescriptor* $file_level_enum_descriptors$[$len$]; + )cc"); } else { - format( - "static " - "constexpr ::_pb::EnumDescriptor const** " - "$file_level_enum_descriptors$ = nullptr;\n"); + p->Emit(R"cc( + static constexpr const ::_pb::EnumDescriptor** + $file_level_enum_descriptors$ = nullptr; + )cc"); } + if (HasGenericServices(file_, options_) && file_->service_count() > 0) { - format( - "static " - "const ::_pb::ServiceDescriptor* " - "$file_level_service_descriptors$[$1$];\n", - file_->service_count()); + p->Emit({{"len", absl::StrCat(file_->service_count())}}, R"cc( + static const ::_pb::ServiceDescriptor* + $file_level_service_descriptors$[$len$]; + )cc"); } else { - format( - "static " - "constexpr ::_pb::ServiceDescriptor const** " - "$file_level_service_descriptors$ = nullptr;\n"); + p->Emit(R"cc( + static constexpr const ::_pb::ServiceDescriptor** + $file_level_service_descriptors$ = nullptr; + )cc"); } if (!message_generators_.empty()) { - format( - "\n" - "const $uint32$ $tablename$::offsets[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - std::vector > pairs; - pairs.reserve(message_generators_.size()); - for (int i = 0; i < message_generators_.size(); i++) { - pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); - } - format.Outdent(); - format( - "};\n" - "static const ::_pbi::MigrationSchema schemas[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - { - int offset = 0; - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateSchema(printer, offset, - pairs[i].second); - offset += pairs[i].first; - } - } - format.Outdent(); - format( - "};\n" - "\nstatic const ::_pb::Message* const file_default_instances[] = {\n"); - format.Indent(); - for (int i = 0; i < message_generators_.size(); i++) { - const Descriptor* descriptor = message_generators_[i]->descriptor_; - format("&$1$::_$2$_default_instance_._instance,\n", - Namespace(descriptor, options_), // 1 - ClassName(descriptor)); // 2 - } - format.Outdent(); - format( - "};\n" - "\n"); + std::vector> offsets; + offsets.reserve(message_generators_.size()); + + p->Emit( + { + {"offsets", + [&] { + for (int i = 0; i < message_generators_.size(); ++i) { + offsets.push_back(message_generators_[i]->GenerateOffsets(p)); + } + }}, + {"schemas", + [&] { + int offset = 0; + for (int i = 0; i < message_generators_.size(); ++i) { + message_generators_[i]->GenerateSchema(p, offset, + offsets[i].second); + offset += offsets[i].first; + } + }}, + {"defaults", + [&] { + for (auto& gen : message_generators_) { + p->Emit( + { + {"ns", Namespace(gen->descriptor_, options_)}, + {"class", ClassName(gen->descriptor_)}, + }, + R"cc( + &$ns$::_$class$_default_instance_._instance, + )cc"); + } + }}, + }, + R"cc( + const uint32_t $tablename$::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + $offsets$, + }; + + static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + $schemas$, + }; + + static const ::_pb::Message* const file_default_instances[] = { + $defaults$, + }; + )cc"); } else { - // we still need these symbols to exist - format( - // MSVC doesn't like empty arrays, so we add a dummy. - "const $uint32$ $tablename$::offsets[1] = {};\n" - "static constexpr ::_pbi::MigrationSchema* schemas = nullptr;\n" - "static constexpr ::_pb::Message* const* " - "file_default_instances = nullptr;\n" - "\n"); + // Ee still need these symbols to exist. + // + // MSVC doesn't like empty arrays, so we add a dummy. + p->Emit(R"cc( + const uint32_t $tablename$::offsets[1] = {}; + static constexpr ::_pbi::MigrationSchema* schemas = nullptr; + static constexpr ::_pb::Message* const* file_default_instances = nullptr; + )cc"); } // --------------------------------------------------------------- @@ -863,63 +954,88 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // Embed the descriptor. We simply serialize the entire // FileDescriptorProto/ and embed it as a string literal, which is parsed and // built into real descriptors at initialization time. - const std::string protodef_name = - UniqueName("descriptor_table_protodef", file_, options_); - format("const char $1$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =\n", - protodef_name); - format.Indent(); + FileDescriptorProto file_proto; file_->CopyTo(&file_proto); std::string file_data; file_proto.SerializeToString(&file_data); - { - if (file_data.size() > 65535) { - // Workaround for MSVC: "Error C1091: compiler limit: string exceeds - // 65535 bytes in length". Declare a static array of chars rather than - // use a string literal. Only write 25 bytes per line. - static const int kBytesPerLine = 25; - format("{ "); - for (int i = 0; i < file_data.size();) { - for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { - format("'$1$', ", absl::CEscape(file_data.substr(i, 1))); - } - format("\n"); - } - format("'\\0' }"); // null-terminate - } else { - // Only write 40 bytes per line. - static const int kBytesPerLine = 40; - for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - format( - "\"$1$\"\n", - EscapeTrigraphs(absl::CEscape(file_data.substr(i, kBytesPerLine)))); - } - } - format(";\n"); - } - format.Outdent(); + auto desc_name = UniqueName("descriptor_table_protodef", file_, options_); + p->Emit( + {{"desc_name", desc_name}, + {"encoded_file_proto", + [&] { + absl::string_view data = file_data; + if (data.size() <= 65535) { + static constexpr size_t kBytesPerLine = 40; + while (!data.empty()) { + auto to_write = std::min(kBytesPerLine, data.size()); + auto chunk = data.substr(0, to_write); + data = data.substr(to_write); + + p->Emit({{"text", EscapeTrigraphs(absl::CEscape(chunk))}}, R"cc( + "$text$" + )cc"); + } + return; + } + + // Workaround for MSVC: "Error C1091: compiler limit: string exceeds + // 65535 bytes in length". Declare a static array of chars rather than + // use a string literal. Only write 25 bytes per line. + static constexpr size_t kBytesPerLine = 25; + while (!data.empty()) { + auto to_write = std::min(kBytesPerLine, data.size()); + auto chunk = data.substr(0, to_write); + data = data.substr(to_write); + + std::string line; + for (char c : chunk) { + absl::StrAppend(&line, "'", + absl::CEscape(absl::string_view(&c, 1)), "', "); + } + + p->Emit({{"line", line}}, R"cc( + $line$ + )cc"); + } + }}}, + R"cc( + const char $desc_name$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + $encoded_file_proto$, + }; + )cc"); CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); - int num_deps = + size_t num_deps = refs.strong_reflection_files.size() + refs.weak_reflection_files.size(); // Build array of DescriptorTable deps. if (num_deps > 0) { - format( - "static const ::_pbi::DescriptorTable* const " - "$desc_table$_deps[$1$] = {\n", - num_deps); - - for (auto dep : Sorted(refs.strong_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - for (auto dep : Sorted(refs.weak_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - - format("};\n"); + p->Emit( + { + {"len", absl::StrCat(num_deps)}, + {"deps", + [&] { + for (auto dep : refs.strong_reflection_files) { + p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc( + &::$name$, + )cc"); + } + for (auto dep : refs.weak_reflection_files) { + p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc( + &::$name$, + )cc"); + } + }}, + }, + R"cc( + static const ::_pbi::DescriptorTable* const $desc_table$_deps[$len$] = + { + $deps$, + }; + )cc"); } // The DescriptorTable itself. @@ -927,344 +1043,358 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { // however this might cause a tsan failure in superroot b/148382879, // so disable for now. bool eager = false; - format( - "static ::absl::once_flag $desc_table$_once;\n" - "const ::_pbi::DescriptorTable $desc_table$ = {\n" - " false, $1$, $2$, $3$,\n" - " \"$filename$\",\n" - " &$desc_table$_once, $4$, $5$, $6$,\n" - " schemas, file_default_instances, $tablename$::offsets,\n" - " $7$, $file_level_enum_descriptors$,\n" - " $file_level_service_descriptors$,\n" - "};\n" - // This function exists to be marked as weak. - // It can significantly speed up compilation by breaking up LLVM's SCC in - // the .pb.cc translation units. Large translation units see a reduction - // of more than 35% of walltime for optimized builds. - // Without the weak attribute all the messages in the file, including all - // the vtables and everything they use become part of the same SCC through - // a cycle like: - // GetMetadata -> descriptor table -> default instances -> - // vtables -> GetMetadata - // By adding a weak function here we break the connection from the - // individual vtables back into the descriptor table. - "PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* " - "$desc_table$_getter() {\n" - " return &$desc_table$;\n" - "}\n" - "\n", - eager ? "true" : "false", file_data.size(), protodef_name, - num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps, - message_generators_.size(), - message_generators_.empty() ? "nullptr" - : variables_["file_level_metadata"]); + p->Emit( + { + {"eager", eager ? "true" : "false"}, + {"file_proto_len", absl::StrCat(file_data.size())}, + {"proto_name", desc_name}, + {"deps_ptr", num_deps == 0 + ? "nullptr" + : absl::StrCat(p->LookupVar("desc_table"), "_deps")}, + {"num_deps", absl::StrCat(num_deps)}, + {"num_msgs", absl::StrCat(message_generators_.size())}, + {"msgs_ptr", message_generators_.empty() + ? "nullptr" + : std::string(p->LookupVar("file_level_metadata"))}, + }, + R"cc( + static ::absl::once_flag $desc_table$_once; + const ::_pbi::DescriptorTable $desc_table$ = { + false, + $eager$, + $file_proto_len$, + $proto_name$, + "$filename$", + &$desc_table$_once, + $deps_ptr$, + $num_deps$, + $num_msgs$, + schemas, + file_default_instances, + $tablename$::offsets, + $msgs_ptr$, + $file_level_enum_descriptors$, + $file_level_service_descriptors$, + }; + + // This function exists to be marked as weak. + // It can significantly speed up compilation by breaking up LLVM's SCC + // in the .pb.cc translation units. Large translation units see a + // reduction of more than 35% of walltime for optimized builds. Without + // the weak attribute all the messages in the file, including all the + // vtables and everything they use become part of the same SCC through + // a cycle like: + // GetMetadata -> descriptor table -> default instances -> + // vtables -> GetMetadata + // By adding a weak function here we break the connection from the + // individual vtables back into the descriptor table. + PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* $desc_table$_getter() { + return &$desc_table$; + } + )cc"); // For descriptor.proto we want to avoid doing any dynamic initialization, // because in some situations that would otherwise pull in a lot of // unnecessary code that can't be stripped by --gc-sections. Descriptor // initialization will still be performed lazily when it's needed. - if (file_->name() != "net/proto2/proto/descriptor.proto") { - format( - "// Force running AddDescriptors() at dynamic initialization time.\n" - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 " - "static ::_pbi::AddDescriptorsRunner $1$(&$desc_table$);\n", - UniqueName("dynamic_init_dummy", file_, options_)); + if (file_->name() == "net/proto2/proto/descriptor.proto") { + return; } + + p->Emit({{"dummy", UniqueName("dynamic_init_dummy", file_, options_)}}, R"cc( + // Force running AddDescriptors() at dynamic initialization time. + PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 + static ::_pbi::AddDescriptorsRunner $dummy$(&$desc_table$); + )cc"); } class FileGenerator::ForwardDeclarations { public: - void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; } - void AddEnum(const EnumDescriptor* d) { enums_[ClassName(d)] = d; } - void AddSplit(const Descriptor* d) { splits_[ClassName(d)] = d; } - - void Print(const Formatter& format, const Options& options) const { - for (const auto& p : enums_) { - const std::string& enumname = p.first; - const EnumDescriptor* enum_desc = p.second; - format( - "enum ${1$$2$$}$ : int;\n" - "bool $2$_IsValid(int value);\n", - enum_desc, enumname); + void AddMessage(const Descriptor* d) { classes_.emplace(ClassName(d), d); } + void AddEnum(const EnumDescriptor* d) { enums_.emplace(ClassName(d), d); } + void AddSplit(const Descriptor* d) { splits_.emplace(ClassName(d), d); } + + void Print(io::Printer* p, const Options& options) const { + for (const auto& e : enums_) { + auto a = p->WithAnnotations({{"enum", e.second}}); + p->Emit({{"enum", e.first}}, R"cc( + enum $enum$ : int; + bool $enum$_IsValid(int value); + )cc"); } - for (const auto& p : classes_) { - const std::string& classname = p.first; - const Descriptor* class_desc = p.second; - format( - "class ${1$$2$$}$;\n" - "struct $3$;\n" - "$dllexport_decl $extern $3$ $4$;\n", - class_desc, classname, DefaultInstanceType(class_desc, options), - DefaultInstanceName(class_desc, options)); + + for (const auto& c : classes_) { + const Descriptor* desc = c.second; + auto a = p->WithAnnotations({{"class", desc}}); + p->Emit( + { + {"class", c.first}, + {"default_type", DefaultInstanceType(desc, options)}, + {"default_name", DefaultInstanceName(desc, options)}, + }, + R"cc( + class $class$; + struct $default_type$; + $dllexport_decl $extern $default_type$ $default_name$; + )cc"); } - for (const auto& p : splits_) { - const Descriptor* class_desc = p.second; - format( - "struct $1$;\n" - "$dllexport_decl $extern const $1$ $2$;\n", - DefaultInstanceType(class_desc, options, /*split=*/true), - DefaultInstanceName(class_desc, options, /*split=*/true)); + + for (const auto& s : splits_) { + const Descriptor* desc = s.second; + p->Emit( + { + {"default_type", + DefaultInstanceType(desc, options, /*split=*/true)}, + {"default_name", + DefaultInstanceName(desc, options, /*split=*/true)}, + }, + R"cc( + struct $default_type$; + $dllexport_decl $extern const $default_type$ $default_name$; + )cc"); } } - void PrintTopLevelDecl(const Formatter& format, - const Options& options) const { - for (const auto& pair : classes_) { - format( - "template<> $dllexport_decl $" - "$1$* Arena::CreateMaybeMessage<$1$>(Arena*);\n", - QualifiedClassName(pair.second, options)); + void PrintTopLevelDecl(io::Printer* p, const Options& options) const { + for (const auto& c : classes_) { + p->Emit({{"class", QualifiedClassName(c.second, options)}}, R"cc( + template <> + $dllexport_decl $$class$* Arena::CreateMaybeMessage<$class$>(Arena*); + )cc"); } } private: - std::map classes_; - std::map enums_; - std::map splits_; + absl::btree_map classes_; + absl::btree_map enums_; + absl::btree_map splits_; }; -static void PublicImportDFS(const FileDescriptor* fd, - std::unordered_set* fd_set) { - for (int i = 0; i < fd->public_dependency_count(); i++) { +static void PublicImportDFS( + const FileDescriptor* fd, + absl::flat_hash_set& fd_set) { + for (int i = 0; i < fd->public_dependency_count(); ++i) { const FileDescriptor* dep = fd->public_dependency(i); - if (fd_set->insert(dep).second) PublicImportDFS(dep, fd_set); + if (fd_set.insert(dep).second) { + PublicImportDFS(dep, fd_set); + } } } -void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateForwardDeclarations(io::Printer* p) { std::vector classes; - std::vector enums; - FlattenMessagesInFile(file_, &classes); // All messages need forward decls. + std::vector enums; if (options_.proto_h) { // proto.h needs extra forward declarations. // All classes / enums referred to as field members std::vector fields; ListAllFields(file_, &fields); - for (int i = 0; i < fields.size(); i++) { - classes.push_back(fields[i]->containing_type()); - classes.push_back(fields[i]->message_type()); - enums.push_back(fields[i]->enum_type()); + for (const auto* field : fields) { + classes.push_back(field->containing_type()); + classes.push_back(field->message_type()); + enums.push_back(field->enum_type()); } + ListAllTypesForServices(file_, &classes); } // Calculate the set of files whose definitions we get through include. // No need to forward declare types that are defined in these. - std::unordered_set public_set; - PublicImportDFS(file_, &public_set); + absl::flat_hash_set public_set; + PublicImportDFS(file_, public_set); - std::map decls; - for (int i = 0; i < classes.size(); i++) { - const Descriptor* d = classes[i]; - if (d && !public_set.count(d->file())) + absl::btree_map decls; + for (const auto* d : classes) { + if (d != nullptr && !public_set.count(d->file())) decls[Namespace(d, options_)].AddMessage(d); } - for (int i = 0; i < enums.size(); i++) { - const EnumDescriptor* d = enums[i]; - if (d && !public_set.count(d->file())) - decls[Namespace(d, options_)].AddEnum(d); + for (const auto* e : enums) { + if (e != nullptr && !public_set.count(e->file())) + decls[Namespace(e, options_)].AddEnum(e); } for (const auto& mg : message_generators_) { const Descriptor* d = mg->descriptor_; - if ((d != nullptr) && (public_set.count(d->file()) == 0u) && + if (d != nullptr && public_set.count(d->file()) == 0u && ShouldSplit(mg->descriptor_, options_)) decls[Namespace(d, options_)].AddSplit(d); } - { - NamespaceOpener ns(format); - for (const auto& pair : decls) { - ns.ChangeTo(pair.first); - pair.second.Print(format, options_); - } - } - format("PROTOBUF_NAMESPACE_OPEN\n"); - for (const auto& pair : decls) { - pair.second.PrintTopLevelDecl(format, options_); + NamespaceOpener ns(p); + for (const auto& decl : decls) { + ns.ChangeTo(decl.first); + decl.second.Print(p, options_); } - format("PROTOBUF_NAMESPACE_CLOSE\n"); -} - -void FileGenerator::GenerateTopHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type) { - Formatter format(printer, variables_); - // Generate top of header. - format( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - "#ifndef $1$\n" - "#define $1$\n" - "\n" - "#include \n" - "#include \n", - IncludeGuard(file_, file_type, options_)); - if (!options_.opensource_runtime && !enum_generators_.empty()) { - // Add header to provide std::is_integral for safe Enum_Name() function. - format("#include \n"); - } - format("\n"); -} -void FileGenerator::GenerateBottomHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type) { - Formatter format(printer, variables_); - format("#endif // $GOOGLE_PROTOBUF$_INCLUDED_$1$\n", - IncludeGuard(file_, file_type, options_)); + ns.ChangeTo("PROTOBUF_NAMESPACE_ID"); + for (const auto& decl : decls) { + decl.second.PrintTopLevelDecl(p, options_); + } } -void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateLibraryIncludes(io::Printer* p) { if (UsingImplicitWeakFields(file_, options_)) { - IncludeFile("net/proto2/public/implicit_weak_message.h", printer); + IncludeFile("net/proto2/public/implicit_weak_message.h", p); } if (HasWeakFields(file_, options_)) { GOOGLE_CHECK(!options_.opensource_runtime); - IncludeFile("net/proto2/public/weak_field_map.h", printer); + IncludeFile("net/proto2/public/weak_field_map.h", p); } if (HasLazyFields(file_, options_, &scc_analyzer_)) { GOOGLE_CHECK(!options_.opensource_runtime); - IncludeFile("net/proto2/public/lazy_field.h", printer); + IncludeFile("net/proto2/public/lazy_field.h", p); } if (ShouldVerify(file_, options_, &scc_analyzer_)) { - IncludeFile("net/proto2/public/wire_format_verify.h", printer); + IncludeFile("net/proto2/public/wire_format_verify.h", p); } if (options_.opensource_runtime) { // Verify the protobuf library header version is compatible with the protoc // version before going any further. - IncludeFile("net/proto2/public/port_def.inc", printer); - format( - "#if PROTOBUF_VERSION < $1$\n" - "#error This file was generated by a newer version of protoc which is\n" - "#error incompatible with your Protocol Buffer headers. Please update\n" - "#error your headers.\n" - "#endif\n" - "#if $2$ < PROTOBUF_MIN_PROTOC_VERSION\n" - "#error This file was generated by an older version of protoc which " - "is\n" - "#error incompatible with your Protocol Buffer headers. Please\n" - "#error regenerate this file with a newer version of protoc.\n" - "#endif\n" - "\n", - PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1 - PROTOBUF_VERSION); // 2 - IncludeFile("net/proto2/public/port_undef.inc", printer); + IncludeFile("net/proto2/public/port_def.inc", p); + p->Emit( + { + {"min_version", + absl::StrCat(PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC)}, + {"version", absl::StrCat(PROTOBUF_VERSION)}, + }, + R"( + #if PROTOBUF_VERSION < $min_version$ + #error "This file was generated by a newer version of protoc which is" + #error "incompatible with your Protocol Buffer headers. Please update" + #error "your headers." + #endif // PROTOBUF_VERSION + + #if $version$ < PROTOBUF_MIN_PROTOC_VERSION + #error "This file was generated by an older version of protoc which is" + #error "incompatible with your Protocol Buffer headers. Please" + #error "regenerate this file with a newer version of protoc." + #endif // PROTOBUF_MIN_PROTOC_VERSION + )"); + IncludeFile("net/proto2/public/port_undef.inc", p); } // OK, it's now safe to #include other files. - IncludeFile("net/proto2/io/public/coded_stream.h", printer); - IncludeFile("net/proto2/public/arena.h", printer); - IncludeFile("net/proto2/public/arenastring.h", printer); + IncludeFile("net/proto2/io/public/coded_stream.h", p); + IncludeFile("net/proto2/public/arena.h", p); + IncludeFile("net/proto2/public/arenastring.h", p); if ((options_.force_inline_string || options_.profile_driven_inline_string) && !options_.opensource_runtime) { - IncludeFile("net/proto2/public/inlined_string_field.h", printer); + IncludeFile("net/proto2/public/inlined_string_field.h", p); } if (HasSimpleBaseClasses(file_, options_)) { - IncludeFile("net/proto2/public/generated_message_bases.h", printer); + IncludeFile("net/proto2/public/generated_message_bases.h", p); } if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - IncludeFile("net/proto2/public/generated_message_tctable_decl.h", printer); + IncludeFile("net/proto2/public/generated_message_tctable_decl.h", p); } - IncludeFile("net/proto2/public/generated_message_util.h", printer); - IncludeFile("net/proto2/public/metadata_lite.h", printer); + IncludeFile("net/proto2/public/generated_message_util.h", p); + IncludeFile("net/proto2/public/metadata_lite.h", p); if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/generated_message_reflection.h", printer); + IncludeFile("net/proto2/public/generated_message_reflection.h", p); } if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/message.h", printer); + IncludeFile("net/proto2/public/message.h", p); } else { - IncludeFile("net/proto2/public/message_lite.h", printer); + IncludeFile("net/proto2/public/message_lite.h", p); } } if (options_.opensource_runtime) { // Open-source relies on unconditional includes of these. - IncludeFileAndExport("net/proto2/public/repeated_field.h", printer); - IncludeFileAndExport("net/proto2/public/extension_set.h", printer); + IncludeFileAndExport("net/proto2/public/repeated_field.h", p); + IncludeFileAndExport("net/proto2/public/extension_set.h", p); } else { // Google3 includes these files only when they are necessary. if (HasExtensionsOrExtendableMessage(file_)) { - IncludeFileAndExport("net/proto2/public/extension_set.h", printer); + IncludeFileAndExport("net/proto2/public/extension_set.h", p); } if (HasRepeatedFields(file_)) { - IncludeFileAndExport("net/proto2/public/repeated_field.h", printer); + IncludeFileAndExport("net/proto2/public/repeated_field.h", p); } if (HasStringPieceFields(file_, options_)) { - IncludeFile("net/proto2/public/string_piece_field_support.h", printer); + IncludeFile("net/proto2/public/string_piece_field_support.h", p); } if (HasCordFields(file_, options_)) { - format("#include \"third_party/absl/strings/cord.h\"\n"); + p->Emit(R"( + #include "third_party/absl/strings/cord.h" + )"); } } if (HasMapFields(file_)) { - IncludeFileAndExport("net/proto2/public/map.h", printer); + IncludeFileAndExport("net/proto2/public/map.h", p); if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/map_entry.h", printer); - IncludeFile("net/proto2/public/map_field_inl.h", printer); + IncludeFile("net/proto2/public/map_entry.h", p); + IncludeFile("net/proto2/public/map_field_inl.h", p); } else { - IncludeFile("net/proto2/public/map_entry_lite.h", printer); - IncludeFile("net/proto2/public/map_field_lite.h", printer); + IncludeFile("net/proto2/public/map_entry_lite.h", p); + IncludeFile("net/proto2/public/map_field_lite.h", p); } } if (HasEnumDefinitions(file_)) { if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/generated_enum_reflection.h", printer); + IncludeFile("net/proto2/public/generated_enum_reflection.h", p); } else { - IncludeFile("net/proto2/public/generated_enum_util.h", printer); + IncludeFile("net/proto2/public/generated_enum_util.h", p); } } if (HasGenericServices(file_, options_)) { - IncludeFile("net/proto2/public/service.h", printer); + IncludeFile("net/proto2/public/service.h", p); } if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { - IncludeFile("net/proto2/public/unknown_field_set.h", printer); + IncludeFile("net/proto2/public/unknown_field_set.h", p); } } -void FileGenerator::GenerateMetadataPragma(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); - if (!info_path.empty() && !options_.annotation_pragma_name.empty() && - !options_.annotation_guard_name.empty()) { - format.Set("guard", options_.annotation_guard_name); - format.Set("pragma", options_.annotation_pragma_name); - format.Set("info_path", info_path); - format( - "#ifdef $guard$\n" - "#pragma $pragma$ \"$info_path$\"\n" - "#endif // $guard$\n"); +void FileGenerator::GenerateMetadataPragma(io::Printer* p, + absl::string_view info_path) { + if (info_path.empty() || options_.annotation_pragma_name.empty() || + options_.annotation_guard_name.empty()) { + return; } + + p->Emit( + { + {"guard", options_.annotation_guard_name}, + {"pragma", options_.annotation_pragma_name}, + {"info_path", std::string(info_path)}, + }, + R"( + #ifdef $guard$ + #pragma $pragma$ "$info_path$" + #endif // $guard$ + )"); } -void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { - Formatter format(printer, variables_); - for (int i = 0; i < file_->dependency_count(); i++) { - std::string basename = StripProto(file_->dependency(i)->name()); +void FileGenerator::GenerateDependencyIncludes(io::Printer* p) { + for (int i = 0; i < file_->dependency_count(); ++i) { + const FileDescriptor* dep = file_->dependency(i); // Do not import weak deps. - if (IsDepWeak(file_->dependency(i))) continue; + if (IsDepWeak(dep)) { + continue; + } + std::string basename = StripProto(dep->name()); if (IsBootstrapProto(options_, file_)) { GetBootstrapBasename(options_, basename, &basename); } - format("#include $1$\n", - CreateHeaderInclude(basename + ".pb.h", file_->dependency(i))); + p->Emit( + {{"name", CreateHeaderInclude(absl::StrCat(basename, ".pb.h"), dep)}}, + R"( + #include $name$ + )"); } } -void FileGenerator::GenerateGlobalStateFunctionDeclarations( - io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateGlobalStateFunctionDeclarations(io::Printer* p) { // Forward-declare the DescriptorTable because this is referenced by .pb.cc // files depending on this file. // @@ -1272,114 +1402,102 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // weak fields must refer to table struct but cannot include the header. // Also it annotates extra weak attributes. // TODO(gerbens) make sure this situation is handled better. - format( - "\n" - "// Internal implementation detail -- do not use these members.\n" - "struct $dllexport_decl $$tablename$ {\n" - " static const $uint32$ offsets[];\n" - "};\n"); + p->Emit(R"cc( + // Internal implementation detail -- do not use these members. + struct $dllexport_decl $$tablename$ { + static const uint32_t offsets[]; + }; + )cc"); + if (HasDescriptorMethods(file_, options_)) { - format( - "$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable " - "$desc_table$;\n"); + p->Emit(R"cc( + $dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable + $desc_table$; + )cc"); } } -void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { - Formatter format(printer, variables_); - // Generate class definitions. - for (int i = 0; i < message_generators_.size(); i++) { - if (i > 0) { - format("\n"); - format(kThinSeparator); - format("\n"); - } - message_generators_[i]->GenerateClassDefinition(printer); +void FileGenerator::GenerateMessageDefinitions(io::Printer* p) { + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + message_generators_[i]->GenerateClassDefinition(p); } } -void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { - // Generate enum definitions. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateDefinition(printer); +void FileGenerator::GenerateEnumDefinitions(io::Printer* p) { + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateDefinition(p); } } -void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { - Formatter format(printer, variables_); - if (HasGenericServices(file_, options_)) { - // Generate service definitions. - for (int i = 0; i < service_generators_.size(); i++) { - if (i > 0) { - format("\n"); - format(kThinSeparator); - format("\n"); - } - service_generators_[i]->GenerateDeclarations(printer); - } +void FileGenerator::GenerateServiceDefinitions(io::Printer* p) { + if (!HasGenericServices(file_, options_)) { + return; + } - format("\n"); - format(kThickSeparator); - format("\n"); + for (int i = 0; i < service_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + service_generators_[i]->GenerateDeclarations(p); } + + p->Emit(R"cc( + $hrule_thick$ + )cc"); } -void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { +void FileGenerator::GenerateExtensionIdentifiers(io::Printer* p) { // Declare extension identifiers. These are in global scope and so only // the global scope extensions. for (auto& extension_generator : extension_generators_) { - if (extension_generator->IsScoped()) continue; - extension_generator->GenerateDeclaration(printer); + if (extension_generator->IsScoped()) { + continue; + } + extension_generator->GenerateDeclaration(p); } } -void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* p) { // TODO(gerbens) remove pragmas when gcc is no longer used. Current version // of gcc fires a bogus error when compiled with strict-aliasing. - format( - "#ifdef __GNUC__\n" - " #pragma GCC diagnostic push\n" - " #pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n" - "#endif // __GNUC__\n"); - // Generate class inline methods. - for (int i = 0; i < message_generators_.size(); i++) { - if (i > 0) { - format(kThinSeparator); - format("\n"); - } - message_generators_[i]->GenerateInlineMethods(printer); - } - format( - "#ifdef __GNUC__\n" - " #pragma GCC diagnostic pop\n" - "#endif // __GNUC__\n"); + p->Emit(R"( + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" + #endif // __GNUC__ + )"); + + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + message_generators_[i]->GenerateInlineMethods(p); + } + + p->Emit(R"( + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif // __GNUC__ + )"); +} - for (int i = 0; i < message_generators_.size(); i++) { - if (i > 0) { - format(kThinSeparator); - format("\n"); - } +void FileGenerator::GenerateProto2NamespaceEnumSpecializations(io::Printer* p) { + // Emit GetEnumDescriptor specializations into google::protobuf namespace. + if (!HasEnumDefinitions(file_)) { + return; } -} -void FileGenerator::GenerateProto2NamespaceEnumSpecializations( - io::Printer* printer) { - Formatter format(printer, variables_); - // Emit GetEnumDescriptor specializations into google::protobuf namespace: - if (HasEnumDefinitions(file_)) { - format("\n"); - { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - format("\n"); - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - format("\n"); - } + p->PrintRaw("\n"); + NamespaceOpener ns(ProtobufNamespace(options_), p); + p->PrintRaw("\n"); + for (auto& gen : enum_generators_) { + gen->GenerateGetEnumDescriptorSpecializations(p); } + p->PrintRaw("\n"); } - } // namespace cpp } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/cpp/file.h b/src/google/protobuf/compiler/cpp/file.h index 072b9138af..cd38345043 100644 --- a/src/google/protobuf/compiler/cpp/file.h +++ b/src/google/protobuf/compiler/cpp/file.h @@ -36,55 +36,47 @@ #define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ #include +#include #include #include #include #include #include "google/protobuf/stubs/common.h" +#include "google/protobuf/compiler/scc.h" +#include "absl/container/flat_hash_set.h" +#include "google/protobuf/compiler/cpp/enum.h" +#include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/helpers.h" -#include "google/protobuf/port.h" -#include "google/protobuf/compiler/scc.h" +#include "google/protobuf/compiler/cpp/message.h" #include "google/protobuf/compiler/cpp/options.h" +#include "google/protobuf/compiler/cpp/service.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/port.h" -namespace google { -namespace protobuf { -class FileDescriptor; // descriptor.h -namespace io { -class Printer; // printer.h -} -} // namespace protobuf -} // namespace google namespace google { namespace protobuf { namespace compiler { namespace cpp { - -class EnumGenerator; // enum.h -class MessageGenerator; // message.h -class ServiceGenerator; // service.h -class ExtensionGenerator; // extension.h - class FileGenerator { public: - // See generator.cc for the meaning of dllexport_decl. FileGenerator(const FileDescriptor* file, const Options& options); + FileGenerator(const FileGenerator&) = delete; FileGenerator& operator=(const FileGenerator&) = delete; - ~FileGenerator(); - // Shared code between the two header generators below. - void GenerateHeader(io::Printer* printer); + ~FileGenerator() = default; // info_path, if non-empty, should be the path (relative to printer's // output) to the metadata file describing this proto header. - void GenerateProtoHeader(io::Printer* printer, const std::string& info_path); + void GenerateProtoHeader(io::Printer* p, absl::string_view info_path); // info_path, if non-empty, should be the path (relative to printer's // output) to the metadata file describing this PB header. - void GeneratePBHeader(io::Printer* printer, const std::string& info_path); - void GenerateSource(io::Printer* printer); + void GeneratePBHeader(io::Printer* p, absl::string_view info_path); + void GenerateSource(io::Printer* p); // The following member functions are used when the lite_implicit_weak_fields // option is set. In this mode the code is organized a bit differently to @@ -95,80 +87,86 @@ class FileGenerator { int NumMessages() const { return message_generators_.size(); } int NumExtensions() const { return extension_generators_.size(); } // Generates the source file for one message. - void GenerateSourceForMessage(int idx, io::Printer* printer); + void GenerateSourceForMessage(int idx, io::Printer* p); // Generates the source file for one extension. - void GenerateSourceForExtension(int idx, io::Printer* printer); + void GenerateSourceForExtension(int idx, io::Printer* p); // Generates a source file containing everything except messages and // extensions. - void GenerateGlobalSource(io::Printer* printer); + void GenerateGlobalSource(io::Printer* p); private: + // Generates a file, setting up the necessary accoutrements that start and + // end the file, calling `cb` in between. + // + // This includes header guards and file-global variables. + void GenerateFile(io::Printer* p, GeneratedFileType file_type, + std::function cb); + + // Shared code between the two header generators. + void GenerateSharedHeaderCode(io::Printer* p); + // Internal type used by GenerateForwardDeclarations (defined in file.cc). class ForwardDeclarations; struct CrossFileReferences; - void IncludeFile(const std::string& google3_name, io::Printer* printer) { - DoIncludeFile(google3_name, false, printer); + void IncludeFile(absl::string_view google3_name, io::Printer* p) { + DoIncludeFile(google3_name, false, p); } - void IncludeFileAndExport(const std::string& google3_name, - io::Printer* printer) { - DoIncludeFile(google3_name, true, printer); + void IncludeFileAndExport(absl::string_view google3_name, io::Printer* p) { + DoIncludeFile(google3_name, true, p); } - void DoIncludeFile(const std::string& google3_name, bool do_export, - io::Printer* printer); + void DoIncludeFile(absl::string_view google3_name, bool do_export, + io::Printer* p); - std::string CreateHeaderInclude(const std::string& basename, + std::string CreateHeaderInclude(absl::string_view basename, const FileDescriptor* file); void GetCrossFileReferencesForField(const FieldDescriptor* field, CrossFileReferences* refs); void GetCrossFileReferencesForFile(const FileDescriptor* file, CrossFileReferences* refs); void GenerateInternalForwardDeclarations(const CrossFileReferences& refs, - io::Printer* printer); - void GenerateSourceIncludes(io::Printer* printer); - void GenerateSourcePrelude(io::Printer* printer); - void GenerateSourceDefaultInstance(int idx, io::Printer* printer); + io::Printer* p); + void GenerateSourceIncludes(io::Printer* p); + void GenerateSourcePrelude(io::Printer* p); + void GenerateSourceDefaultInstance(int idx, io::Printer* p); void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs, - io::Printer* printer); - void GenerateReflectionInitializationCode(io::Printer* printer); + io::Printer* p); + void GenerateReflectionInitializationCode(io::Printer* p); // For other imports, generates their forward-declarations. - void GenerateForwardDeclarations(io::Printer* printer); + void GenerateForwardDeclarations(io::Printer* p); // Generates top or bottom of a header file. - void GenerateTopHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type); - void GenerateBottomHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type); + void GenerateTopHeaderGuard(io::Printer* p, GeneratedFileType file_type); + void GenerateBottomHeaderGuard(io::Printer* p, GeneratedFileType file_type); // Generates #include directives. - void GenerateLibraryIncludes(io::Printer* printer); - void GenerateDependencyIncludes(io::Printer* printer); + void GenerateLibraryIncludes(io::Printer* p); + void GenerateDependencyIncludes(io::Printer* p); // Generate a pragma to pull in metadata using the given info_path (if // non-empty). info_path should be relative to printer's output. - void GenerateMetadataPragma(io::Printer* printer, - const std::string& info_path); + void GenerateMetadataPragma(io::Printer* p, absl::string_view info_path); // Generates a couple of different pieces before definitions: - void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); + void GenerateGlobalStateFunctionDeclarations(io::Printer* p); // Generates types for classes. - void GenerateMessageDefinitions(io::Printer* printer); + void GenerateMessageDefinitions(io::Printer* p); - void GenerateEnumDefinitions(io::Printer* printer); + void GenerateEnumDefinitions(io::Printer* p); // Generates generic service definitions. - void GenerateServiceDefinitions(io::Printer* printer); + void GenerateServiceDefinitions(io::Printer* p); // Generates extension identifiers. - void GenerateExtensionIdentifiers(io::Printer* printer); + void GenerateExtensionIdentifiers(io::Printer* p); // Generates inline function definitions. - void GenerateInlineFunctionDefinitions(io::Printer* printer); + void GenerateInlineFunctionDefinitions(io::Printer* p); - void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); + void GenerateProto2NamespaceEnumSpecializations(io::Printer* p); // Sometimes the names we use in a .proto file happen to be defined as // macros on some platforms (e.g., macro/minor used in plugin.proto are @@ -177,7 +175,7 @@ class FileGenerator { // undef the macro for these few platforms, or rename the field name for all // platforms. Since these names are part of protobuf public API, renaming is // generally a breaking change so we prefer the #undef approach. - void GenerateMacroUndefs(io::Printer* printer); + void GenerateMacroUndefs(io::Printer* p); bool IsDepWeak(const FileDescriptor* dep) const { if (weak_deps_.count(dep) != 0) { @@ -187,13 +185,16 @@ class FileGenerator { return false; } - std::set weak_deps_; + absl::flat_hash_set weak_deps_; const FileDescriptor* file_; - const Options options_; + Options options_; MessageSCCAnalyzer scc_analyzer_; + // This member is unused and should be deleted once all old-style variable + // maps are gone. + // TODO(b/245791219) std::map variables_; // Contains the post-order walk of all the messages (and child messages) in diff --git a/src/google/protobuf/compiler/cpp/generator.cc b/src/google/protobuf/compiler/cpp/generator.cc index 578d0d6969..8403312cb2 100644 --- a/src/google/protobuf/compiler/cpp/generator.cc +++ b/src/google/protobuf/compiler/cpp/generator.cc @@ -70,6 +70,9 @@ absl::flat_hash_map CommonVars( {"uint32", "uint32_t"}, {"uint64", "uint64_t"}, + {"hrule_thick", kThickSeparator}, + {"hrule_thin", kThinSeparator}, + // Warning: there is some clever naming/splitting here to avoid extract // script rewrites. The names of these variables must not be things that // the extract script will rewrite. That's why we use "CHK" (for example) diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index bba2ff5221..c89a48dcc2 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "google/protobuf/stubs/common.h" @@ -1087,6 +1088,46 @@ bool IsWellKnownMessage(const FileDescriptor* file) { return well_known_files->find(file->name()) != well_known_files->end(); } +void NamespaceOpener::ChangeTo(absl::string_view name) { + std::vector new_stack = + absl::StrSplit(name, "::", absl::SkipEmpty()); + size_t len = std::min(name_stack_.size(), new_stack.size()); + size_t common_idx = 0; + while (common_idx < len) { + if (name_stack_[common_idx] != new_stack[common_idx]) { + break; + } + ++common_idx; + } + + for (size_t i = name_stack_.size(); i > common_idx; i--) { + const auto& ns = name_stack_[i - 1]; + if (ns == "PROTOBUF_NAMESPACE_ID") { + p_->Emit(R"cc( + PROTOBUF_NAMESPACE_CLOSE + )cc"); + } else { + p_->Emit({{"ns", ns}}, R"( + } // namespace $ns$ + )"); + } + } + for (size_t i = common_idx; i < new_stack.size(); ++i) { + const auto& ns = new_stack[i]; + if (ns == "PROTOBUF_NAMESPACE_ID") { + p_->Emit(R"cc( + PROTOBUF_NAMESPACE_OPEN + )cc"); + } else { + p_->Emit({{"ns", ns}}, R"( + namespace $ns$ { + )"); + } + } + + name_stack_ = std::move(new_stack); +} + static void GenerateUtf8CheckCode(const FieldDescriptor* field, const Options& options, bool for_parse, const char* parameters, diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 19120e313c..251214f2fa 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h @@ -44,7 +44,7 @@ #include "google/protobuf/compiler/scc.h" #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/options.h" @@ -52,6 +52,7 @@ #include "google/protobuf/io/printer.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/port.h" +#include "google/protobuf/stubs/strutil.h" #include "absl/strings/str_cat.h" // Must be included last. @@ -887,43 +888,21 @@ void PrintFieldComment(const Formatter& format, const T* field) { class PROTOC_EXPORT NamespaceOpener { public: - explicit NamespaceOpener(const Formatter& format) - : printer_(format.printer()) {} - NamespaceOpener(const std::string& name, const Formatter& format) + explicit NamespaceOpener(io::Printer* p) : p_(p) {} + explicit NamespaceOpener(const Formatter& format) : p_(format.printer()) {} + NamespaceOpener(absl::string_view name, const Formatter& format) : NamespaceOpener(format) { ChangeTo(name); } + NamespaceOpener(absl::string_view name, io::Printer* p) : NamespaceOpener(p) { + ChangeTo(name); + } ~NamespaceOpener() { ChangeTo(""); } - void ChangeTo(const std::string& name) { - std::vector new_stack_ = - absl::StrSplit(name, "::", absl::SkipEmpty()); - size_t len = std::min(name_stack_.size(), new_stack_.size()); - size_t common_idx = 0; - while (common_idx < len) { - if (name_stack_[common_idx] != new_stack_[common_idx]) break; - common_idx++; - } - for (auto it = name_stack_.crbegin(); - it != name_stack_.crend() - common_idx; ++it) { - if (*it == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n"); - } else { - printer_->Print("} // namespace $ns$\n", "ns", *it); - } - } - name_stack_.swap(new_stack_); - for (size_t i = common_idx; i < name_stack_.size(); ++i) { - if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_OPEN\n"); - } else { - printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]); - } - } - } + void ChangeTo(absl::string_view name); private: - io::Printer* printer_; + io::Printer* p_; std::vector name_stack_; }; diff --git a/src/google/protobuf/compiler/cpp/parse_function_generator.cc b/src/google/protobuf/compiler/cpp/parse_function_generator.cc index e4f057f48b..00f48236d9 100644 --- a/src/google/protobuf/compiler/cpp/parse_function_generator.cc +++ b/src/google/protobuf/compiler/cpp/parse_function_generator.cc @@ -630,11 +630,11 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) { std::string func_name = info.func_name; // For 1-byte tags we have a more optimized version of the varint parser // that can hardcode the offset and has bit. - if (HasSuffixString(func_name, "V8S1") || - HasSuffixString(func_name, "V32S1") || - HasSuffixString(func_name, "V64S1")) { - std::string field_type = HasSuffixString(func_name, "V8S1") ? "bool" - : HasSuffixString(func_name, "V32S1") + if (absl::EndsWith(func_name, "V8S1") || + absl::EndsWith(func_name, "V32S1") || + absl::EndsWith(func_name, "V64S1")) { + std::string field_type = absl::EndsWith(func_name, "V8S1") ? "bool" + : absl::EndsWith(func_name, "V32S1") ? "uint32_t" : "uint64_t"; func_name = diff --git a/src/google/protobuf/compiler/csharp/BUILD.bazel b/src/google/protobuf/compiler/csharp/BUILD.bazel index ce29ea6b5d..df3d7bfb17 100644 --- a/src/google/protobuf/compiler/csharp/BUILD.bazel +++ b/src/google/protobuf/compiler/csharp/BUILD.bazel @@ -56,7 +56,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/strings", diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index 72a4c12bc8..507b8263fc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc @@ -33,9 +33,6 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" #include "google/protobuf/descriptor.h" diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 14b43ad36a..846da9b6c9 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -33,22 +33,13 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf { @@ -65,6 +56,9 @@ EnumGenerator::~EnumGenerator() { void EnumGenerator::Generate(io::Printer* printer) { WriteEnumDocComment(printer, descriptor_); + if (descriptor_->options().deprecated()) { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } printer->Print("$access_level$ enum $name$ {\n", "access_level", class_access_level(), "name", descriptor_->name()); @@ -73,6 +67,9 @@ void EnumGenerator::Generate(io::Printer* printer) { std::set used_number; for (int i = 0; i < descriptor_->value_count(); i++) { WriteEnumValueDocComment(printer, descriptor_->value(i)); + if (descriptor_->value(i)->options().deprecated()) { + printer->Print("[global::System.ObsoleteAttribute]\n"); + } std::string original_name = descriptor_->value(i)->name(); std::string name = GetEnumValueName(descriptor_->name(), descriptor_->value(i)->name()); diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index e808b7d573..da205df607 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc @@ -37,21 +37,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/wire_format.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" // Must be last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 9eecde9fec..b2ad2c21b8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h @@ -32,17 +32,13 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__ #include + +#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" #include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" - -#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/csharp/csharp_source_generator_base.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 8a3286e1fb..0dab0718fa 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc @@ -34,16 +34,6 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" -#include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" #include "google/protobuf/compiler/csharp/csharp_reflection_class.h" diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index dd60eb714e..b917d8f145 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc @@ -41,9 +41,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "google/protobuf/compiler/csharp/csharp_enum_field.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" @@ -57,8 +55,6 @@ #include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h" #include "google/protobuf/compiler/csharp/csharp_wrapper_field.h" #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/io/printer.h" -#include "google/protobuf/wire_format.h" // Must be last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 55660b7499..9c48cc8a0e 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h @@ -39,11 +39,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/port.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/port_def.inc" -#include "google/protobuf/port.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index 5511536b8e..efe87f2a6a 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc @@ -34,20 +34,10 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 993e9d6d27..92fe55dd1c 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc @@ -35,27 +35,18 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/wire_format.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_enum.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/wire_format_lite.h" // Must be last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 9d70bd013a..1f30bdc492 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -34,23 +34,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/wire_format.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 61f4b7b0eb..e7688113bd 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h @@ -39,8 +39,6 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ #include -#include "google/protobuf/port.h" -#include "google/protobuf/stubs/common.h" #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index f42ff90048..1467bd3687 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc @@ -33,22 +33,13 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index b767c9d75d..95a00566fc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc @@ -33,25 +33,16 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_join.h" #include "google/protobuf/compiler/csharp/csharp_enum.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_message.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" // Must be last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 287b22e67f..a2de7e5f19 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -48,7 +48,7 @@ #include #include -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_join.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" @@ -282,7 +282,7 @@ static std::string CanonicalizePath(absl::string_view path) { // backslashes are standard. Let's avoid confusion and use only forward // slashes. std::string path_str; - if (HasPrefixString(path, "\\\\")) { + if (absl::StartsWith(path, "\\\\")) { // Avoid converting two leading backslashes. path_str = "\\\\" + absl::StrReplaceAll(path.substr(2), {{"\\", "/"}}); } else { @@ -306,8 +306,8 @@ static std::string CanonicalizePath(absl::string_view path) { } static inline bool ContainsParentReference(absl::string_view path) { - return path == ".." || HasPrefixString(path, "../") || - HasSuffixString(path, "/..") || absl::StrContains(path, "/../"); + return path == ".." || absl::StartsWith(path, "../") || + absl::EndsWith(path, "/..") || absl::StrContains(path, "/../"); } // Maps a file from an old location to a new one. Typically, old_prefix is @@ -336,7 +336,7 @@ static bool ApplyMapping(absl::string_view filename, // We do not allow the file name to use "..". return false; } - if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) { + if (absl::StartsWith(filename, "/") || IsWindowsAbsolutePath(filename)) { // This is an absolute path, so it isn't matched by the empty string. return false; } @@ -344,7 +344,7 @@ static bool ApplyMapping(absl::string_view filename, if (!result->empty()) result->push_back('/'); result->append(std::string(filename)); return true; - } else if (HasPrefixString(filename, old_prefix)) { + } else if (absl::StartsWith(filename, old_prefix)) { // old_prefix is a prefix of the filename. Is it the whole filename? if (filename.size() == old_prefix.size()) { // Yep, it's an exact match. diff --git a/src/google/protobuf/compiler/java/BUILD.bazel b/src/google/protobuf/compiler/java/BUILD.bazel index 06d90f67ba..5c4d5f162d 100644 --- a/src/google/protobuf/compiler/java/BUILD.bazel +++ b/src/google/protobuf/compiler/java/BUILD.bazel @@ -81,7 +81,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/strings", diff --git a/src/google/protobuf/compiler/java/helpers.cc b/src/google/protobuf/compiler/java/helpers.cc index 625ff18b2e..680a750766 100644 --- a/src/google/protobuf/compiler/java/helpers.cc +++ b/src/google/protobuf/compiler/java/helpers.cc @@ -221,7 +221,7 @@ std::string ToCamelCase(const std::string& input, bool lower_first) { if (i == '_') { capitalize_next = true; } else if (capitalize_next) { - result.push_back(ToUpperCh(i)); + result.push_back(absl::ascii_toupper(i)); capitalize_next = false; } else { result.push_back(i); @@ -230,20 +230,12 @@ std::string ToCamelCase(const std::string& input, bool lower_first) { // Lower-case the first letter. if (lower_first && !result.empty()) { - result[0] = ToLowerCh(result[0]); + result[0] = absl::ascii_tolower(result[0]); } return result; } -char ToUpperCh(char ch) { - return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch; -} - -char ToLowerCh(char ch) { - return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch; -} - std::string UnderscoresToCamelCase(const FieldDescriptor* field) { return UnderscoresToCamelCase(FieldName(field), false); } diff --git a/src/google/protobuf/compiler/java/helpers.h b/src/google/protobuf/compiler/java/helpers.h index eb16096aca..6fe43aedce 100644 --- a/src/google/protobuf/compiler/java/helpers.h +++ b/src/google/protobuf/compiler/java/helpers.h @@ -84,9 +84,6 @@ void PrintEnumVerifierLogic(io::Printer* printer, // first letter. std::string ToCamelCase(const std::string& input, bool lower_first); -char ToUpperCh(char ch); -char ToLowerCh(char ch); - // Converts a name to camel-case. If cap_first_letter is true, capitalize the // first letter. std::string UnderscoresToCamelCase(const std::string& name, diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index f19cbf5224..a4cc9e66ff 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -39,19 +39,18 @@ #include #include -#include "google/protobuf/stubs/strutil.h" - #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h" -#include "google/protobuf/testing/file.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.pb.h" #include #include "absl/strings/str_join.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #include "absl/strings/substitute.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" @@ -208,8 +207,8 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, std::string* error) const { bool annotate = false; for (int i = 0; i < file->message_type_count(); i++) { - if (HasPrefixString(file->message_type(i)->name(), "MockCodeGenerator_")) { - std::string command = StripPrefixString( + if (absl::StartsWith(file->message_type(i)->name(), "MockCodeGenerator_")) { + absl::string_view command = absl::StripPrefix( file->message_type(i)->name(), "MockCodeGenerator_"); if (command == "Error") { *error = "Saw message type MockCodeGenerator_Error."; @@ -252,12 +251,12 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, } } - bool insert_endlines = HasPrefixString(parameter, "insert_endlines="); - if (insert_endlines || HasPrefixString(parameter, "insert=")) { + bool insert_endlines = absl::StartsWith(parameter, "insert_endlines="); + if (insert_endlines || absl::StartsWith(parameter, "insert=")) { std::vector insert_into = absl::StrSplit( - StripPrefixString( - parameter, insert_endlines ? "insert_endlines=" : "insert="), - ",", absl::SkipEmpty()); + absl::StripPrefix(parameter, + insert_endlines ? "insert_endlines=" : "insert="), + ',', absl::SkipEmpty()); for (size_t i = 0; i < insert_into.size(); i++) { { @@ -265,7 +264,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, std::string content = GetOutputFileContent(name_, "first_insert", file, context); if (insert_endlines) { - GlobalReplaceSubstring(",", ",\n", &content); + absl::StrReplaceAll({{",", ",\n"}}, &content); } if (annotate) { auto* annotation = info.add_annotation(); @@ -290,7 +289,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file, std::string content = GetOutputFileContent(name_, "second_insert", file, context); if (insert_endlines) { - GlobalReplaceSubstring(",", ",\n", &content); + absl::StrReplaceAll({{",", ",\n"}}, &content); } if (annotate) { auto* annotation = info.add_annotation(); diff --git a/src/google/protobuf/compiler/objectivec/BUILD.bazel b/src/google/protobuf/compiler/objectivec/BUILD.bazel index d1cb4604f1..ee2ef1f0e0 100644 --- a/src/google/protobuf/compiler/objectivec/BUILD.bazel +++ b/src/google/protobuf/compiler/objectivec/BUILD.bazel @@ -35,6 +35,7 @@ cc_library( "objectivec_message_field.h", "objectivec_nsobject_methods.h", "objectivec_oneof.h", + "objectivec_options.h", "objectivec_primitive_field.h", ], copts = COPTS, @@ -44,7 +45,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/strings", ], diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 7e1283b841..13954ca563 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc @@ -28,22 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_enum.h" + +#include #include #include -#include "google/protobuf/compiler/objectivec/objectivec_enum.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include // std::find() namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index c70766a6ef..c97c9feade 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc @@ -28,20 +28,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_extension.h" + #include -#include "google/protobuf/compiler/objectivec/objectivec_extension.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" #include "google/protobuf/io/printer.h" namespace google { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index f11cbde086..b98955b632 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -28,24 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_field.h" + #include -#include "google/protobuf/compiler/objectivec/objectivec_field.h" -#include "google/protobuf/compiler/objectivec/objectivec_helpers.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum_field.h" +#include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_map_field.h" #include "google/protobuf/compiler/objectivec/objectivec_message_field.h" #include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index a420c2c69b..84910fff23 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc @@ -29,26 +29,18 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "google/protobuf/compiler/objectivec/objectivec_file.h" + +#include +#include +#include + +#include "google/protobuf/compiler/code_generator.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum.h" #include "google/protobuf/compiler/objectivec/objectivec_extension.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_message.h" -#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream_impl.h" -#include "google/protobuf/stubs/stl_util.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include // std::find() -#include -#include // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for errors. diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.h b/src/google/protobuf/compiler/objectivec/objectivec_file.h index 842ddff154..5063611923 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.h @@ -35,6 +35,7 @@ #include #include #include +#include "google/protobuf/compiler/objectivec/objectivec_options.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" @@ -49,17 +50,6 @@ class MessageGenerator; class FileGenerator { public: - struct GenerationOptions { - GenerationOptions() - // TODO(thomasvl): Eventually flip this default to false for better - // interop with Swift if proto usages span modules made from ObjC sources. - : headers_use_forward_declarations(true) {} - std::string generate_for_named_framework; - std::string named_framework_to_proto_path_mappings_path; - std::string runtime_import_prefix; - bool headers_use_forward_declarations; - }; - // Wrapper for some common state that is shared between file generations to // improve performance when more than one file is generated at a time. struct CommonState { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc index e2efe29b20..e5f2fb3d6e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc @@ -28,24 +28,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_generator.h" + #include #include #include #include -#include "google/protobuf/compiler/objectivec/objectivec_generator.h" + +#include "absl/strings/ascii.h" +#include "absl/strings/str_split.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/objectivec/objectivec_file.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" namespace google { namespace protobuf { @@ -103,11 +99,11 @@ bool ObjectiveCGenerator::GenerateAll( // e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework Options validation_options; - FileGenerator::GenerationOptions generation_options; + GenerationOptions generation_options; std::vector > options; ParseGeneratorParameter(parameter, &options); - for (int i = 0; i < options.size(); i++) { + for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "expected_prefixes_path") { // Path to find a file containing the expected prefixes // (objc_class_prefix "PREFIX") for proto packages (package NAME). The @@ -197,7 +193,8 @@ bool ObjectiveCGenerator::GenerateAll( // generated files. When integrating ObjC protos into a build system, // this can be used to avoid having to add the runtime directory to the // header search path since the generate #import will be more complete. - generation_options.runtime_import_prefix = StripSuffixString(options[i].second, "/"); + generation_options.runtime_import_prefix = + std::string(absl::StripSuffix(options[i].second, "/")); } else if (options[i].first == "package_to_prefix_mappings_path") { // Path to use for when loading the objc class prefix mappings to use. // The `objc_class_prefix` file option is always honored first if one is present. diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.h b/src/google/protobuf/compiler/objectivec/objectivec_generator.h index f863fc8686..acd9ce895f 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_generator.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.h @@ -37,7 +37,9 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" +// clang-format off #include "google/protobuf/port_def.inc" +// clang-format on namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index 1dbff83749..17e3f4b9b8 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc @@ -31,31 +31,33 @@ #ifndef _MSC_VER #include #endif -#include #include #include +#include + +#include #include #include #include -#include #include #include #include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/ascii.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/str_split.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/coded_stream.h" +#include "google/protobuf/io/io_win32.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream_impl.h" -#include "google/protobuf/io/io_win32.h" #include "google/protobuf/port.h" #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for errors. @@ -199,7 +201,7 @@ std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDesc if (prefix_lookup != package_to_prefix_map_.end()) { return prefix_lookup->second; - } + } return ""; } @@ -466,7 +468,7 @@ std::string SanitizeNameForObjC(const std::string& prefix, // a) Doesn't start with the prefix or // b) Isn't equivalent to the prefix or // c) Has the prefix, but the letter after the prefix is lowercase - if (HasPrefixString(input, prefix)) { + if (absl::StartsWith(input, prefix)) { if (input.length() == prefix.length() || !absl::ascii_isupper(input[prefix.length()])) { sanitized = prefix + input; } else { @@ -513,13 +515,13 @@ void PathSplit(const std::string& path, std::string* directory, } } -bool IsSpecialName(const std::string& name, const std::string* special_names, - size_t count) { +bool IsSpecialNamePrefix(const std::string& name, + const std::string* special_names, size_t count) { for (size_t i = 0; i < count; ++i) { - size_t length = special_names[i].length(); + const size_t length = special_names[i].length(); if (name.compare(0, length, special_names[i]) == 0) { if (name.length() > length) { - // If name is longer than the retained_name[i] that it matches + // If name is longer than the special_names[i] that it matches // the next character must be not lower case (newton vs newTon vs // new_ton). return !absl::ascii_islower(name[length]); @@ -589,14 +591,46 @@ bool IsRetainedName(const std::string& name) { // http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html static const std::string retained_names[] = {"new", "alloc", "copy", "mutableCopy"}; - return IsSpecialName(name, retained_names, - sizeof(retained_names) / sizeof(retained_names[0])); + return IsSpecialNamePrefix( + name, retained_names, sizeof(retained_names) / sizeof(retained_names[0])); } bool IsInitName(const std::string& name) { static const std::string init_names[] = {"init"}; - return IsSpecialName(name, init_names, - sizeof(init_names) / sizeof(init_names[0])); + return IsSpecialNamePrefix(name, init_names, + sizeof(init_names) / sizeof(init_names[0])); +} + +bool IsCreateName(const std::string& name) { + // List of segments from + // https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029 + static const std::string create_names[] = {"Create", "Copy"}; + const size_t count = sizeof(create_names) / sizeof(create_names[0]); + + for (size_t i = 0; i < count; ++i) { + const size_t length = create_names[i].length(); + size_t pos = name.find(create_names[i]); + if (pos != std::string::npos) { + // The above docs don't actually call out anything about the characters + // before the special words. So it's not clear if something like + // "FOOCreate" would or would not match the "The Create Rule", but by not + // checking, and claiming it does match, then callers will annotate with + // `cf_returns_not_retained` which will ensure things work as desired. + // + // The footnote here is the docs do have a passing reference to "NoCopy", + // but again, not looking for that and just returning `true` will cause + // callers to annotate the api as not being a Create Rule function. + + // If name is longer than the create_names[i] that it matches the next + // character must be not lower case (Copyright vs CopyFoo vs Copy_Foo). + if (name.length() > pos + length) { + return !absl::ascii_islower(name[pos + length]); + } else { + return true; + } + } + } + return false; } std::string BaseFileName(const FileDescriptor* file) { @@ -764,7 +798,7 @@ std::string EnumValueShortName(const EnumValueDescriptor* descriptor) { const std::string class_name = EnumName(descriptor->type()); const std::string long_name_prefix = class_name + "_"; const std::string long_name = EnumValueName(descriptor); - return StripPrefixString(long_name, long_name_prefix); + return std::string(absl::StripPrefix(long_name, long_name_prefix)); } std::string UnCamelCaseEnumShortName(const std::string& name) { @@ -793,7 +827,7 @@ std::string FieldName(const FieldDescriptor* field) { result += "Array"; } else { // If it wasn't repeated, but ends in "Array", force on the _p suffix. - if (HasSuffixString(result, "Array")) { + if (absl::EndsWith(result, "Array")) { result += "_p"; } } @@ -843,20 +877,22 @@ std::string ObjCClassDeclaration(const std::string& class_name) { } std::string UnCamelCaseFieldName(const std::string& name, const FieldDescriptor* field) { - std::string worker(name); - if (HasSuffixString(worker, "_p")) { - worker = StripSuffixString(worker, "_p"); + absl::string_view worker(name); + if (absl::EndsWith(worker, "_p")) { + worker = absl::StripSuffix(worker, "_p"); } - if (field->is_repeated() && HasSuffixString(worker, "Array")) { - worker = StripSuffixString(worker, "Array"); + if (field->is_repeated() && absl::EndsWith(worker, "Array")) { + worker = absl::StripSuffix(worker, "Array"); } if (field->type() == FieldDescriptor::TYPE_GROUP) { if (worker.length() > 0) { if (absl::ascii_islower(worker[0])) { - worker[0] = absl::ascii_toupper(worker[0]); + std::string copy(worker); + copy[0] = absl::ascii_toupper(worker[0]); + return copy; } } - return worker; + return std::string(worker); } else { std::string result; for (int i = 0; i < worker.size(); i++) { @@ -1219,7 +1255,7 @@ std::string BuildCommentsString(const SourceLocation& location, for (size_t i = 0; i < lines.size(); i++) { std::string line = absl::StrReplaceAll( - StripPrefixString(lines[i], " "), + absl::StripPrefix(lines[i], " "), {// HeaderDoc and appledoc use '\' and '@' for markers; escape them. {"\\", "\\\\"}, {"@", "\\@"}, @@ -1227,9 +1263,9 @@ std::string BuildCommentsString(const SourceLocation& location, {"/*", "/\\*"}, {"*/", "*\\/"}}); line = prefix + line; - StripWhitespace(&line); + absl::StripAsciiWhitespace(&line); // If not a one line, need to add the first space before *, as - // StripWhitespace would have removed it. + // absl::StripAsciiWhitespace would have removed it. line = (add_leading_space ? " " : "") + line; final_comments += line + suffix; } @@ -1392,7 +1428,7 @@ bool ValidateObjCClassPrefix( other_package_for_prefix = i->first; // Stop on the first real package listing, if it was a no_package file // specific entry, keep looking to try and find a package one. - if (!HasPrefixString(other_package_for_prefix, no_package_prefix)) { + if (!absl::StartsWith(other_package_for_prefix, no_package_prefix)) { break; } } @@ -1405,16 +1441,19 @@ bool ValidateObjCClassPrefix( *out_error = "error: Found 'option objc_class_prefix = \"" + prefix + "\";' in '" + file->name() + "'; that prefix is already used for "; - if (HasPrefixString(other_package_for_prefix, no_package_prefix)) { - *out_error += "file '" + - StripPrefixString(other_package_for_prefix, no_package_prefix) + - "'."; + if (absl::StartsWith(other_package_for_prefix, no_package_prefix)) { + absl::StrAppend( + out_error, "file '", + absl::StripPrefix(other_package_for_prefix, no_package_prefix), + "'."); } else { - *out_error += "'package " + other_package_for_prefix + ";'."; + absl::StrAppend(out_error, "'package ", + other_package_for_prefix + ";'."); } - *out_error += - " It can only be reused by adding '" + lookup_key + " = " + prefix + - "' to the expected prefixes file (" + expected_prefixes_path + ")."; + absl::StrAppend(out_error, " It can only be reused by adding '", + lookup_key, " = ", prefix, + "' to the expected prefixes file (", + expected_prefixes_path, ")."); return false; // Only report first usage of the prefix. } } // !prefix.empty() && have_expected_prefix_file diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h index 9cee305080..a0a8d5b6e8 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.h @@ -40,7 +40,9 @@ #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/zero_copy_stream.h" +// clang-format off #include "google/protobuf/port_def.inc" +// clang-format on namespace google { namespace protobuf { @@ -92,6 +94,10 @@ bool PROTOC_EXPORT IsRetainedName(const std::string& name); // handling under ARC. bool PROTOC_EXPORT IsInitName(const std::string& name); +// Returns true if the name requires a cf_returns_not_retained attribute applied +// to it. +bool PROTOC_EXPORT IsCreateName(const std::string& name); + // Gets the objc_class_prefix or the prefix made from the proto package. std::string PROTOC_EXPORT FileClassPrefix(const FileDescriptor* file); diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc index 7ad11f04cb..e6d0a7c613 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc @@ -101,10 +101,12 @@ TEST(ObjCHelper, TextFormatDecodeData_DecodeDataForString_ByteCodes) { // Long name so multiple decode ops are needed. + // clang-format off input_for_decode = "longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000"; desired_output_for_decode = "long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000"; + // clang-format on expected = std::string("\x04\xA5\xA4\xA2\xBF\x1F\x0E\x84\x0", 9); result = TextFormatDecodeData::DecodeDataForString(input_for_decode, desired_output_for_decode); @@ -154,11 +156,13 @@ TEST(ObjCHelper, TextFormatDecodeData_RawStrings) { EXPECT_EQ(4, decode_data.num_entries()); uint8_t expected_data[] = { + // clang-format off 0x4, 0x1, 0x0, 'z', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 0x0, 0x3, 0x0, 'a', 'b', 'c', 'd', 'e', 'z', 'g', 'h', 'I', 'J', 0x0, 0x2, 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 0x0, 0x4, 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 'z', 0x0, + // clang-format on }; std::string expected((const char*)expected_data, sizeof(expected_data)); @@ -172,12 +176,15 @@ TEST(ObjCHelper, TextFormatDecodeData_ByteCodes) { decode_data.AddString(3, "abcdefghIJ", "_AbcdefghIJ"); decode_data.AddString(2, "abcdefghIJ", "Abcd_EfghIJ"); decode_data.AddString(4, "abcdefghIJ", "ABCD__EfghI_j"); + // clang-format off decode_data.AddString(1000, "longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000", "long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000"); + // clang-format on EXPECT_EQ(5, decode_data.num_entries()); + // clang-format off uint8_t expected_data[] = { 0x5, // All as is (00 op) @@ -196,6 +203,7 @@ TEST(ObjCHelper, TextFormatDecodeData_ByteCodes) { // underscore, as is + 3 (00 op) 0xE8, 0x07, 0x04, 0xA5, 0xA4, 0xA2, 0xBF, 0x1F, 0x0E, 0x84, 0x0, }; + // clang-format on std::string expected((const char*)expected_data, sizeof(expected_data)); EXPECT_EQ(expected, decode_data.Data()); @@ -369,6 +377,90 @@ TEST(ObjCHelper, ParseSimple_RejectLinesNoMessage) { } } +TEST(ObjCHelper, IsRetainedName) { + EXPECT_TRUE(IsRetainedName("new")); + EXPECT_TRUE(IsRetainedName("alloc")); + EXPECT_TRUE(IsRetainedName("copy")); + EXPECT_TRUE(IsRetainedName("mutableCopy")); + EXPECT_TRUE(IsRetainedName("newFoo")); + EXPECT_TRUE(IsRetainedName("allocFoo")); + EXPECT_TRUE(IsRetainedName("copyFoo")); + EXPECT_TRUE(IsRetainedName("mutableCopyFoo")); + EXPECT_TRUE(IsRetainedName("new_foo")); + EXPECT_TRUE(IsRetainedName("alloc_foo")); + EXPECT_TRUE(IsRetainedName("copy_foo")); + EXPECT_TRUE(IsRetainedName("mutableCopy_foo")); + + EXPECT_FALSE(IsRetainedName("")); + EXPECT_FALSE(IsRetainedName("ne")); + EXPECT_FALSE(IsRetainedName("all")); + EXPECT_FALSE(IsRetainedName("co")); + EXPECT_FALSE(IsRetainedName("mutable")); + EXPECT_FALSE(IsRetainedName("New")); + EXPECT_FALSE(IsRetainedName("Alloc")); + EXPECT_FALSE(IsRetainedName("Copy")); + EXPECT_FALSE(IsRetainedName("MutableCopy")); + EXPECT_FALSE(IsRetainedName("newer")); + EXPECT_FALSE(IsRetainedName("alloced")); + EXPECT_FALSE(IsRetainedName("copying")); + EXPECT_FALSE(IsRetainedName("mutableCopying")); + + EXPECT_FALSE(IsRetainedName("init")); + EXPECT_FALSE(IsRetainedName("Create")); + EXPECT_FALSE(IsRetainedName("Copy")); +} + +TEST(ObjCHelper, IsInitName) { + EXPECT_TRUE(IsInitName("init")); + EXPECT_TRUE(IsInitName("initFoo")); + EXPECT_TRUE(IsInitName("init_foo")); + + EXPECT_FALSE(IsInitName("")); + EXPECT_FALSE(IsInitName("in")); + EXPECT_FALSE(IsInitName("Init")); + EXPECT_FALSE(IsInitName("inIt")); + EXPECT_FALSE(IsInitName("initial")); + EXPECT_FALSE(IsInitName("initiAl")); + EXPECT_FALSE(IsInitName("fooInit")); + EXPECT_FALSE(IsInitName("foo_init")); + + EXPECT_FALSE(IsInitName("new")); + EXPECT_FALSE(IsInitName("alloc")); + EXPECT_FALSE(IsInitName("copy")); + EXPECT_FALSE(IsInitName("mutableCopy")); + EXPECT_FALSE(IsInitName("Create")); + EXPECT_FALSE(IsInitName("Copy")); +} + +TEST(ObjCHelper, IsCreateName) { + EXPECT_TRUE(IsCreateName("Create")); + EXPECT_TRUE(IsCreateName("Copy")); + EXPECT_TRUE(IsCreateName("CreateFoo")); + EXPECT_TRUE(IsCreateName("CopyFoo")); + EXPECT_TRUE(IsCreateName("Create_foo")); + EXPECT_TRUE(IsCreateName("Copy_foo")); + EXPECT_TRUE(IsCreateName("ReCreate")); + EXPECT_TRUE(IsCreateName("ReCopy")); + EXPECT_TRUE(IsCreateName("FOOCreate")); + EXPECT_TRUE(IsCreateName("FOOCopy")); + EXPECT_TRUE(IsCreateName("CreateWithCopy")); + + EXPECT_FALSE(IsCreateName("")); + EXPECT_FALSE(IsCreateName("Crea")); + EXPECT_FALSE(IsCreateName("Co")); + EXPECT_FALSE(IsCreateName("create")); + EXPECT_FALSE(IsCreateName("recreate")); + EXPECT_FALSE(IsCreateName("recopy")); + EXPECT_FALSE(IsCreateName("ReCreated")); + EXPECT_FALSE(IsCreateName("ReCopying")); + + EXPECT_FALSE(IsCreateName("init")); + EXPECT_FALSE(IsCreateName("new")); + EXPECT_FALSE(IsCreateName("alloc")); + EXPECT_FALSE(IsCreateName("copy")); + EXPECT_TRUE(IsCreateName("mutableCopy")); +} + // TODO(thomasvl): Should probably add some unittests for all the special cases // of name mangling (class name, field name, enum names). Rather than doing // this with an ObjC test in the objectivec directory, we should be able to diff --git a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h index c16e818e2e..20c538e3bb 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_map_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_map_field.h @@ -33,6 +33,7 @@ #include #include + #include "google/protobuf/compiler/objectivec/objectivec_field.h" namespace google { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index 945d095b7e..98161494da 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc @@ -28,28 +28,19 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_message.h" + #include #include #include -#include "google/protobuf/compiler/objectivec/objectivec_message.h" +#include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum.h" #include "google/protobuf/compiler/objectivec/objectivec_extension.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" -#include "google/protobuf/stubs/stl_util.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "google/protobuf/io/printer.h" -#include "google/protobuf/io/coded_stream.h" -#include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/printer.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h index 12e191eed2..19f23a29e7 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_message_field.h @@ -33,6 +33,7 @@ #include #include + #include "google/protobuf/compiler/objectivec/objectivec_field.h" namespace google { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc index 269cd52660..279928bba4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc @@ -28,21 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_oneof.h" + #include #include -#include "google/protobuf/compiler/objectivec/objectivec_oneof.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h index 27e9c2a423..c89cdd91b4 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.h @@ -31,9 +31,10 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__ #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__ -#include #include +#include #include + #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" diff --git a/src/google/protobuf/compiler/objectivec/objectivec_options.h b/src/google/protobuf/compiler/objectivec/objectivec_options.h new file mode 100644 index 0000000000..07b90b3d69 --- /dev/null +++ b/src/google/protobuf/compiler/objectivec/objectivec_options.h @@ -0,0 +1,56 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__ +#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__ + +#include + +namespace google { +namespace protobuf { +namespace compiler { +namespace objectivec { + +// Generation options, documented within objectivec_generator.cc. +struct GenerationOptions { + std::string generate_for_named_framework; + std::string named_framework_to_proto_path_mappings_path; + std::string runtime_import_prefix; + // TODO(thomasvl): Eventually flip this default to false for better interop + // with Swift if proto usages span modules made from ObjC sources. + bool headers_use_forward_declarations = true; +}; + +} // namespace objectivec +} // namespace compiler +} // namespace protobuf +} // namespace google + +#endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_OPTIONS_H__ diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc index 2c30d6bac5..c9339a5aaa 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc @@ -28,21 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" + #include #include +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" -#include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" namespace google { namespace protobuf { diff --git a/src/google/protobuf/compiler/php/BUILD.bazel b/src/google/protobuf/compiler/php/BUILD.bazel index 5911760be9..d2540189d1 100644 --- a/src/google/protobuf/compiler/php/BUILD.bazel +++ b/src/google/protobuf/compiler/php/BUILD.bazel @@ -17,7 +17,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/strings", ], diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 7c1daec42f..7466f74e5a 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -33,13 +33,12 @@ #include #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/compiler/plugin.h" -#include "google/protobuf/descriptor.h" #include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" #include "absl/strings/str_replace.h" +#include "absl/strings/str_split.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -153,8 +152,7 @@ std::string ReservedNamePrefix(const std::string& classname, template std::string DescriptorFullName(const DescriptorType* desc, bool is_internal) { if (is_internal) { - return StringReplace(desc->full_name(), - "google.protobuf", + return StringReplace(desc->full_name(), "google.protobuf", "google.protobuf.internal", false); } else { return desc->full_name(); @@ -1110,7 +1108,7 @@ static bool NeedsUnwrapping(const FileDescriptor* file, has_aggregate_metadata_prefix = true; } else { for (const auto& prefix : options.aggregate_metadata_prefixes) { - if (HasPrefixString(file->package(), prefix)) { + if (absl::StartsWith(file->package(), prefix)) { has_aggregate_metadata_prefix = true; break; } @@ -2392,7 +2390,7 @@ bool Generator::GenerateAll(const std::vector& files, for (const auto& option : absl::StrSplit(parameter, ",", absl::SkipEmpty())) { const std::vector option_pair = absl::StrSplit(option, "=", absl::SkipEmpty()); - if (HasPrefixString(option_pair[0], "aggregate_metadata")) { + if (absl::StartsWith(option_pair[0], "aggregate_metadata")) { options.aggregate_metadata = true; for (const auto& prefix : absl::StrSplit(option_pair[1], "#", absl::AllowEmpty())) { options.aggregate_metadata_prefixes.emplace(prefix); diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index bcaf8d509d..87d4dda712 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -1,10 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/compiler/plugin.proto -#include +#include "google/protobuf/compiler/plugin.pb.h" #include - #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/extension_set.h" #include "google/protobuf/wire_format_lite.h" @@ -13,13 +12,12 @@ #include "google/protobuf/reflection_ops.h" #include "google/protobuf/wire_format.h" // @@protoc_insertion_point(includes) -#include "google/protobuf/port_def.inc" +// Must be included last. +#include "google/protobuf/port_def.inc" PROTOBUF_PRAGMA_INIT_SEG - namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = _pb::internal; - +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; PROTOBUF_NAMESPACE_OPEN namespace compiler { PROTOBUF_CONSTEXPR Version::Version( @@ -31,14 +29,15 @@ PROTOBUF_CONSTEXPR Version::Version( , /*decltype(_impl_.minor_)*/0 , /*decltype(_impl_.patch_)*/0} {} struct VersionDefaultTypeInternal { - PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~VersionDefaultTypeInternal() {} union { Version _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -48,14 +47,15 @@ PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest( , /*decltype(_impl_.parameter_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.compiler_version_)*/nullptr} {} struct CodeGeneratorRequestDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorRequestDefaultTypeInternal() {} union { CodeGeneratorRequest _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -65,14 +65,15 @@ PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File( , /*decltype(_impl_.content_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.generated_code_info_)*/nullptr} {} struct CodeGeneratorResponse_FileDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponse_FileDefaultTypeInternal() {} union { CodeGeneratorResponse_File _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -81,138 +82,163 @@ PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse( , /*decltype(_impl_.error_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.supported_features_)*/uint64_t{0u}} {} struct CodeGeneratorResponseDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponseDefaultTypeInternal() {} union { CodeGeneratorResponse _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; } // namespace compiler PROTOBUF_NAMESPACE_CLOSE static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; -static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; - -const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_), - 1, - 2, - 3, - 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_), - ~0u, - 0, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_), - 0, - 1, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), - 0, - 1, - ~0u, +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; +const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_), + 1, + 2, + 3, + 0, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_), + ~0u, + 0, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_), + 0, + 1, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), + 0, + 1, + ~0u, }; -static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, - { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, - { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, - { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, + { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, + { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, + { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, }; static const ::_pb::Message* const file_default_instances[] = { - &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._instance, }; - -const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n%google/protobuf/compiler/plugin.proto\022" - "\030google.protobuf.compiler\032 google/protob" - "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" - "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" - "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" - "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" - "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." - "FileDescriptorProto\022;\n\020compiler_version\030" - "\003 \001(\0132!.google.protobuf.compiler.Version" - "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" - "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " - "\003(\01324.google.protobuf.compiler.CodeGener" - "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022" - "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" - "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google." - "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n" - "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION" - "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl" - "uginProtosZ)google.golang.org/protobuf/t" - "ypes/pluginpb" - ; -static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { - &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, +const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n%google/protobuf/compiler/plugin.proto\022" + "\030google.protobuf.compiler\032 google/protob" + "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" + "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" + "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" + "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" + "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." + "FileDescriptorProto\022;\n\020compiler_version\030" + "\003 \001(\0132!.google.protobuf.compiler.Version" + "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" + "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " + "\003(\01324.google.protobuf.compiler.CodeGener" + "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022" + "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" + "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google." + "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n" + "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION" + "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl" + "uginProtosZ)google.golang.org/protobuf/t" + "ypes/pluginpb" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = + { + &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + false, + false, + 773, + descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, + 1, + 4, + schemas, + file_default_instances, + TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; } - // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); PROTOBUF_NAMESPACE_OPEN namespace compiler { const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() { @@ -236,7 +262,6 @@ constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MIN; constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX; constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) - // =================================================================== class Version::_Internal { @@ -562,7 +587,6 @@ void Version::InternalSwap(Version* other) { &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]); } - // =================================================================== class CodeGeneratorRequest::_Internal { @@ -916,7 +940,6 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]); } - // =================================================================== class CodeGeneratorResponse_File::_Internal { @@ -1308,7 +1331,6 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]); } - // =================================================================== class CodeGeneratorResponse::_Internal { @@ -1601,7 +1623,6 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]); } - // @@protoc_insertion_point(namespace_scope) } // namespace compiler PROTOBUF_NAMESPACE_CLOSE @@ -1623,6 +1644,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRespo return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena); } PROTOBUF_NAMESPACE_CLOSE - // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 8e8c111451..b4489e5f08 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -6,19 +6,20 @@ #include #include +#include #include "google/protobuf/port_def.inc" #if PROTOBUF_VERSION < 3021000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION +#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION #include "google/protobuf/port_undef.inc" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/arena.h" @@ -31,16 +32,20 @@ #include "google/protobuf/extension_set.h" // IWYU pragma: export #include "google/protobuf/generated_enum_reflection.h" #include "google/protobuf/unknown_field_set.h" -#include +#include "google/protobuf/descriptor.pb.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" + #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT #ifdef major #undef major -#endif +#endif // major #ifdef minor #undef minor -#endif +#endif // minor + PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; @@ -51,7 +56,8 @@ PROTOBUF_NAMESPACE_CLOSE struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { static const uint32_t offsets[]; }; -PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; +PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; PROTOBUF_NAMESPACE_OPEN namespace compiler { class CodeGeneratorRequest; @@ -67,16 +73,18 @@ class Version; struct VersionDefaultTypeInternal; PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; } // namespace compiler +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*); PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*); -PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN namespace compiler { - enum CodeGeneratorResponse_Feature : int { CodeGeneratorResponse_Feature_FEATURE_NONE = 0, CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1 @@ -104,8 +112,12 @@ inline bool CodeGeneratorResponse_Feature_Parse( return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( CodeGeneratorResponse_Feature_descriptor(), name, value); } + // =================================================================== + +// ------------------------------------------------------------------- + class PROTOC_EXPORT Version final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { public: @@ -313,8 +325,7 @@ class PROTOC_EXPORT Version final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOC_EXPORT CodeGeneratorRequest final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { @@ -544,8 +555,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { @@ -769,8 +779,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOC_EXPORT CodeGeneratorResponse final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { @@ -1005,12 +1014,17 @@ class PROTOC_EXPORT CodeGeneratorResponse final : // =================================================================== + + // =================================================================== + #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ +// ------------------------------------------------------------------- + // Version // optional int32 major = 1; @@ -1861,20 +1875,14 @@ CodeGeneratorResponse::file() const { } #ifdef __GNUC__ - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) - } // namespace compiler PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {}; @@ -1888,4 +1896,5 @@ PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh + +#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh diff --git a/src/google/protobuf/compiler/python/BUILD.bazel b/src/google/protobuf/compiler/python/BUILD.bazel index b45a00b808..fadb1767cc 100644 --- a/src/google/protobuf/compiler/python/BUILD.bazel +++ b/src/google/protobuf/compiler/python/BUILD.bazel @@ -25,7 +25,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/strings", "@com_google_absl//absl/synchronization", diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index 3d580adc32..deb5b09f94 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc @@ -59,6 +59,8 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/strip.h" #include "absl/strings/substitute.h" #include "google/protobuf/compiler/python/helpers.h" #include "google/protobuf/compiler/python/pyi_generator.h" @@ -82,8 +84,8 @@ std::string ModuleAlias(const std::string& filename) { // We can't have dots in the module name, so we replace each with _dot_. // But that could lead to a collision between a.b and a_dot_b, so we also // duplicate each underscore. - GlobalReplaceSubstring("_", "__", &module_name); - GlobalReplaceSubstring(".", "_dot_", &module_name); + absl::StrReplaceAll({{"_", "__"}}, &module_name); + absl::StrReplaceAll({{".", "_dot_"}}, &module_name); return module_name; } @@ -315,7 +317,8 @@ bool Generator::Generate(const FileDescriptor* file, } std::string module_name = ModuleName(file->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print( "_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, '$module_name$', " @@ -386,7 +389,8 @@ void Generator::PrintImports() const { std::string module_name = ModuleName(filename); std::string module_alias = ModuleAlias(filename); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } if (ContainsPythonKeyword(module_name)) { // If the module path contains a Python keyword, we have to quote the @@ -419,7 +423,8 @@ void Generator::PrintImports() const { for (int i = 0; i < file_->public_dependency_count(); ++i) { std::string module_name = ModuleName(file_->public_dependency(i)->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("from $module$ import *\n", "module", module_name); } @@ -592,7 +597,8 @@ void Generator::PrintDescriptorKeyAndModuleName( kDescriptorKey, "descriptor_name", name); std::string module_name = ModuleName(file_->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("__module__ = '$module_name$'\n", "module_name", module_name); } @@ -784,7 +790,8 @@ void Generator::PrintMessage(const Descriptor& message_descriptor, printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n"); std::string module_name = ModuleName(file_->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("'__module__' : '$module_name$'\n", "module_name", module_name); diff --git a/src/google/protobuf/compiler/python/helpers.cc b/src/google/protobuf/compiler/python/helpers.cc index 711d555249..e58ed9ccc8 100644 --- a/src/google/protobuf/compiler/python/helpers.cc +++ b/src/google/protobuf/compiler/python/helpers.cc @@ -32,9 +32,11 @@ #include -#include "google/protobuf/stubs/strutil.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" @@ -47,8 +49,7 @@ namespace python { // Returns the Python module name expected for a given .proto filename. std::string ModuleName(const std::string& filename) { std::string basename = StripProto(filename); - ReplaceCharacters(&basename, "-", '_'); - ReplaceCharacters(&basename, "/", '.'); + absl::StrReplaceAll({{"-", "_"}, {"/", "."}}, &basename); return basename + "_pb2"; } @@ -94,7 +95,7 @@ std::string GetFileName(const FileDescriptor* file_des, const std::string& suffix) { std::string module_name = ModuleName(file_des->name()); std::string filename = module_name; - ReplaceCharacters(&filename, ".", '/'); + absl::StrReplaceAll({{".", "/"}}, &filename); filename += suffix; return filename; } diff --git a/src/google/protobuf/compiler/python/helpers.h b/src/google/protobuf/compiler/python/helpers.h index 1fff3c9d79..3741fbb2f3 100644 --- a/src/google/protobuf/compiler/python/helpers.h +++ b/src/google/protobuf/compiler/python/helpers.h @@ -42,7 +42,6 @@ namespace protobuf { namespace compiler { namespace python { - std::string ModuleName(const std::string& filename); std::string StrippedModuleName(const std::string& filename); bool ContainsPythonKeyword(const std::string& module_name); diff --git a/src/google/protobuf/compiler/python/pyi_generator.cc b/src/google/protobuf/compiler/python/pyi_generator.cc index 7c723ef853..b09ceb2f69 100644 --- a/src/google/protobuf/compiler/python/pyi_generator.cc +++ b/src/google/protobuf/compiler/python/pyi_generator.cc @@ -34,7 +34,7 @@ #include #include "absl/strings/ascii.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/python/helpers.h" #include "google/protobuf/descriptor.h" @@ -577,7 +577,7 @@ bool PyiGenerator::Generate(const FileDescriptor* file, for (const std::pair& option : options) { if (option.first == "annotate_code") { annotate_code = true; - } else if (HasSuffixString(option.first, ".pyi")) { + } else if (absl::EndsWith(option.first, ".pyi")) { filename = option.first; } else { *error = "Unknown generator option: " + option.first; diff --git a/src/google/protobuf/compiler/ruby/BUILD.bazel b/src/google/protobuf/compiler/ruby/BUILD.bazel index 73b0fcf96e..7abfeb60dd 100644 --- a/src/google/protobuf/compiler/ruby/BUILD.bazel +++ b/src/google/protobuf/compiler/ruby/BUILD.bazel @@ -17,7 +17,7 @@ cc_library( "//src/google/protobuf/compiler:__pkg__", ], deps = [ - "//:protobuf", + "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", ], ) diff --git a/src/google/protobuf/compiler/subprocess.cc b/src/google/protobuf/compiler/subprocess.cc index 02c23871b9..ae1f5dd049 100644 --- a/src/google/protobuf/compiler/subprocess.cc +++ b/src/google/protobuf/compiler/subprocess.cc @@ -54,16 +54,6 @@ namespace google { namespace protobuf { namespace compiler { -namespace { -char* portable_strdup(const char* s) { - char* ns = (char*)malloc(strlen(s) + 1); - if (ns != nullptr) { - strcpy(ns, s); - } - return ns; -} -} // namespace - #ifdef _WIN32 static void CloseHandleOrDie(HANDLE handle) { @@ -318,6 +308,16 @@ Subprocess::~Subprocess() { } } +namespace { +char* portable_strdup(const char* s) { + char* ns = (char*)malloc(strlen(s) + 1); + if (ns != nullptr) { + strcpy(ns, s); + } + return ns; +} +} // namespace + void Subprocess::Start(const std::string& program, SearchMode search_mode) { // Note that we assume that there are no other threads, thus we don't have to // do crazy stuff like using socket pairs or avoiding libc locks. diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index ddebcf6184..f61eb22e03 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -2505,12 +2505,7 @@ std::string FieldDescriptor::DefaultValueAsString( // CopyTo methods ==================================================== void FileDescriptor::CopyTo(FileDescriptorProto* proto) const { - proto->set_name(name()); - if (!package().empty()) proto->set_package(package()); - // TODO(liujisi): Also populate when syntax="proto2". - if (syntax() == SYNTAX_PROTO3 - ) proto->set_syntax(SyntaxName(syntax())); - + CopyHeadingTo(proto); for (int i = 0; i < dependency_count(); i++) { proto->add_dependency(dependency(i)->name()); @@ -2542,6 +2537,19 @@ void FileDescriptor::CopyTo(FileDescriptorProto* proto) const { } } +void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const { + proto->set_name(name()); + if (!package().empty()) { + proto->set_package(package()); + } + + // TODO(liujisi): Also populate when syntax="proto2". + if (syntax() == SYNTAX_PROTO3 + ) { + proto->set_syntax(SyntaxName(syntax())); + } +} + void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const { if (message_type_count() != proto->message_type_size() || extension_count() != proto->extension_size()) { @@ -2900,7 +2908,7 @@ class SourceLocationCommentPrinter { // the DebugString() output. std::string FormatComment(const std::string& comment_text) { std::string stripped_comment = comment_text; - StripWhitespace(&stripped_comment); + absl::StripAsciiWhitespace(&stripped_comment); std::vector lines = absl::StrSplit(stripped_comment, "\n"); std::string output; for (const std::string& line : lines) { @@ -4205,7 +4213,7 @@ void DescriptorBuilder::AddWarning( bool DescriptorBuilder::IsInPackage(const FileDescriptor* file, const std::string& package_name) { - return HasPrefixString(file->package(), package_name) && + return absl::StartsWith(file->package(), package_name) && (file->package().size() == package_name.size() || file->package()[package_name.size()] == '.'); } diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index dfe8d42cab..5a8b5f3661 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -761,6 +761,10 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase { // Reflection::HasField() is semantically meaningful. bool has_presence() const; + // Returns true if this TYPE_STRING-typed field requires UTF-8 validation on + // parse. + bool requires_utf8_validation() const; + // Index of this field within the message's field array, or the file or // extension scope's extensions array. int index() const; @@ -1143,6 +1147,13 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase { // with AllowUnknownDependencies() set. bool is_placeholder() const; + // Returns true whether this is a "closed" enum, meaning that it: + // - Has a fixed set of named values. + // - Encountering values not in this set causes them to be treated as unknown + // fields. + // - The first value (i.e., the default) may be nonzero. + bool is_closed() const; + // Reserved fields ------------------------------------------------- // A range of reserved field numbers. @@ -1650,6 +1661,9 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase { // Fill the json_name field of FieldDescriptorProto for all fields. Can only // be called after CopyTo(). void CopyJsonNameTo(FileDescriptorProto* proto) const; + // Fills in the file-level settings of this file (e.g. syntax, package, + // file options) to `proto`. + void CopyHeadingTo(FileDescriptorProto* proto) const; // See Descriptor::DebugString(). std::string DebugString() const; @@ -2200,6 +2214,10 @@ PROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, reserved_range, const EnumDescriptor::ReservedRange*) PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_name_count, int) +inline bool EnumDescriptor::is_closed() const { + return file()->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + PROTOBUF_DEFINE_NAME_ACCESSOR(EnumValueDescriptor) PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, number, int) PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, type, const EnumDescriptor*) @@ -2364,6 +2382,11 @@ inline bool FieldDescriptor::has_presence() const { file()->syntax() == FileDescriptor::SYNTAX_PROTO2; } +inline bool FieldDescriptor::requires_utf8_validation() const { + return type() == TYPE_STRING && + file()->syntax() == FileDescriptor::SYNTAX_PROTO3; +} + // To save space, index() is computed by looking at the descriptor's position // in the parent's array of children. inline int FieldDescriptor::index() const { diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index b8a24a9f53..7d17e6b5eb 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -1,10 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/descriptor.proto -#include +#include "google/protobuf/descriptor.pb.h" #include - #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/extension_set.h" #include "google/protobuf/wire_format_lite.h" @@ -13,27 +12,27 @@ #include "google/protobuf/reflection_ops.h" #include "google/protobuf/wire_format.h" // @@protoc_insertion_point(includes) -#include "google/protobuf/port_def.inc" +// Must be included last. +#include "google/protobuf/port_def.inc" PROTOBUF_PRAGMA_INIT_SEG - namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = _pb::internal; - +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; PROTOBUF_NAMESPACE_OPEN PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.file_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct FileDescriptorSetDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorSetDefaultTypeInternal() {} union { FileDescriptorSet _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -52,14 +51,15 @@ PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto( , /*decltype(_impl_.options_)*/nullptr , /*decltype(_impl_.source_code_info_)*/nullptr} {} struct FileDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorProtoDefaultTypeInternal() {} union { FileDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -68,14 +68,15 @@ PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRang , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ExtensionRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ExtensionRangeDefaultTypeInternal() {} union { DescriptorProto_ExtensionRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -83,14 +84,15 @@ PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ReservedRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ReservedRangeDefaultTypeInternal() {} union { DescriptorProto_ReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -106,28 +108,30 @@ PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto( , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct DescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProtoDefaultTypeInternal() {} union { DescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct ExtensionRangeOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ExtensionRangeOptionsDefaultTypeInternal() {} union { ExtensionRangeOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -144,14 +148,15 @@ PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto( , /*decltype(_impl_.label_)*/1 , /*decltype(_impl_.type_)*/1} {} struct FieldDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FieldDescriptorProtoDefaultTypeInternal() {} union { FieldDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -159,14 +164,15 @@ PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto( , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct OneofDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~OneofDescriptorProtoDefaultTypeInternal() {} union { OneofDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -174,14 +180,15 @@ PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_En , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {} union { EnumDescriptorProto_EnumReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -192,14 +199,15 @@ PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto( , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct EnumDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProtoDefaultTypeInternal() {} union { EnumDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -208,14 +216,15 @@ PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto( , /*decltype(_impl_.options_)*/nullptr , /*decltype(_impl_.number_)*/0} {} struct EnumValueDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueDescriptorProtoDefaultTypeInternal() {} union { EnumValueDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -224,14 +233,15 @@ PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto( , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct ServiceDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceDescriptorProtoDefaultTypeInternal() {} union { ServiceDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -243,14 +253,15 @@ PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto( , /*decltype(_impl_.client_streaming_)*/false , /*decltype(_impl_.server_streaming_)*/false} {} struct MethodDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MethodDescriptorProtoDefaultTypeInternal() {} union { MethodDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR FileOptions::FileOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -278,14 +289,15 @@ PROTOBUF_CONSTEXPR FileOptions::FileOptions( , /*decltype(_impl_.optimize_for_)*/1 , /*decltype(_impl_.cc_enable_arenas_)*/true} {} struct FileOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileOptionsDefaultTypeInternal() {} union { FileOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_; PROTOBUF_CONSTEXPR MessageOptions::MessageOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -297,14 +309,15 @@ PROTOBUF_CONSTEXPR MessageOptions::MessageOptions( , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.map_entry_)*/false} {} struct MessageOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MessageOptionsDefaultTypeInternal() {} union { MessageOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; PROTOBUF_CONSTEXPR FieldOptions::FieldOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -319,28 +332,30 @@ PROTOBUF_CONSTEXPR FieldOptions::FieldOptions( , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.weak_)*/false} {} struct FieldOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FieldOptionsDefaultTypeInternal() {} union { FieldOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; PROTOBUF_CONSTEXPR OneofOptions::OneofOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct OneofOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~OneofOptionsDefaultTypeInternal() {} union { OneofOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; PROTOBUF_CONSTEXPR EnumOptions::EnumOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -350,14 +365,15 @@ PROTOBUF_CONSTEXPR EnumOptions::EnumOptions( , /*decltype(_impl_.allow_alias_)*/false , /*decltype(_impl_.deprecated_)*/false} {} struct EnumOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumOptionsDefaultTypeInternal() {} union { EnumOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -366,14 +382,15 @@ PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions( , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_.deprecated_)*/false} {} struct EnumValueOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueOptionsDefaultTypeInternal() {} union { EnumValueOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -382,14 +399,15 @@ PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions( , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_.deprecated_)*/false} {} struct ServiceOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceOptionsDefaultTypeInternal() {} union { ServiceOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; PROTOBUF_CONSTEXPR MethodOptions::MethodOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -399,14 +417,15 @@ PROTOBUF_CONSTEXPR MethodOptions::MethodOptions( , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.idempotency_level_)*/0} {} struct MethodOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MethodOptionsDefaultTypeInternal() {} union { MethodOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -414,14 +433,15 @@ PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart( , /*decltype(_impl_.name_part_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.is_extension_)*/false} {} struct UninterpretedOption_NamePartDefaultTypeInternal { - PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOption_NamePartDefaultTypeInternal() {} union { UninterpretedOption_NamePart _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -434,14 +454,15 @@ PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption( , /*decltype(_impl_.negative_int_value_)*/int64_t{0} , /*decltype(_impl_.double_value_)*/0} {} struct UninterpretedOptionDefaultTypeInternal { - PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOptionDefaultTypeInternal() {} union { UninterpretedOption _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -454,27 +475,29 @@ PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location( , /*decltype(_impl_.leading_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.trailing_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} struct SourceCodeInfo_LocationDefaultTypeInternal { - PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfo_LocationDefaultTypeInternal() {} union { SourceCodeInfo_Location _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.location_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct SourceCodeInfoDefaultTypeInternal { - PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfoDefaultTypeInternal() {} union { SourceCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -486,734 +509,759 @@ PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( , /*decltype(_impl_.end_)*/0 , /*decltype(_impl_.semantic_)*/0} {} struct GeneratedCodeInfo_AnnotationDefaultTypeInternal { - PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {} union { GeneratedCodeInfo_Annotation _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.annotation_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct GeneratedCodeInfoDefaultTypeInternal { - PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfoDefaultTypeInternal() {} union { GeneratedCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; PROTOBUF_NAMESPACE_CLOSE static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[7]; -static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; - -const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.edition_), - 0, - 1, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - 4, - 5, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), - 1, - 2, - 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_), - 0, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - 1, - ~0u, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_), - 0, - 6, - 9, - 10, - 2, - 1, - 3, - 7, - 4, - 5, - 8, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_), - 0, - ~0u, - 1, - ~0u, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), - 0, - 2, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), - 0, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_), - 0, - 1, - 2, - 3, - 4, - 5, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_), - 0, - 1, - 10, - 11, - 12, - 18, - 2, - 13, - 14, - 15, - 16, - 17, - 19, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_), - 0, - 1, - 2, - 3, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), - 0, - 2, - 1, - 3, - 4, - 5, - 6, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), - 0, - 1, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), - 0, - 1, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_), - ~0u, - 0, - 3, - 4, - 5, - 1, - 2, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_), - ~0u, - ~0u, - 0, - 1, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.semantic_), - ~0u, - 0, - 1, - 2, - 3, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; +const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.edition_), + 0, + 1, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 4, + 5, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), + 1, + 2, + 0, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_), + 0, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 1, + ~0u, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_), + 0, + 6, + 9, + 10, + 2, + 1, + 3, + 7, + 4, + 5, + 8, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_), + 0, + ~0u, + 1, + ~0u, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), + 0, + 2, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), + 0, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_), + 0, + 1, + 2, + 3, + 4, + 5, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_), + 0, + 1, + 10, + 11, + 12, + 18, + 2, + 13, + 14, + 15, + 16, + 17, + 19, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_), + 0, + 1, + 2, + 3, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), + 0, + 2, + 1, + 3, + 4, + 5, + 6, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), + 0, + 1, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), + 0, + 1, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_), + ~0u, + 0, + 3, + 4, + 5, + 1, + 2, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_), + ~0u, + ~0u, + 0, + 1, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.semantic_), + ~0u, + 0, + 1, + 2, + 3, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), }; -static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, - { 9, 30, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, - { 43, 54, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, - { 57, 67, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, - { 69, 87, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, - { 97, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, - { 106, 125, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, - { 136, 146, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, - { 148, 158, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, - { 160, 173, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, - { 178, 189, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, - { 192, 203, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, - { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, - { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, - { 276, 289, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 294, 310, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 318, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 327, 338, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 341, 351, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 353, 363, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 379, 389, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 391, 406, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 413, 426, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 431, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 440, 453, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 458, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, + { 9, 30, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, + { 43, 54, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, + { 57, 67, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, + { 69, 87, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, + { 97, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, + { 106, 125, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, + { 136, 146, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, + { 148, 158, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, + { 160, 173, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, + { 178, 189, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, + { 192, 203, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, + { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, + { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, + { 276, 289, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, + { 294, 310, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 318, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 327, 338, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 341, 351, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 353, 363, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 379, 389, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 391, 406, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 413, 426, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 431, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 440, 453, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 458, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; static const ::_pb::Message* const file_default_instances[] = { - &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance, +}; +const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n google/protobuf/descriptor.proto\022\017goog" + "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" + "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" + "roto\"\354\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" + "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" + "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" + "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" + "le.protobuf.DescriptorProto\0227\n\tenum_type" + "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" + "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." + "ServiceDescriptorProto\0228\n\textension\030\007 \003(" + "\0132%.google.protobuf.FieldDescriptorProto" + "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" + "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" + "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" + "(\t\022\017\n\007edition\030\r \001(\t\"\251\005\n\017DescriptorProto\022" + "\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.google.pr" + "otobuf.FieldDescriptorProto\0228\n\textension" + "\030\006 \003(\0132%.google.protobuf.FieldDescriptor" + "Proto\0225\n\013nested_type\030\003 \003(\0132 .google.prot" + "obuf.DescriptorProto\0227\n\tenum_type\030\004 \003(\0132" + "$.google.protobuf.EnumDescriptorProto\022H\n" + "\017extension_range\030\005 \003(\0132/.google.protobuf" + ".DescriptorProto.ExtensionRange\0229\n\noneof" + "_decl\030\010 \003(\0132%.google.protobuf.OneofDescr" + "iptorProto\0220\n\007options\030\007 \001(\0132\037.google.pro" + "tobuf.MessageOptions\022F\n\016reserved_range\030\t" + " \003(\0132..google.protobuf.DescriptorProto.R" + "eservedRange\022\025\n\rreserved_name\030\n \003(\t\032e\n\016E" + "xtensionRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(" + "\005\0227\n\007options\030\003 \001(\0132&.google.protobuf.Ext" + "ensionRangeOptions\032+\n\rReservedRange\022\r\n\005s" + "tart\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"g\n\025ExtensionRang" + "eOptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132" + "$.google.protobuf.UninterpretedOption*\t\010" + "\350\007\020\200\200\200\200\002\"\325\005\n\024FieldDescriptorProto\022\014\n\004nam" + "e\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+" + ".google.protobuf.FieldDescriptorProto.La" + "bel\0228\n\004type\030\005 \001(\0162*.google.protobuf.Fiel" + "dDescriptorProto.Type\022\021\n\ttype_name\030\006 \001(\t" + "\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_value\030\007 \001(" + "\t\022\023\n\013oneof_index\030\t \001(\005\022\021\n\tjson_name\030\n \001(" + "\t\022.\n\007options\030\010 \001(\0132\035.google.protobuf.Fie" + "ldOptions\022\027\n\017proto3_optional\030\021 \001(\010\"\266\002\n\004T" + "ype\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\n" + "TYPE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_IN" + "T32\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020" + "\007\022\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYP" + "E_GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTE" + "S\020\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rT" + "YPE_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYP" + "E_SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016" + "LABEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016" + "LABEL_REPEATED\020\003\"T\n\024OneofDescriptorProto" + "\022\014\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google" + ".protobuf.OneofOptions\"\244\002\n\023EnumDescripto" + "rProto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).go" + "ogle.protobuf.EnumValueDescriptorProto\022-" + "\n\007options\030\003 \001(\0132\034.google.protobuf.EnumOp" + "tions\022N\n\016reserved_range\030\004 \003(\01326.google.p" + "rotobuf.EnumDescriptorProto.EnumReserved" + "Range\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumRese" + "rvedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n" + "\030EnumValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022" + "\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.googl" + "e.protobuf.EnumValueOptions\"\220\001\n\026ServiceD" + "escriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002" + " \003(\0132&.google.protobuf.MethodDescriptorP" + "roto\0220\n\007options\030\003 \001(\0132\037.google.protobuf." + "ServiceOptions\"\301\001\n\025MethodDescriptorProto" + "\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013ou" + "tput_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.googl" + "e.protobuf.MethodOptions\022\037\n\020client_strea" + "ming\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 " + "\001(\010:\005false\"\245\006\n\013FileOptions\022\024\n\014java_packa" + "ge\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"" + "\n\023java_multiple_files\030\n \001(\010:\005false\022)\n\035ja" + "va_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n" + "\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n\014" + "optimize_for\030\t \001(\0162).google.protobuf.Fil" + "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa" + "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f" + "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal" + "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#" + "\n\024php_generic_services\030* \001(\010:\005false\022\031\n\nd" + "eprecated\030\027 \001(\010:\005false\022\036\n\020cc_enable_aren" + "as\030\037 \001(\010:\004true\022\031\n\021objc_class_prefix\030$ \001(" + "\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pre" + "fix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rp" + "hp_namespace\030) \001(\t\022\036\n\026php_metadata_names" + "pace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" + "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" + "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\204\002\n\016MessageOptions\022&\n" + "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" + "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" + "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" + "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" + "(\0132$.google.protobuf.UninterpretedOption" + "*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020" + "\n\"\276\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" + "le.protobuf.FieldOptions.CType:\006STRING\022\016" + "\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google." + "protobuf.FieldOptions.JSType:\tJS_NORMAL\022" + "\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unverified_lazy\030" + "\017 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" + "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" + "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" + "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" + "\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMA" + "L\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200" + "\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpre" + "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" + "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptio" + "ns\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 " + "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\n" + "deprecated\030\001 \001(\010:\005false\022C\n\024uninterpreted" + "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" + "pretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOption" + "s\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterp" + "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" + "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodO" + "ptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021ide" + "mpotency_level\030\" \001(\0162/.google.protobuf.M" + "ethodOptions.IdempotencyLevel:\023IDEMPOTEN" + "CY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption\"" + "P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKNO" + "WN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020" + "\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004" + "name\030\002 \003(\0132-.google.protobuf.Uninterpret" + "edOption.NamePart\022\030\n\020identifier_value\030\003 " + "\001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negat" + "ive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(" + "\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_val" + "ue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022" + "\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo" + "\022:\n\010location\030\001 \003(\0132(.google.protobuf.Sou" + "rceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pat" + "h\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading" + "_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001" + "(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\234\002" + "\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132" + "-.google.protobuf.GeneratedCodeInfo.Anno" + "tation\032\303\001\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" + "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" + "nd\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626.google.prot" + "obuf.GeneratedCodeInfo.Annotation.Semant" + "ic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALI" + "AS\020\002B~\n\023com.google.protobufB\020DescriptorP" + "rotosH\001Z-google.golang.org/protobuf/type" + "s/descriptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobu" + "f.Reflection" }; - -const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n google/protobuf/descriptor.proto\022\017goog" - "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" - "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" - "roto\"\354\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" - "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" - "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" - "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." - "ServiceDescriptorProto\0228\n\textension\030\007 \003(" - "\0132%.google.protobuf.FieldDescriptorProto" - "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" - "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" - "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" - "(\t\022\017\n\007edition\030\r \001(\t\"\251\005\n\017DescriptorProto\022" - "\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.google.pr" - "otobuf.FieldDescriptorProto\0228\n\textension" - "\030\006 \003(\0132%.google.protobuf.FieldDescriptor" - "Proto\0225\n\013nested_type\030\003 \003(\0132 .google.prot" - "obuf.DescriptorProto\0227\n\tenum_type\030\004 \003(\0132" - "$.google.protobuf.EnumDescriptorProto\022H\n" - "\017extension_range\030\005 \003(\0132/.google.protobuf" - ".DescriptorProto.ExtensionRange\0229\n\noneof" - "_decl\030\010 \003(\0132%.google.protobuf.OneofDescr" - "iptorProto\0220\n\007options\030\007 \001(\0132\037.google.pro" - "tobuf.MessageOptions\022F\n\016reserved_range\030\t" - " \003(\0132..google.protobuf.DescriptorProto.R" - "eservedRange\022\025\n\rreserved_name\030\n \003(\t\032e\n\016E" - "xtensionRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(" - "\005\0227\n\007options\030\003 \001(\0132&.google.protobuf.Ext" - "ensionRangeOptions\032+\n\rReservedRange\022\r\n\005s" - "tart\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"g\n\025ExtensionRang" - "eOptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132" - "$.google.protobuf.UninterpretedOption*\t\010" - "\350\007\020\200\200\200\200\002\"\325\005\n\024FieldDescriptorProto\022\014\n\004nam" - "e\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+" - ".google.protobuf.FieldDescriptorProto.La" - "bel\0228\n\004type\030\005 \001(\0162*.google.protobuf.Fiel" - "dDescriptorProto.Type\022\021\n\ttype_name\030\006 \001(\t" - "\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_value\030\007 \001(" - "\t\022\023\n\013oneof_index\030\t \001(\005\022\021\n\tjson_name\030\n \001(" - "\t\022.\n\007options\030\010 \001(\0132\035.google.protobuf.Fie" - "ldOptions\022\027\n\017proto3_optional\030\021 \001(\010\"\266\002\n\004T" - "ype\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\n" - "TYPE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_IN" - "T32\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020" - "\007\022\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYP" - "E_GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTE" - "S\020\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rT" - "YPE_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYP" - "E_SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016" - "LABEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016" - "LABEL_REPEATED\020\003\"T\n\024OneofDescriptorProto" - "\022\014\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google" - ".protobuf.OneofOptions\"\244\002\n\023EnumDescripto" - "rProto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).go" - "ogle.protobuf.EnumValueDescriptorProto\022-" - "\n\007options\030\003 \001(\0132\034.google.protobuf.EnumOp" - "tions\022N\n\016reserved_range\030\004 \003(\01326.google.p" - "rotobuf.EnumDescriptorProto.EnumReserved" - "Range\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumRese" - "rvedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n" - "\030EnumValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022" - "\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.googl" - "e.protobuf.EnumValueOptions\"\220\001\n\026ServiceD" - "escriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002" - " \003(\0132&.google.protobuf.MethodDescriptorP" - "roto\0220\n\007options\030\003 \001(\0132\037.google.protobuf." - "ServiceOptions\"\301\001\n\025MethodDescriptorProto" - "\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013ou" - "tput_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.googl" - "e.protobuf.MethodOptions\022\037\n\020client_strea" - "ming\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 " - "\001(\010:\005false\"\245\006\n\013FileOptions\022\024\n\014java_packa" - "ge\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"" - "\n\023java_multiple_files\030\n \001(\010:\005false\022)\n\035ja" - "va_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n" - "\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n\014" - "optimize_for\030\t \001(\0162).google.protobuf.Fil" - "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa" - "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f" - "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal" - "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#" - "\n\024php_generic_services\030* \001(\010:\005false\022\031\n\nd" - "eprecated\030\027 \001(\010:\005false\022\036\n\020cc_enable_aren" - "as\030\037 \001(\010:\004true\022\031\n\021objc_class_prefix\030$ \001(" - "\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pre" - "fix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rp" - "hp_namespace\030) \001(\t\022\036\n\026php_metadata_names" - "pace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unin" - "terpreted_option\030\347\007 \003(\0132$.google.protobu" - "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" - "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" - "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\204\002\n\016MessageOptions\022&\n" - "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" - "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" - "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" - "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020" - "\n\"\276\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" - "le.protobuf.FieldOptions.CType:\006STRING\022\016" - "\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google." - "protobuf.FieldOptions.JSType:\tJS_NORMAL\022" - "\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unverified_lazy\030" - "\017 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" - "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" - "\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMA" - "L\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200" - "\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptio" - "ns\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 " - "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\n" - "deprecated\030\001 \001(\010:\005false\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOption" - "s\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodO" - "ptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021ide" - "mpotency_level\030\" \001(\0162/.google.protobuf.M" - "ethodOptions.IdempotencyLevel:\023IDEMPOTEN" - "CY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption\"" - "P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKNO" - "WN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020" - "\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004" - "name\030\002 \003(\0132-.google.protobuf.Uninterpret" - "edOption.NamePart\022\030\n\020identifier_value\030\003 " - "\001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negat" - "ive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(" - "\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_val" - "ue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022" - "\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo" - "\022:\n\010location\030\001 \003(\0132(.google.protobuf.Sou" - "rceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pat" - "h\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading" - "_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001" - "(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\234\002" - "\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132" - "-.google.protobuf.GeneratedCodeInfo.Anno" - "tation\032\303\001\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" - "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" - "nd\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626.google.prot" - "obuf.GeneratedCodeInfo.Annotation.Semant" - "ic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALI" - "AS\020\002B~\n\023com.google.protobufB\020DescriptorP" - "rotosH\001Z-google.golang.org/protobuf/type" - "s/descriptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobu" - "f.Reflection" - ; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - false, false, 6212, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, + false, + false, + 6212, + descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + nullptr, + 0, + 27, + schemas, + file_default_instances, + TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, + file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; + +// This function exists to be marked as weak. +// It can significantly speed up compilation by breaking up LLVM's SCC +// in the .pb.cc translation units. Large translation units see a +// reduction of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; } - // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); PROTOBUF_NAMESPACE_OPEN const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); @@ -1406,7 +1454,6 @@ constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::Se constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::Semantic_MAX; constexpr int GeneratedCodeInfo_Annotation::Semantic_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) - // =================================================================== class FileDescriptorSet::_Internal { @@ -1593,7 +1640,6 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]); } - // =================================================================== class FileDescriptorProto::_Internal { @@ -2349,7 +2395,6 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]); } - // =================================================================== class DescriptorProto_ExtensionRange::_Internal { @@ -2635,7 +2680,6 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]); } - // =================================================================== class DescriptorProto_ReservedRange::_Internal { @@ -2874,7 +2918,6 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]); } - // =================================================================== class DescriptorProto::_Internal { @@ -3442,7 +3485,6 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]); } - // =================================================================== class ExtensionRangeOptions::_Internal { @@ -3651,7 +3693,6 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]); } - // =================================================================== class FieldDescriptorProto::_Internal { @@ -4334,7 +4375,6 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]); } - // =================================================================== class OneofDescriptorProto::_Internal { @@ -4611,7 +4651,6 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]); } - // =================================================================== class EnumDescriptorProto_EnumReservedRange::_Internal { @@ -4850,7 +4889,6 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]); } - // =================================================================== class EnumDescriptorProto::_Internal { @@ -5238,7 +5276,6 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]); } - // =================================================================== class EnumValueDescriptorProto::_Internal { @@ -5551,7 +5588,6 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]); } - // =================================================================== class ServiceDescriptorProto::_Internal { @@ -5864,7 +5900,6 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]); } - // =================================================================== class MethodDescriptorProto::_Internal { @@ -6323,7 +6358,6 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]); } - // =================================================================== class FileOptions::_Internal { @@ -7444,7 +7478,6 @@ void FileOptions::InternalSwap(FileOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]); } - // =================================================================== class MessageOptions::_Internal { @@ -7794,7 +7827,6 @@ void MessageOptions::InternalSwap(MessageOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]); } - // =================================================================== class FieldOptions::_Internal { @@ -8243,7 +8275,6 @@ void FieldOptions::InternalSwap(FieldOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]); } - // =================================================================== class OneofOptions::_Internal { @@ -8452,7 +8483,6 @@ void OneofOptions::InternalSwap(OneofOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]); } - // =================================================================== class EnumOptions::_Internal { @@ -8746,7 +8776,6 @@ void EnumOptions::InternalSwap(EnumOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]); } - // =================================================================== class EnumValueOptions::_Internal { @@ -8997,7 +9026,6 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]); } - // =================================================================== class ServiceOptions::_Internal { @@ -9248,7 +9276,6 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]); } - // =================================================================== class MethodOptions::_Internal { @@ -9551,7 +9578,6 @@ void MethodOptions::InternalSwap(MethodOptions* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]); } - // =================================================================== class UninterpretedOption_NamePart::_Internal { @@ -9829,7 +9855,6 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]); } - // =================================================================== class UninterpretedOption::_Internal { @@ -10300,7 +10325,6 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]); } - // =================================================================== class SourceCodeInfo_Location::_Internal { @@ -10709,7 +10733,6 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]); } - // =================================================================== class SourceCodeInfo::_Internal { @@ -10894,7 +10917,6 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]); } - // =================================================================== class GeneratedCodeInfo_Annotation::_Internal { @@ -11267,7 +11289,6 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]); } - // =================================================================== class GeneratedCodeInfo::_Internal { @@ -11452,7 +11473,6 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) { &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -11565,6 +11585,5 @@ Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(Arena* a return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(arena); } PROTOBUF_NAMESPACE_CLOSE - // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index a75a31c36e..9a5db1db2a 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -6,19 +6,20 @@ #include #include +#include #include "google/protobuf/port_def.inc" #if PROTOBUF_VERSION < 3021000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif +#error "This file was generated by a newer version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please update" +#error "your headers." +#endif // PROTOBUF_VERSION +#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION #include "google/protobuf/port_undef.inc" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/arena.h" @@ -32,8 +33,12 @@ #include "google/protobuf/generated_enum_reflection.h" #include "google/protobuf/unknown_field_set.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" + #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto PROTOBUF_EXPORT + PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; @@ -44,7 +49,8 @@ PROTOBUF_NAMESPACE_CLOSE struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto { static const uint32_t offsets[]; }; -PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; +PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; PROTOBUF_NAMESPACE_OPEN class DescriptorProto; struct DescriptorProtoDefaultTypeInternal; @@ -127,38 +133,63 @@ PROTOBUF_EXPORT extern UninterpretedOptionDefaultTypeInternal _UninterpretedOpti class UninterpretedOption_NamePart; struct UninterpretedOption_NamePartDefaultTypeInternal; PROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*); PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*); -PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN +PROTOBUF_NAMESPACE_OPEN enum FieldDescriptorProto_Type : int { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, FieldDescriptorProto_Type_TYPE_FLOAT = 2, @@ -370,8 +401,12 @@ inline bool GeneratedCodeInfo_Annotation_Semantic_Parse( return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( GeneratedCodeInfo_Annotation_Semantic_descriptor(), name, value); } + // =================================================================== + +// ------------------------------------------------------------------- + class PROTOBUF_EXPORT FileDescriptorSet final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { public: @@ -533,8 +568,7 @@ class PROTOBUF_EXPORT FileDescriptorSet final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FileDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { @@ -952,8 +986,7 @@ class PROTOBUF_EXPORT FileDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { @@ -1147,8 +1180,7 @@ class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { @@ -1322,8 +1354,7 @@ class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { @@ -1676,8 +1707,7 @@ class PROTOBUF_EXPORT DescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { @@ -2032,8 +2062,7 @@ class PROTOBUF_EXPORT ExtensionRangeOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FieldDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { @@ -2466,8 +2495,7 @@ class PROTOBUF_EXPORT FieldDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT OneofDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { @@ -2651,8 +2679,7 @@ class PROTOBUF_EXPORT OneofDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { @@ -2826,8 +2853,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { @@ -3079,8 +3105,7 @@ class PROTOBUF_EXPORT EnumDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { @@ -3279,8 +3304,7 @@ class PROTOBUF_EXPORT EnumValueDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { @@ -3484,8 +3508,7 @@ class PROTOBUF_EXPORT ServiceDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MethodDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { @@ -3739,8 +3762,7 @@ class PROTOBUF_EXPORT MethodDescriptorProto final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FileOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { @@ -4478,8 +4500,7 @@ class PROTOBUF_EXPORT FileOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MessageOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { @@ -4895,8 +4916,7 @@ class PROTOBUF_EXPORT MessageOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FieldOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { @@ -5421,8 +5441,7 @@ class PROTOBUF_EXPORT FieldOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT OneofOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { @@ -5777,8 +5796,7 @@ class PROTOBUF_EXPORT OneofOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { @@ -6164,8 +6182,7 @@ class PROTOBUF_EXPORT EnumOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumValueOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { @@ -6536,8 +6553,7 @@ class PROTOBUF_EXPORT EnumValueOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ServiceOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { @@ -6908,8 +6924,7 @@ class PROTOBUF_EXPORT ServiceOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MethodOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { @@ -7327,8 +7342,7 @@ class PROTOBUF_EXPORT MethodOptions final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { @@ -7510,8 +7524,7 @@ class PROTOBUF_EXPORT UninterpretedOption_NamePart final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT UninterpretedOption final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { @@ -7782,8 +7795,7 @@ class PROTOBUF_EXPORT UninterpretedOption final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { @@ -8043,8 +8055,7 @@ class PROTOBUF_EXPORT SourceCodeInfo_Location final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT SourceCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { @@ -8209,8 +8220,7 @@ class PROTOBUF_EXPORT SourceCodeInfo final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { @@ -8476,8 +8486,7 @@ class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { @@ -8646,12 +8655,17 @@ class PROTOBUF_EXPORT GeneratedCodeInfo final : // =================================================================== + + // =================================================================== + #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ +// ------------------------------------------------------------------- + // FileDescriptorSet // repeated .google.protobuf.FileDescriptorProto file = 1; @@ -14861,65 +14875,13 @@ GeneratedCodeInfo::annotation() const { } #ifdef __GNUC__ - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) - PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type> : ::std::true_type {}; @@ -14963,4 +14925,5 @@ PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh + +#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh diff --git a/src/google/protobuf/descriptor.proto b/src/google/protobuf/descriptor.proto index 2e19d33262..f264b13abd 100644 --- a/src/google/protobuf/descriptor.proto +++ b/src/google/protobuf/descriptor.proto @@ -502,6 +502,10 @@ message MessageOptions { reserved 4, 5, 6; + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + // // Whether the message is an automatically generated map entry type for the // maps field. // @@ -519,10 +523,6 @@ message MessageOptions { // use a native map in the target language to hold the keys and values. // The reflection APIs in such implementations still need to work as // if the field is a repeated message field. - // - // NOTE: Do not set the option in .proto files. Always use the maps syntax - // instead. The option should only be implicitly set by the proto compiler - // parser. optional bool map_entry = 7; reserved 8; // javalite_serializable diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 440bf9a97f..c024a7778c 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc @@ -39,7 +39,7 @@ #include #include "absl/strings/ascii.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/stubs/stl_util.h" @@ -190,7 +190,7 @@ typename Container::const_iterator FindLastLessOrEqual( // "foo.bar.baz", but not a parent of "foo.barbaz"). bool IsSubSymbol(absl::string_view sub_symbol, absl::string_view super_symbol) { return sub_symbol == super_symbol || - (HasPrefixString(super_symbol, sub_symbol) && + (absl::StartsWith(super_symbol, sub_symbol) && super_symbol[sub_symbol.size()] == '.'); } diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index a2900454f6..46597205d0 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc @@ -43,6 +43,7 @@ #include "google/protobuf/compiler/parser.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_custom_options.pb.h" +#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/stringprintf.h" @@ -553,6 +554,27 @@ TEST_F(FileDescriptorTest, Syntax) { } } +TEST_F(FileDescriptorTest, CopyHeadingTo) { + FileDescriptorProto proto; + proto.set_name("foo.proto"); + proto.set_package("foo.bar.baz"); + proto.set_syntax("proto3"); + + // Won't be copied. + proto.add_message_type()->set_name("Foo"); + + DescriptorPool pool; + const FileDescriptor* file = pool.BuildFile(proto); + ASSERT_NE(file, nullptr); + + FileDescriptorProto other; + file->CopyHeadingTo(&other); + EXPECT_EQ(other.name(), "foo.proto"); + EXPECT_EQ(other.package(), "foo.bar.baz"); + EXPECT_EQ(other.syntax(), "proto3"); + EXPECT_TRUE(other.message_type().empty()); +} + void ExtractDebugString( const FileDescriptor* file, std::set* visited, std::vector>* debug_strings) { @@ -1063,6 +1085,34 @@ TEST_F(DescriptorTest, FieldLabel) { EXPECT_TRUE(baz_->is_repeated()); } +TEST_F(DescriptorTest, NeedsUtf8Check) { + EXPECT_FALSE(foo_->requires_utf8_validation()); + EXPECT_FALSE(bar_->requires_utf8_validation()); + + // Build a copy of the file in proto3. + FileDescriptorProto foo_file3; + foo_file_->CopyTo(&foo_file3); + foo_file3.set_syntax("proto3"); + + // Make this valid proto3 by removing `required` and the one group field. + for (auto& f : *foo_file3.mutable_message_type(1)->mutable_field()) { + f.clear_label(); + if (f.type() == FieldDescriptorProto::TYPE_GROUP) { + f.set_type(FieldDescriptorProto::TYPE_MESSAGE); + } + } + // Make this valid proto3 by making the first enum value be zero. + foo_file3.mutable_enum_type(0)->mutable_value(0)->set_number(0); + + DescriptorPool pool3; + const Descriptor* message3 = pool3.BuildFile(foo_file3)->message_type(1); + const FieldDescriptor* foo3 = message3->field(0); + const FieldDescriptor* bar3 = message3->field(1); + + EXPECT_TRUE(foo3->requires_utf8_validation()); + EXPECT_FALSE(bar3->requires_utf8_validation()); +} + TEST_F(DescriptorTest, IsMap) { EXPECT_TRUE(map_->is_map()); EXPECT_FALSE(baz_->is_map()); @@ -1535,6 +1585,23 @@ TEST_F(EnumDescriptorTest, ValueType) { EXPECT_EQ(enum2_, baz2_->type()); } +TEST_F(EnumDescriptorTest, IsClosed) { + // enum_ is proto2. + EXPECT_TRUE(enum_->is_closed()); + + // Make a proto3 version of enum_. + FileDescriptorProto foo_file3; + foo_file_->CopyTo(&foo_file3); + foo_file3.set_syntax("proto3"); + + // Make this valid proto3 by making the first enum value be zero. + foo_file3.mutable_enum_type(0)->mutable_value(0)->set_number(0); + + DescriptorPool pool3; + const EnumDescriptor* enum3 = pool3.BuildFile(foo_file3)->enum_type(0); + EXPECT_FALSE(enum3->is_closed()); +} + // =================================================================== // Test service descriptors. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index a1e62ccdd5..4fe1e620de 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 8e65cb6b39..bc6bbc695b 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 8b436bc20c..2db28c3f24 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc @@ -49,6 +49,7 @@ #include "google/protobuf/testing/googletest.h" #include #include "absl/base/casts.h" +#include "absl/strings/match.h" #include "google/protobuf/test_util.h" #include "google/protobuf/test_util2.h" #include "google/protobuf/stubs/stl_util.h" @@ -855,8 +856,10 @@ TEST(ExtensionSetTest, SpaceUsedExcludingSelf) { const size_t old_capacity = \ message->GetRepeatedExtension(unittest::repeated_##type##_extension) \ .Capacity(); \ - EXPECT_GE(old_capacity, \ - (RepeatedFieldLowerClampLimit())); \ + EXPECT_GE( \ + old_capacity, \ + (RepeatedFieldLowerClampLimit())); \ for (int i = 0; i < 16; ++i) { \ message->AddExtension(unittest::repeated_##type##_extension, value); \ } \ @@ -1232,7 +1235,7 @@ TEST(ExtensionSetTest, DynamicExtensions) { std::string prefix = "." + template_descriptor->full_name() + "."; if (extension->has_type_name()) { std::string* type_name = extension->mutable_type_name(); - if (HasPrefixString(*type_name, prefix)) { + if (absl::StartsWith(*type_name, prefix)) { type_name->replace(0, prefix.size(), ".dynamic_extensions."); } } diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 7d003df4bd..3d9c467fcf 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/io/coded_stream_unittest.cc b/src/google/protobuf/io/coded_stream_unittest.cc index 6f12482900..1fca15c49c 100644 --- a/src/google/protobuf/io/coded_stream_unittest.cc +++ b/src/google/protobuf/io/coded_stream_unittest.cc @@ -136,7 +136,7 @@ class CodedStreamTest : public testing::Test { static uint8_t buffer_[kBufferSize]; }; -uint8_t CodedStreamTest::buffer_[CodedStreamTest::kBufferSize]; +uint8_t CodedStreamTest::buffer_[CodedStreamTest::kBufferSize] = {}; // We test each operation over a variety of block sizes to insure that // we test cases where reads or writes cross buffer boundaries, cases @@ -727,7 +727,7 @@ TEST_1D(CodedStreamTest, ReadStringImpossiblyLarge, kBlockSizes) { TEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnStack) { // Same test as above, except directly use a buffer. This used to cause // crashes while the above did not. - uint8_t buffer[8]; + uint8_t buffer[8] = {}; CodedInputStream coded_input(buffer, 8); std::string str; EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30)); @@ -1318,7 +1318,7 @@ class ReallyBigInputStream : public ZeroCopyInputStream { int backup_amount_; private: - char buffer_[1024]; + char buffer_[1024] = {}; int64_t buffer_count_; }; diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h index c7ef1327a2..eec111cacb 100644 --- a/src/google/protobuf/io/gzip_stream.h +++ b/src/google/protobuf/io/gzip_stream.h @@ -76,7 +76,7 @@ class PROTOBUF_EXPORT GzipInputStream PROTOBUF_FUTURE_FINAL Format format = AUTO, int buffer_size = -1); GzipInputStream(const GzipInputStream&) = delete; GzipInputStream& operator=(const GzipInputStream&) = delete; - virtual ~GzipInputStream(); + ~GzipInputStream() override; // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; } @@ -144,7 +144,7 @@ class PROTOBUF_EXPORT GzipOutputStream PROTOBUF_FUTURE_FINAL GzipOutputStream(const GzipOutputStream&) = delete; GzipOutputStream& operator=(const GzipOutputStream&) = delete; - virtual ~GzipOutputStream(); + ~GzipOutputStream() override; // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; } diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index b2e16372e7..99dc5bd778 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc @@ -48,7 +48,7 @@ #include "google/protobuf/stubs/common.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/string_view.h" @@ -129,6 +129,16 @@ Printer::Printer(ZeroCopyOutputStream* output, Options options) } } +absl::string_view Printer::LookupVar(absl::string_view var) { + LookupResult result = LookupInFrameStack(var, absl::MakeSpan(var_lookups_)); + GOOGLE_CHECK(result.has_value()) << "could not find " << var; + auto* view = absl::get_if(&*result); + GOOGLE_CHECK(view != nullptr) << "could not find " << var + << "; found callback instead"; + + return *view; +} + bool Printer::Validate(bool cond, Printer::PrintOptions opts, absl::FunctionRef message) { if (!cond) { @@ -326,8 +336,8 @@ bool Printer::ValidateIndexLookupInBounds(size_t index, void Printer::PrintImpl(absl::string_view format, absl::Span args, PrintOptions opts) { - // Inside of this function, we set intentation as we print new lines from the - // format string. No matter how we exit this functon, we should fix up the + // Inside of this function, we set indentation as we print new lines from the + // format string. No matter how we exit this function, we should fix up the // indent to what it was before we entered; a cleanup makes it easy to avoid // this mistake. size_t original_indent = indent_; @@ -614,10 +624,12 @@ void Printer::PrintImpl(absl::string_view format, // // }; // - // in many cases. We *also* do this if a ; follows the substitution, + // in many cases. We *also* do this if a ; or , follows the substitution, // because this helps clang-format keep its head on in many cases. // Users that need to keep the semi can write $foo$/**/; - absl::ConsumePrefix(&format, ";"); + if (!absl::ConsumePrefix(&format, ";")) { + absl::ConsumePrefix(&format, ","); + } absl::ConsumePrefix(&format, "\n"); indent_ = original_indent + ConsumeIndentForLine(raw_string_indent_len, format); diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index 844eed2a83..176f484f8e 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h @@ -220,7 +220,7 @@ class AnnotationProtoCollector : public AnnotationCollector { // pointer (which will cause the Printer to store a pointer, potentially // avoiding a copy.) // -// p.Emit(vars, "..."); is effecitvely syntax sugar for +// p.Emit(vars, "..."); is effectively syntax sugar for // // { auto v = p.WithVars(vars); p.Emit("..."); } // @@ -230,7 +230,7 @@ class AnnotationProtoCollector : public AnnotationCollector { // # Annotations // // If Printer is given an AnnotationCollector, it will use it to record which -// spans of genreated code correspond to user-indicated descriptors. There are +// spans of generated code correspond to user-indicated descriptors. There are // a few different ways of indicating when to emit annotations. // // The WithAnnotations() function is like WithVars(), but accepts maps with @@ -414,6 +414,13 @@ class PROTOBUF_EXPORT Printer { // Options for controlling how the output of a Printer is formatted. struct Options { + Options() = default; + Options(const Options&) = default; + Options(Options&&) = default; + Options(char variable_delimiter, AnnotationCollector* annotation_collector) + : variable_delimiter(variable_delimiter), + annotation_collector(annotation_collector) {} + // The delimiter for variable substitutions, e.g. $foo$. char variable_delimiter = kDefaultVariableDelimiter; // An optional listener the Printer calls whenever it emits a source @@ -428,11 +435,11 @@ class PROTOBUF_EXPORT Printer { size_t spaces_per_indent = 2; // Whether to emit a "codegen trace" for calls to Emit(). If true, each call // to Emit() will print a comment indicating where in the source of the - // compiler the Emit() call occured. + // compiler the Emit() call occurred. // // If disengaged, defaults to whether or not the environment variable // `PROTOC_CODEGEN_TRACE` is set. - absl::optional enable_codegen_trace; + absl::optional enable_codegen_trace = absl::nullopt; }; // Constructs a new Printer with the default options to output to @@ -488,6 +495,13 @@ class PROTOBUF_EXPORT Printer { return absl::MakeCleanup([this] { var_lookups_.pop_back(); }); } + // Looks up a variable set with WithVars(). + // + // Will crash if: + // - `var` is not present in the lookup frame table. + // - `var` is a callback, rather than a string. + absl::string_view LookupVar(absl::string_view var); + // Pushes a new annotation lookup frame that stores `vars` by reference. // // Returns an RAII object that pops the lookup frame. @@ -689,7 +703,7 @@ class PROTOBUF_EXPORT Printer { // If set, leading whitespace will be stripped from the format string to // determine the "extraneous indentation" that is produced when the format // string is a C++ raw string. This is used to remove leading spaces from - // a raw string that would otherwise result in eratic indentation in the + // a raw string that would otherwise result in erratic indentation in the // output. bool strip_raw_string_indentation = false; // If set, the annotation lookup frames are searched, per the annotation diff --git a/src/google/protobuf/io/zero_copy_stream_unittest.cc b/src/google/protobuf/io/zero_copy_stream_unittest.cc index 81a5e0589c..d82354e571 100644 --- a/src/google/protobuf/io/zero_copy_stream_unittest.cc +++ b/src/google/protobuf/io/zero_copy_stream_unittest.cc @@ -1053,7 +1053,7 @@ TEST_F(IoTest, LimitingInputStream) { TEST_F(IoTest, LimitingInputStreamByteCount) { const int kHalfBufferSize = 128; const int kBufferSize = kHalfBufferSize * 2; - uint8 buffer[kBufferSize]; + uint8 buffer[kBufferSize] = {}; // Set up input. Only allow half to be read at once. ArrayInputStream array_input(buffer, kBufferSize, kHalfBufferSize); diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index 529e7bdc9d..3b615b7c5c 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc @@ -39,7 +39,7 @@ #include "google/protobuf/map_lite_unittest.pb.h" #include "google/protobuf/unittest_lite.pb.h" #include -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "google/protobuf/arena_test_util.h" #include "google/protobuf/io/coded_stream.h" @@ -1144,8 +1144,8 @@ TEST(Lite, CorrectEnding) { TEST(Lite, DebugString) { protobuf_unittest::TestAllTypesLite message1, message2; - EXPECT_TRUE(HasPrefixString(message1.DebugString(), "MessageLite at 0x")); - EXPECT_TRUE(HasPrefixString(message2.DebugString(), "MessageLite at 0x")); + EXPECT_TRUE(absl::StartsWith(message1.DebugString(), "MessageLite at 0x")); + EXPECT_TRUE(absl::StartsWith(message2.DebugString(), "MessageLite at 0x")); // DebugString() and ShortDebugString() are the same for now. EXPECT_EQ(message1.DebugString(), message1.ShortDebugString()); diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 7cae7beb55..defc8158b9 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc @@ -63,6 +63,10 @@ namespace google { namespace protobuf { +MessageLite::~MessageLite(){ +// Defined out of line to save code space +} + std::string MessageLite::InitializationErrorString() const { return "(cannot determine missing fields for lite message)"; } diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index f4bca9cb27..92e5b73845 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -171,7 +171,7 @@ class PROTOBUF_EXPORT MessageLite { constexpr MessageLite() {} MessageLite(const MessageLite&) = delete; MessageLite& operator=(const MessageLite&) = delete; - virtual ~MessageLite() = default; + virtual ~MessageLite(); // Basic Operations ------------------------------------------------ diff --git a/src/google/protobuf/parse_context.cc b/src/google/protobuf/parse_context.cc index 29f53e278b..34063195c8 100644 --- a/src/google/protobuf/parse_context.cc +++ b/src/google/protobuf/parse_context.cc @@ -30,10 +30,6 @@ #include "google/protobuf/parse_context.h" -#ifdef __aarch64__ -#include -#endif - #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream.h" #include "google/protobuf/arenastring.h" @@ -581,7 +577,7 @@ const char* UnknownFieldParse(uint32_t tag, std::string* unknown, // // 2) Calculate the index of the cleared continuation bit in order to determine // where the encoded Varint ends and the size of the decoded value. The -// easist way to do this is mask off all data bits, leaving just the +// easiest way to do this is mask off all data bits, leaving just the // continuation bits. We actually need to do the masking on an inverted // copy of the data, which leaves a 1 in all continuation bits which were // originally clear. The number of trailing zeroes in this value indicates diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 3dbdf3e4ae..12d51f5034 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -337,7 +337,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { template const char* AppendSize(const char* ptr, int size, const A& append) { - int chunk_size = buffer_end_ + kSlopBytes - ptr; + int chunk_size = static_cast(buffer_end_ + kSlopBytes - ptr); do { GOOGLE_DCHECK(size > chunk_size); if (next_chunk_ == nullptr) return nullptr; @@ -351,7 +351,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { ptr = Next(); if (ptr == nullptr) return nullptr; // passed the limit ptr += kSlopBytes; - chunk_size = buffer_end_ + kSlopBytes - ptr; + chunk_size = static_cast(buffer_end_ + kSlopBytes - ptr); } while (size > chunk_size); append(ptr, size); return ptr + size; @@ -880,7 +880,7 @@ template const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, RepeatedField* out) { GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int nbytes = buffer_end_ + kSlopBytes - ptr; + int nbytes = static_cast(buffer_end_ + kSlopBytes - ptr); while (size > nbytes) { int num = nbytes / sizeof(T); int old_entries = out->size(); @@ -898,7 +898,7 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, ptr = Next(); if (ptr == nullptr) return nullptr; ptr += kSlopBytes - (nbytes - block_size); - nbytes = buffer_end_ + kSlopBytes - ptr; + nbytes = static_cast(buffer_end_ + kSlopBytes - ptr); } int num = size / sizeof(T); int old_entries = out->size(); @@ -930,11 +930,11 @@ template const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { int size = ReadSize(&ptr); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int chunk_size = buffer_end_ - ptr; + int chunk_size = static_cast(buffer_end_ - ptr); while (size > chunk_size) { ptr = ReadPackedVarintArray(ptr, buffer_end_, add); if (ptr == nullptr) return nullptr; - int overrun = ptr - buffer_end_; + int overrun = static_cast(ptr - buffer_end_); GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes); if (size - chunk_size <= kSlopBytes) { // The current buffer contains all the information needed, we don't need @@ -955,7 +955,7 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { ptr = Next(); if (ptr == nullptr) return nullptr; ptr += overrun; - chunk_size = buffer_end_ - ptr; + chunk_size = static_cast(buffer_end_ - ptr); } auto end = ptr + size; ptr = ReadPackedVarintArray(ptr, end, add); diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 175c6e99a2..0f55865406 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc @@ -38,7 +38,7 @@ #include "google/protobuf/arena.h" #include "google/protobuf/text_format.h" #include -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/test_util.h" // Must be included last. @@ -296,7 +296,7 @@ TEST(Proto3OptionalTest, OptionalFieldDescriptor) { for (int i = 0; i < d->field_count(); i++) { const FieldDescriptor* f = d->field(i); - if (HasPrefixString(f->name(), "singular")) { + if (absl::StartsWith(f->name(), "singular")) { EXPECT_FALSE(f->has_optional_keyword()) << f->full_name(); EXPECT_FALSE(f->has_presence()) << f->full_name(); EXPECT_FALSE(f->containing_oneof()) << f->full_name(); diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 0c8c71a48c..ee4e6b22d6 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 768265e203..e52be9476e 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index eb43fd2229..7c86204511 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc @@ -95,11 +95,14 @@ TEST(LoggingTest, DefaultLogging) { GOOGLE_LOG(ERROR ) << "An error."; std::string text = GetCapturedTestStderr(); - EXPECT_EQ( - "[libprotobuf INFO " __FILE__ ":" + SimpleItoa(line + 1) + "] A message.\n" - "[libprotobuf WARNING " __FILE__ ":" + SimpleItoa(line + 2) + "] A warning.\n" - "[libprotobuf ERROR " __FILE__ ":" + SimpleItoa(line + 3) + "] An error.\n", - text); + EXPECT_EQ(absl::StrCat("[libprotobuf INFO " __FILE__ ":", line + 1, + "] A message.\n" + "[libprotobuf WARNING " __FILE__ ":", + line + 2, + "] A warning.\n" + "[libprotobuf ERROR " __FILE__ ":", + line + 3, "] An error.\n"), + text); } TEST(LoggingTest, NullLogging) { @@ -128,12 +131,10 @@ TEST(LoggingTest, CaptureLogging) { EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "2 " __FILE__ ":" + SimpleItoa(start_line + 1) + ": An error.", - captured_messages_[0]); - EXPECT_EQ( - "1 " __FILE__ ":" + SimpleItoa(start_line + 2) + ": A warning.", - captured_messages_[1]); + EXPECT_EQ(absl::StrCat("2 " __FILE__ ":", start_line + 1, ": An error."), + captured_messages_[0]); + EXPECT_EQ(absl::StrCat("1 " __FILE__ ":", start_line + 2, ": A warning."), + captured_messages_[1]); } TEST(LoggingTest, SilenceLogging) { @@ -154,12 +155,10 @@ TEST(LoggingTest, SilenceLogging) { EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "0 " __FILE__ ":" + SimpleItoa(line1) + ": Visible1", - captured_messages_[0]); - EXPECT_EQ( - "0 " __FILE__ ":" + SimpleItoa(line2) + ": Visible2", - captured_messages_[1]); + EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line1, ": Visible1"), + captured_messages_[0]); + EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line2, ": Visible2"), + captured_messages_[1]); } class ClosureTest : public testing::Test { diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index b6d2049a34..720c6fcee3 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc @@ -63,75 +63,7 @@ namespace google { namespace protobuf { -// These are defined as macros on some platforms. #undef them so that we can -// redefine them. -#undef isxdigit -#undef isprint - -// The definitions of these in ctype.h change based on locale. Since our -// string manipulation is all in relation to the protocol buffer and C++ -// languages, we always want to use the C locale. So, we re-define these -// exactly as we want them. -inline bool isxdigit(char c) { - return ('0' <= c && c <= '9') || - ('a' <= c && c <= 'f') || - ('A' <= c && c <= 'F'); -} - -inline bool isprint(char c) { - return c >= 0x20 && c <= 0x7E; -} - -// ---------------------------------------------------------------------- -// ReplaceCharacters -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// ---------------------------------------------------------------------- -void ReplaceCharacters(std::string *s, const char *remove, char replacewith) { - const char *str_start = s->c_str(); - const char *str = str_start; - for (str = strpbrk(str, remove); - str != nullptr; - str = strpbrk(str + 1, remove)) { - (*s)[str - str_start] = replacewith; - } -} - -void StripWhitespace(std::string *str) { - int str_length = str->length(); - - // Strip off leading whitespace. - int first = 0; - while (first < str_length && absl::ascii_isspace(str->at(first))) { - ++first; - } - // If entire string is white space. - if (first == str_length) { - str->clear(); - return; - } - if (first > 0) { - str->erase(0, first); - str_length -= first; - } - - // Strip off trailing whitespace. - int last = str_length - 1; - while (last >= 0 && absl::ascii_isspace(str->at(last))) { - --last; - } - if (last != (str_length - 1) && last >= 0) { - str->erase(last + 1, std::string::npos); - } -} - -// ---------------------------------------------------------------------- -// StringReplace() -// Replace the "old" pattern with the "new" pattern in a string, -// and append the result to "res". If replace_all is false, -// it only replaces the first instance of "old." -// ---------------------------------------------------------------------- - +namespace { void StringReplace(const std::string &s, const std::string &oldsub, const std::string &newsub, bool replace_all, std::string *res) { @@ -153,6 +85,7 @@ void StringReplace(const std::string &s, const std::string &oldsub, } while (replace_all); res->append(s, start_pos, s.length() - start_pos); } +} // namespace // ---------------------------------------------------------------------- // StringReplace() @@ -170,91 +103,6 @@ std::string StringReplace(const std::string &s, const std::string &oldsub, return ret; } -// ---------------------------------------------------------------------- -// SplitStringUsing() -// Split a string using a character delimiter. Append the components -// to 'result'. -// -// Note: For multi-character delimiters, this routine will split on *ANY* of -// the characters in the string, not the entire string as a single delimiter. -// ---------------------------------------------------------------------- -template -static inline void SplitStringToIteratorUsing(absl::string_view full, - const char *delim, ITR &result) { - // Optimize the common case where delim is a single character. - if (delim[0] != '\0' && delim[1] == '\0') { - char c = delim[0]; - const char* p = full.data(); - const char* end = p + full.size(); - while (p != end) { - if (*p == c) { - ++p; - } else { - const char* start = p; - while (++p != end && *p != c); - *result++ = std::string(start, p - start); - } - } - return; - } - - std::string::size_type begin_index, end_index; - begin_index = full.find_first_not_of(delim); - while (begin_index != std::string::npos) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == std::string::npos) { - *result++ = std::string(full.substr(begin_index)); - return; - } - *result++ = - std::string(full.substr(begin_index, (end_index - begin_index))); - begin_index = full.find_first_not_of(delim, end_index); - } -} - -void SplitStringUsing(absl::string_view full, const char *delim, - std::vector *result) { - std::back_insert_iterator > it(*result); - SplitStringToIteratorUsing(full, delim, it); -} - -// Split a string using a character delimiter. Append the components -// to 'result'. If there are consecutive delimiters, this function -// will return corresponding empty strings. The string is split into -// at most the specified number of pieces greedily. This means that the -// last piece may possibly be split further. To split into as many pieces -// as possible, specify 0 as the number of pieces. -// -// If "full" is the empty string, yields an empty string as the only value. -// -// If "pieces" is negative for some reason, it returns the whole string -// ---------------------------------------------------------------------- -template -static inline void SplitStringToIteratorAllowEmpty(absl::string_view full, - const char *delim, - int pieces, ITR &result) { - std::string::size_type begin_index, end_index; - begin_index = 0; - - for (int i = 0; (i < pieces-1) || (pieces == 0); i++) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == std::string::npos) { - *result++ = std::string(full.substr(begin_index)); - return; - } - *result++ = - std::string(full.substr(begin_index, (end_index - begin_index))); - begin_index = end_index + 1; - } - *result++ = std::string(full.substr(begin_index)); -} - -void SplitStringAllowEmpty(absl::string_view full, const char *delim, - std::vector *result) { - std::back_insert_iterator > it(*result); - SplitStringToIteratorAllowEmpty(full, delim, 0, it); -} - // ---------------------------------------------------------------------- // strto32_adaptor() // strtou32_adaptor() @@ -423,378 +271,9 @@ bool safe_uint_internal(std::string text, IntType *value_p) { return safe_parse_positive_int(text, value_p); } -// ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastInt64ToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// ---------------------------------------------------------------------- - -// Offset into buffer where FastInt64ToBuffer places the end of string -// null character. Also used by FastInt64ToBufferLeft. -static const int kFastInt64ToBufferOffset = 21; - -char *FastInt64ToBuffer(int64_t i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 22 bytes is enough to store -2**64, -18446744073709551616. - char* p = buffer + kFastInt64ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -// Offset into buffer where FastInt32ToBuffer places the end of string -// null character. Also used by FastInt32ToBufferLeft -static const int kFastInt32ToBufferOffset = 11; - -// Yes, this is a duplicate of FastInt64ToBuffer. But, we need this for the -// compiler to generate 32 bit arithmetic instructions. It's much faster, at -// least with 32 bit binaries. -char *FastInt32ToBuffer(int32_t i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 12 bytes is enough to store -2**32, -4294967296. - char* p = buffer + kFastInt32ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -char *FastHexToBuffer(int i, char* buffer) { - GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i; - - static const char *hexdigits = "0123456789abcdef"; - char *p = buffer + 21; - *p-- = '\0'; - do { - *p-- = hexdigits[i & 15]; // mod by 16 - i >>= 4; // divide by 16 - } while (i > 0); - return p + 1; -} - -char *InternalFastHexToBuffer(uint64_t value, char* buffer, int num_byte) { - static const char *hexdigits = "0123456789abcdef"; - buffer[num_byte] = '\0'; - for (int i = num_byte - 1; i >= 0; i--) { -#ifdef _M_X64 - // MSVC x64 platform has a bug optimizing the uint32(value) in the #else - // block. Given that the uint32 cast was to improve performance on 32-bit - // platforms, we use 64-bit '&' directly. - buffer[i] = hexdigits[value & 0xf]; -#else - buffer[i] = hexdigits[uint32_t(value) & 0xf]; -#endif - value >>= 4; - } - return buffer; -} - -char *FastHex64ToBuffer(uint64_t value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 16); -} - -char *FastHex32ToBuffer(uint32_t value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 8); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -static const char two_ASCII_digits[100][2] = { - {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'}, - {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'}, - {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'}, - {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'}, - {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'}, - {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'}, - {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'}, - {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'}, - {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'}, - {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'}, - {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'}, - {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'}, - {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'}, - {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, - {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, - {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, - {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, - {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, - {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, - {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} -}; - -char* FastUInt32ToBufferLeft(uint32_t u, char* buffer) { - uint32_t digits; - const char *ASCII_digits = nullptr; - // The idea of this implementation is to trim the number of divides to as few - // as possible by using multiplication and subtraction rather than mod (%), - // and by outputting two digits at a time rather than one. - // The huge-number case is first, in the hopes that the compiler will output - // that case in one branch-free block of code, and only output conditional - // branches into it from below. - if (u >= 1000000000) { // >= 1,000,000,000 - digits = u / 100000000; // 100,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100_000_000: - u -= digits * 100000000; // 100,000,000 -lt100_000_000: - digits = u / 1000000; // 1,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt1_000_000: - u -= digits * 1000000; // 1,000,000 -lt1_000_000: - digits = u / 10000; // 10,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt10_000: - u -= digits * 10000; // 10,000 -lt10_000: - digits = u / 100; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100: - u -= digits * 100; -lt100: - digits = u; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -done: - *buffer = 0; - return buffer; - } - - if (u < 100) { - digits = u; - if (u >= 10) goto lt100; - *buffer++ = '0' + digits; - goto done; - } - if (u < 10000) { // 10,000 - if (u >= 1000) goto lt10_000; - digits = u / 100; - *buffer++ = '0' + digits; - goto sublt100; - } - if (u < 1000000) { // 1,000,000 - if (u >= 100000) goto lt1_000_000; - digits = u / 10000; // 10,000 - *buffer++ = '0' + digits; - goto sublt10_000; - } - if (u < 100000000) { // 100,000,000 - if (u >= 10000000) goto lt100_000_000; - digits = u / 1000000; // 1,000,000 - *buffer++ = '0' + digits; - goto sublt1_000_000; - } - // we already know that u < 1,000,000,000 - digits = u / 100000000; // 100,000,000 - *buffer++ = '0' + digits; - goto sublt100_000_000; -} - -char* FastInt32ToBufferLeft(int32_t i, char* buffer) { - uint32_t u = 0; - if (i < 0) { - *buffer++ = '-'; - u -= i; - } else { - u = i; - } - return FastUInt32ToBufferLeft(u, buffer); -} - -char* FastUInt64ToBufferLeft(uint64_t u64, char* buffer) { - int digits; - const char *ASCII_digits = nullptr; - - uint32_t u = static_cast(u64); - if (u == u64) return FastUInt32ToBufferLeft(u, buffer); - - uint64_t top_11_digits = u64 / 1000000000; - buffer = FastUInt64ToBufferLeft(top_11_digits, buffer); - u = u64 - (top_11_digits * 1000000000); - - digits = u / 10000000; // 10,000,000 - GOOGLE_DCHECK_LT(digits, 100); - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10000000; // 10,000,000 - digits = u / 100000; // 100,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 100000; // 100,000 - digits = u / 1000; // 1,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 1000; // 1,000 - digits = u / 10; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10; - digits = u; - *buffer++ = '0' + digits; - *buffer = 0; - return buffer; -} - -char* FastInt64ToBufferLeft(int64_t i, char* buffer) { - uint64_t u = 0; - if (i < 0) { - *buffer++ = '-'; - u -= i; - } else { - u = i; - } - return FastUInt64ToBufferLeft(u, buffer); -} - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- - -std::string SimpleItoa(int i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned int i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - -std::string SimpleItoa(long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned long i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - -std::string SimpleItoa(long long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned long long i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - // ---------------------------------------------------------------------- // SimpleDtoa() // SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() // We want to print the value without losing precision, but we also do // not want to print more digits than necessary. This turns out to be // trickier than it sounds. Numbers like 0.2 cannot be represented @@ -831,23 +310,18 @@ std::string SimpleItoa(unsigned long long i) { // implementation. // ---------------------------------------------------------------------- -std::string SimpleDtoa(double value) { - char buffer[kDoubleToBufferSize]; - return DoubleToBuffer(value, buffer); -} - -std::string SimpleFtoa(float value) { - char buffer[kFloatToBufferSize]; - return FloatToBuffer(value, buffer); -} +namespace { +// In practice, doubles should never need more than 24 bytes and floats +// should never need more than 14 (including null terminators), but we +// overestimate to be safe. +constexpr int kDoubleToBufferSize = 32; +constexpr int kFloatToBufferSize = 24; static inline bool IsValidFloatChar(char c) { - return ('0' <= c && c <= '9') || - c == 'e' || c == 'E' || - c == '+' || c == '-'; + return ('0' <= c && c <= '9') || c == 'e' || c == 'E' || c == '+' || c == '-'; } -void DelocalizeRadix(char* buffer) { +void DelocalizeRadix(char *buffer) { // Fast check: if the buffer has a normal decimal point, assume no // translation is needed. if (strchr(buffer, '.') != nullptr) return; @@ -868,12 +342,52 @@ void DelocalizeRadix(char* buffer) { if (!IsValidFloatChar(*buffer) && *buffer != '\0') { // It appears the radix was a multi-byte character. We need to remove the // extra bytes. - char* target = buffer; - do { ++buffer; } while (!IsValidFloatChar(*buffer) && *buffer != '\0'); + char *target = buffer; + do { + ++buffer; + } while (!IsValidFloatChar(*buffer) && *buffer != '\0'); memmove(target, buffer, strlen(buffer) + 1); } } +char *FloatToBuffer(float value, char *buffer) { + // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all + // platforms these days. Just in case some system exists where FLT_DIG + // is significantly larger -- and risks overflowing our buffer -- we have + // this assert. + static_assert(FLT_DIG < 10, "FLT_DIG_is_too_big"); + + if (value == std::numeric_limits::infinity()) { + strcpy(buffer, "inf"); + return buffer; + } else if (value == -std::numeric_limits::infinity()) { + strcpy(buffer, "-inf"); + return buffer; + } else if (std::isnan(value)) { + strcpy(buffer, "nan"); + return buffer; + } + + int snprintf_result = + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); + + // The snprintf should never overflow because the buffer is significantly + // larger than the precision we asked for. + GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + + float parsed_value; + if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { + snprintf_result = + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value); + + // Should never overflow; see above. + GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + } + + DelocalizeRadix(buffer); + return buffer; +} + char* DoubleToBuffer(double value, char* buffer) { // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all // platforms these days. Just in case some system exists where DBL_DIG @@ -917,6 +431,17 @@ char* DoubleToBuffer(double value, char* buffer) { DelocalizeRadix(buffer); return buffer; } +} // namespace + +std::string SimpleDtoa(double value) { + char buffer[kDoubleToBufferSize]; + return DoubleToBuffer(value, buffer); +} + +std::string SimpleFtoa(float value) { + char buffer[kFloatToBufferSize]; + return FloatToBuffer(value, buffer); +} static int memcasecmp(const char *s1, const char *s2, size_t len) { const unsigned char *us1 = reinterpret_cast(s1); @@ -994,72 +519,6 @@ bool safe_strtou64(const std::string &str, uint64_t *value) { return safe_uint_internal(str, value); } -char* FloatToBuffer(float value, char* buffer) { - // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all - // platforms these days. Just in case some system exists where FLT_DIG - // is significantly larger -- and risks overflowing our buffer -- we have - // this assert. - static_assert(FLT_DIG < 10, "FLT_DIG_is_too_big"); - - if (value == std::numeric_limits::infinity()) { - strcpy(buffer, "inf"); - return buffer; - } else if (value == -std::numeric_limits::infinity()) { - strcpy(buffer, "-inf"); - return buffer; - } else if (std::isnan(value)) { - strcpy(buffer, "nan"); - return buffer; - } - - int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); - - // The snprintf should never overflow because the buffer is significantly - // larger than the precision we asked for. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - - float parsed_value; - if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { - snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value); - - // Should never overflow; see above. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - } - - DelocalizeRadix(buffer); - return buffer; -} - -int GlobalReplaceSubstring(const std::string &substring, - const std::string &replacement, std::string *s) { - GOOGLE_CHECK(s != nullptr); - if (s->empty() || substring.empty()) - return 0; - std::string tmp; - int num_replacements = 0; - int pos = 0; - for (absl::string_view::size_type match_pos = - s->find(substring.data(), pos, substring.length()); - match_pos != std::string::npos; pos = match_pos + substring.length(), - match_pos = s->find(substring.data(), pos, - substring.length())) { - ++num_replacements; - // Append the original content before the match. - tmp.append(*s, pos, match_pos - pos); - // Append the replacement for the match. - tmp.append(replacement.begin(), replacement.end()); - } - // Append the content after the last match. If no replacements were made, the - // original string is left untouched. - if (num_replacements > 0) { - tmp.append(*s, pos, s->length() - pos); - s->swap(tmp); - } - return num_replacements; -} - namespace { int CalculateBase64EscapedLen(int input_len, bool do_padding) { // Base64 encodes three bytes of input at a time. If the input is not diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index 2aa522db04..1e64d7b7b0 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -67,99 +67,6 @@ inline int hex_digit_to_int(char c) { return x & 0xf; } -// ---------------------------------------------------------------------- -// HasPrefixString() -// Check if a string begins with a given prefix. -// StripPrefixString() -// Given a string and a putative prefix, returns the string minus the -// prefix string if the prefix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasPrefixString(absl::string_view str, absl::string_view prefix) { - return str.size() >= prefix.size() && - memcmp(str.data(), prefix.data(), prefix.size()) == 0; -} - -inline std::string StripPrefixString(const std::string& str, - const std::string& prefix) { - if (HasPrefixString(str, prefix)) { - return str.substr(prefix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// HasSuffixString() -// Return true if str ends in suffix. -// StripSuffixString() -// Given a string and a putative suffix, returns the string minus the -// suffix string if the suffix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasSuffixString(absl::string_view str, absl::string_view suffix) { - return str.size() >= suffix.size() && - memcmp(str.data() + str.size() - suffix.size(), suffix.data(), - suffix.size()) == 0; -} - -inline std::string StripSuffixString(const std::string& str, - const std::string& suffix) { - if (HasSuffixString(str, suffix)) { - return str.substr(0, str.size() - suffix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// ReplaceCharacters -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// Good for keeping html characters or protocol characters (\t) out -// of places where they might cause a problem. -// StripWhitespace -// Removes whitespaces from both ends of the given string. -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT void ReplaceCharacters(std::string* s, const char* remove, - char replacewith); - -PROTOBUF_EXPORT void StripWhitespace(std::string* s); - -// ---------------------------------------------------------------------- -// LowerString() -// UpperString() -// ToUpper() -// Convert the characters in "s" to lowercase or uppercase. ASCII-only: -// these functions intentionally ignore locale because they are applied to -// identifiers used in the Protocol Buffer language, not to natural-language -// strings. -// ---------------------------------------------------------------------- - -inline void LowerString(std::string* s) { - std::string::iterator end = s->end(); - for (std::string::iterator i = s->begin(); i != end; ++i) { - // tolower() changes based on locale. We don't want this! - if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A'; - } -} - -inline void UpperString(std::string* s) { - std::string::iterator end = s->end(); - for (std::string::iterator i = s->begin(); i != end; ++i) { - // toupper() changes based on locale. We don't want this! - if ('a' <= *i && *i <= 'z') *i += 'A' - 'a'; - } -} - -inline void ToUpper(std::string* s) { UpperString(s); } - -inline std::string ToUpper(const std::string& s) { - std::string out = s; - UpperString(&out); - return out; -} - // ---------------------------------------------------------------------- // StringReplace() // Give me a string and two patterns "old" and "new", and I replace @@ -272,135 +179,20 @@ inline bool safe_strtod(absl::string_view str, double* value) { return safe_strtod(std::string(str), value); } -// ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// FastTimeToBuffer() -// These are intended for speed. FastIntToBuffer() assumes the -// integer is non-negative. FastHexToBuffer() puts output in -// hex rather than decimal. FastTimeToBuffer() puts the output -// into RFC822 format. -// -// FastHex64ToBuffer() puts a 64-bit unsigned value in hex-format, -// padded to exactly 16 bytes (plus one byte for '\0') -// -// FastHex32ToBuffer() puts a 32-bit unsigned value in hex-format, -// padded to exactly 8 bytes (plus one byte for '\0') -// -// All functions take the output buffer as an arg. -// They all return a pointer to the beginning of the output, -// which may not be the beginning of the input buffer. -// ---------------------------------------------------------------------- - -// Suggested buffer size for FastToBuffer functions. Also works with -// DoubleToBuffer() and FloatToBuffer(). -static const int kFastToBufferSize = 32; - -PROTOBUF_EXPORT char* FastInt32ToBuffer(int32_t i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBuffer(int64_t i, char* buffer); -char* FastUInt32ToBuffer(uint32_t i, char* buffer); // inline below -char* FastUInt64ToBuffer(uint64_t i, char* buffer); // inline below -PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); -PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64_t i, char* buffer); -PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32_t i, char* buffer); - -// at least 22 bytes long -inline char* FastIntToBuffer(int i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastUIntToBuffer(unsigned int i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} -inline char* FastLongToBuffer(long i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastULongToBuffer(unsigned long i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32_t i, char* buffer); -PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32_t i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64_t i, char* buffer); -PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64_t i, char* buffer); - -// Just define these in terms of the above. -inline char* FastUInt32ToBuffer(uint32_t i, char* buffer) { - FastUInt32ToBufferLeft(i, buffer); - return buffer; -} -inline char* FastUInt64ToBuffer(uint64_t i, char* buffer) { - FastUInt64ToBufferLeft(i, buffer); - return buffer; -} - -inline std::string SimpleBtoa(bool value) { return value ? "true" : "false"; } - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT std::string SimpleItoa(int i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned int i); -PROTOBUF_EXPORT std::string SimpleItoa(long i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned long i); -PROTOBUF_EXPORT std::string SimpleItoa(long long i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i); - // ---------------------------------------------------------------------- // SimpleDtoa() // SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() // Description: converts a double or float to a string which, if // passed to NoLocaleStrtod(), will produce the exact same original double // (except in case of NaN; all NaNs are considered the same value). // We try to keep the string short but it's not guaranteed to be as // short as possible. // -// DoubleToBuffer() and FloatToBuffer() write the text to the given -// buffer and return it. The buffer must be at least -// kDoubleToBufferSize bytes for doubles and kFloatToBufferSize -// bytes for floats. kFastToBufferSize is also guaranteed to be large -// enough to hold either. -// // Return value: string // ---------------------------------------------------------------------- PROTOBUF_EXPORT std::string SimpleDtoa(double value); PROTOBUF_EXPORT std::string SimpleFtoa(float value); -PROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer); -PROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer); - -// In practice, doubles should never need more than 24 bytes and floats -// should never need more than 14 (including null terminators), but we -// overestimate to be safe. -static const int kDoubleToBufferSize = 32; -static const int kFloatToBufferSize = 24; - namespace strings { using Hex = absl::Hex; @@ -413,17 +205,6 @@ using Hex = absl::Hex; // ---------------------------------------------------------------------- PROTOBUF_EXPORT std::string ToHex(uint64_t num); -// ---------------------------------------------------------------------- -// GlobalReplaceSubstring() -// Replaces all instances of a substring in a string. Does nothing -// if 'substring' is empty. Returns the number of replacements. -// -// NOTE: The string pieces must not overlap s. -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring, - const std::string& replacement, - std::string* s); - namespace strings { // Encode src into dest web-safely with padding. PROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(absl::string_view src, @@ -452,15 +233,6 @@ PROTOBUF_EXPORT int EncodeAsUTF8Char(uint32_t code_point, char* output); // ---------------------------------------------------------------------- PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len); -namespace strings { -inline bool EndsWith(absl::string_view text, absl::string_view suffix) { - return suffix.empty() || - (text.size() >= suffix.size() && - memcmp(text.data() + (text.size() - suffix.size()), suffix.data(), - suffix.size()) == 0); -} -} // namespace strings - namespace internal { // A locale-independent version of the standard strtod(), which always diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc index d657579ad5..71e60e6819 100644 --- a/src/google/protobuf/stubs/strutil_unittest.cc +++ b/src/google/protobuf/stubs/strutil_unittest.cc @@ -74,62 +74,6 @@ TEST(StringUtilityTest, ImmuneToLocales) { setlocale(LC_NUMERIC, old_locale.c_str()); } -class ReplaceChars - : public ::testing::TestWithParam< - std::tuple> {}; - -TEST_P(ReplaceChars, ReplacesAllOccurencesOfAnyCharInReplaceWithAReplaceChar) { - std::string expected = std::get<0>(GetParam()); - std::string string_to_replace_in = std::get<1>(GetParam()); - const char* what_to_replace = std::get<2>(GetParam()); - char replacement = std::get<3>(GetParam()); - ReplaceCharacters(&string_to_replace_in, what_to_replace, replacement); - ASSERT_EQ(expected, string_to_replace_in); -} - -INSTANTIATE_TEST_CASE_P( - Replace, ReplaceChars, - ::testing::Values( - std::make_tuple("", "", "", '_'), // empty string should remain empty - std::make_tuple(" ", " ", "", '_'), // no replacement string - std::make_tuple(" ", " ", "_-abcedf", - '*'), // replacement character not in string - std::make_tuple("replace", "Replace", "R", - 'r'), // replace one character - std::make_tuple("not_spaces__", "not\nspaces\t ", " \t\r\n", - '_'), // replace some special characters - std::make_tuple("c++", "cxx", "x", - '+'), // same character multiple times - std::make_tuple("qvvvvvng v T", "queueing a T", "aeiou", - 'v'))); // replace all voewls - -class StripWs - : public ::testing::TestWithParam> {}; - -TEST_P(StripWs, AlwaysStripsLeadingAndTrailingWhitespace) { - std::string expected = std::get<0>(GetParam()); - std::string string_to_strip = std::get<1>(GetParam()); - StripWhitespace(&string_to_strip); - ASSERT_EQ(expected, string_to_strip); -} - -INSTANTIATE_TEST_CASE_P( - Strip, StripWs, - ::testing::Values( - std::make_tuple("", ""), // empty string should remain empty - std::make_tuple("", " "), // only ws should become empty - std::make_tuple("no whitespace", - " no whitespace"), // leading ws removed - std::make_tuple("no whitespace", - "no whitespace "), // trailing ws removed - std::make_tuple("no whitespace", - " no whitespace "), // same nb. of leading and trailing - std::make_tuple( - "no whitespace", - " no whitespace "), // different nb. of leading/trailing - std::make_tuple("no whitespace", - " no whitespace "))); // more trailing than leading - } // anonymous namespace } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index 350f9a9808..5f6a4fbcb6 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -38,6 +38,7 @@ #include #include +#include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "google/protobuf/io/io_win32.h" #include "google/protobuf/stubs/strutil.h" @@ -147,7 +148,7 @@ std::string GetTemporaryDirectoryName() { } // On Win32, tmpnam() returns a file prefixed with '\', but which is supposed // to be used in the current working directory. WTF? - if (HasPrefixString(result, "\\")) { + if (absl::StartsWith(result, "\\")) { result.erase(0, 1); } // The Win32 API accepts forward slashes as a path delimiter as long as the diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 1bee3c79e2..c9fe105f4a 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index a8354863fe..34914636d7 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 514832971f..7daed3f660 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc @@ -43,6 +43,7 @@ #include "absl/strings/str_cat.h" #include "google/protobuf/util/internal/utility.h" #include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/stubs/mathutil.h" namespace google { @@ -263,7 +264,7 @@ std::string DataPiece::ValueAsStringOrDefault( case TYPE_FLOAT: return FloatAsString(float_); case TYPE_BOOL: - return SimpleBtoa(bool_); + return bool_ ? "true" : "false"; case TYPE_STRING: return absl::StrCat("\"", str_, "\""); case TYPE_BYTES: { @@ -397,7 +398,7 @@ bool DataPiece::DecodeBase64(absl::string_view src, std::string* dest) const { absl::WebSafeBase64Escape(*dest, &encoded); // Remove trailing padding '=' characters before comparison. absl::string_view src_no_padding = absl::string_view(src).substr( - 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1 + 0, absl::EndsWith(src, "=") ? src.find_last_not_of('=') + 1 : src.length()); return encoded == src_no_padding; } @@ -409,7 +410,7 @@ bool DataPiece::DecodeBase64(absl::string_view src, std::string* dest) const { std::string encoded; strings::LegacyBase64EscapeWithoutPadding(*dest, &encoded); absl::string_view src_no_padding = absl::string_view(src).substr( - 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1 + 0, absl::EndsWith(src, "=") ? src.find_last_not_of('=') + 1 : src.length()); return encoded == src_no_padding; } diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index e0ffe1324e..5cdc29da97 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc @@ -31,7 +31,7 @@ #include "google/protobuf/util/internal/field_mask_utility.h" #include "absl/status/status.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/util/internal/utility.h" #include "google/protobuf/stubs/status_macros.h" @@ -56,7 +56,7 @@ std::string AppendPathSegmentToPrefix(absl::string_view prefix, return std::string(prefix); } // If the segment is a map key, appends it to the prefix without the ".". - if (HasPrefixString(segment, "[\"")) { + if (absl::StartsWith(segment, "[\"")) { return absl::StrCat(prefix, segment); } return absl::StrCat(prefix, ".", segment); diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index eccedb9d84..c294009bc8 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -43,6 +43,7 @@ #include "absl/status/status.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/util/internal/object_writer.h" @@ -966,15 +967,15 @@ JsonStreamParser::TokenType JsonStreamParser::GetNextTokenType() { return BEGIN_NUMBER; } if (size >= kKeywordTrue.length() && - HasPrefixString(data_view, kKeywordTrue)) { + absl::StartsWith(data_view, kKeywordTrue)) { return BEGIN_TRUE; } if (size >= kKeywordFalse.length() && - HasPrefixString(data_view, kKeywordFalse)) { + absl::StartsWith(data_view, kKeywordFalse)) { return BEGIN_FALSE; } if (size >= kKeywordNull.length() && - HasPrefixString(data_view, kKeywordNull)) { + absl::StartsWith(data_view, kKeywordNull)) { return BEGIN_NULL; } if (*data == '{') return BEGIN_OBJECT; diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 677647e5ec..2c4d5ef575 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc @@ -41,6 +41,7 @@ #include "absl/base/call_once.h" #include "absl/status/status.h" #include "absl/status/statusor.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/strip.h" #include "absl/time/time.h" @@ -1048,7 +1049,7 @@ Status ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow, absl::string_view value(data.str()); int timezone_offset_seconds = 0; - if (HasSuffixString(value, "Z")) { + if (absl::EndsWith(value, "Z")) { value = value.substr(0, value.size() - 1); } else { size_t pos = value.find_last_of("+-"); @@ -1123,13 +1124,13 @@ Status ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow, absl::string_view value(data.str()); - if (!HasSuffixString(value, "s")) { + if (!absl::EndsWith(value, "s")) { return absl::InvalidArgumentError( "Illegal duration format; duration must end with 's'"); } value = value.substr(0, value.size() - 1); int sign = 1; - if (HasPrefixString(value, "-")) { + if (absl::StartsWith(value, "-")) { sign = -1; value = value.substr(1); } diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index f8054ca728..c2488e8ba4 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc @@ -45,6 +45,7 @@ #include "google/protobuf/stubs/strutil.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/ascii.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/util/internal/constants.h" diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 8df47333ee..2942eeb516 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc @@ -32,6 +32,7 @@ #include "absl/base/call_once.h" #include "absl/status/status.h" +#include "absl/strings/ascii.h" #include "google/protobuf/stubs/bytestream.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -141,7 +142,7 @@ class StatusErrorListener : public converter::ErrorListener { std::string GetLocString(const converter::LocationTrackerInterface& loc) { std::string loc_string = loc.ToString(); - StripWhitespace(&loc_string); + absl::StripAsciiWhitespace(&loc_string); if (!loc_string.empty()) { loc_string = absl::StrCat("(", loc_string, ")"); } diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 3f18431fee..3b582c48c5 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc @@ -509,6 +509,32 @@ TEST_P(JsonTest, FloatPrecision) { IsOkAndHolds("[0.99000000953674316,0.87999999523162842]")); } +TEST_P(JsonTest, FloatMinMaxValue) { + // 3.4028235e38 is FLT_MAX to 8-significant-digits. The final digit (5) + // is rounded up; that means that when parsing this as a 64-bit FP number, + // the value ends up higher than FLT_MAX. We still want to accept it though, + // as a reasonable representation of FLT_MAX. + auto m = ToProto(R"json( + { + "repeatedFloatValue": [3.4028235e38, -3.4028235e38], + } + )json"); + ASSERT_OK(m); + EXPECT_THAT(m->repeated_float_value(), ElementsAre(FLT_MAX, -FLT_MAX)); +} + +TEST_P(JsonTest, FloatOutOfRange) { + // Check that the slightly-lenient parsing demonstrated in FloatMinMaxValue + // doesn't mean we allow all values. The value being parsed differs only + // in the least significant (represented) digit. + auto m = ToProto(R"json( + { + "floatValue": 3.4028236e38 + } + )json"); + EXPECT_THAT(m, StatusIs(absl::StatusCode::kInvalidArgument)); +} + TEST_P(JsonTest, ParseLegacySingleRepeatedField) { auto m = ToProto(R"json({ "repeatedInt32Value": 1997, diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 51b2bea3be..ba4db190d4 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc @@ -57,6 +57,7 @@ #include "google/protobuf/stubs/strutil.h" #include "absl/container/fixed_array.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" #include "google/protobuf/util/field_comparator.h" diff --git a/src/google/protobuf/wire_format_unittest.inc b/src/google/protobuf/wire_format_unittest.inc index 5653be7962..6224ae7fa3 100644 --- a/src/google/protobuf/wire_format_unittest.inc +++ b/src/google/protobuf/wire_format_unittest.inc @@ -45,7 +45,7 @@ #include #include "absl/base/casts.h" #include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/test_util2.h" #include "google/protobuf/stubs/stl_util.h" @@ -1560,7 +1560,7 @@ TEST_F(Utf8ValidationTest, OldVerifyUTF8String) { #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED ASSERT_EQ(1, errors.size()); EXPECT_TRUE( - HasPrefixString(errors[0], + absl::StartsWith(errors[0], "String field contains invalid UTF-8 data when " "serializing a protocol buffer. Use the " "'bytes' type if you intend to send raw bytes.")); diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 3fbb1a666a..16ec96e853 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc.