Merge branch 'protocolbuffers:main' into fix_12505

pull/12540/head
Jason Lunn 2 years ago committed by GitHub
commit 24ac3ecd86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 182
      .github/workflows/test_cpp.yml
  2. 4
      .github/workflows/test_csharp.yml
  3. 49
      .github/workflows/test_java.yml
  4. 9
      .github/workflows/test_php.yml
  5. 2
      .github/workflows/test_ruby.yml
  6. 22
      CMakeLists.txt
  7. 2
      Protobuf-C++.podspec
  8. 2
      Protobuf.podspec
  9. 8
      WORKSPACE
  10. 5
      build_defs/cpp_opts.bzl
  11. 35
      cmake/conformance.cmake
  12. 8
      cmake/gtest.cmake
  13. 17
      cmake/install.cmake
  14. 3
      cmake/protobuf-lite.pc.cmake
  15. 3
      cmake/protobuf.pc.cmake
  16. 5
      conformance/binary_json_conformance_suite.cc
  17. 2
      csharp/Google.Protobuf.Tools.nuspec
  18. 3
      csharp/generate_protos.sh
  19. 8
      csharp/src/Google.Protobuf.Test.TestProtos/Unittest.pb.cs
  20. 177
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.pb.cs
  21. 1141
      csharp/src/Google.Protobuf.Test.TestProtos/UnittestRetention.pb.cs
  22. 15
      csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
  23. BIN
      csharp/src/Google.Protobuf.Test/testprotos.pb
  24. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  25. 204
      csharp/src/Google.Protobuf/Reflection/Descriptor.pb.cs
  26. 5
      docs/options.md
  27. 1
      editors/protobuf-mode.el
  28. 6
      java/README.md
  29. 2
      java/bom/pom.xml
  30. 37
      java/core/BUILD.bazel
  31. 2
      java/core/pom.xml
  32. 4
      java/core/src/main/java/com/google/protobuf/Descriptors.java
  33. 2
      java/kotlin-lite/pom.xml
  34. 2
      java/kotlin/pom.xml
  35. 2
      java/lite.md
  36. 2
      java/lite/pom.xml
  37. 2
      java/pom.xml
  38. 2
      java/protoc/pom.xml
  39. 20
      java/util/BUILD.bazel
  40. 2
      java/util/pom.xml
  41. 34
      objectivec/BUILD.bazel
  42. 2
      php/ext/google/protobuf/php-upb.c
  43. 653
      php/ext/google/protobuf/php-upb.h
  44. 2
      php/ext/google/protobuf/protobuf.h
  45. 1
      pkg/BUILD.bazel
  46. 8
      protobuf_deps.bzl
  47. 10
      protobuf_version.bzl
  48. 2
      python/google/protobuf/__init__.py
  49. 19
      python/google/protobuf/descriptor_pool.py
  50. 23
      python/google/protobuf/internal/builder.py
  51. 39
      python/google/protobuf/internal/message_test.py
  52. 17
      python/internal.bzl
  53. 2
      ruby/ext/google/protobuf_c/ruby-upb.c
  54. 661
      ruby/ext/google/protobuf_c/ruby-upb.h
  55. 2
      ruby/google-protobuf.gemspec
  56. 4
      ruby/pom.xml
  57. 40
      rust/BUILD
  58. 1
      rust/aspects.bzl
  59. 4
      rust/cpp_kernel/BUILD
  60. 2
      rust/cpp_kernel/cpp.rs
  61. 8
      rust/shared.rs
  62. 1
      rust/test/cpp/interop/BUILD
  63. 94
      rust/test/cpp/interop/main.rs
  64. 30
      rust/test/cpp/interop/test_utils.cc
  65. 52
      rust/test/shared/BUILD
  66. 61
      rust/test/shared/serialization_test.rs
  67. 4
      rust/upb_kernel/BUILD
  68. 4
      src/file_lists.cmake
  69. 21
      src/google/protobuf/BUILD.bazel
  70. 86
      src/google/protobuf/any.pb.cc
  71. 108
      src/google/protobuf/any.pb.h
  72. 313
      src/google/protobuf/api.pb.cc
  73. 523
      src/google/protobuf/api.pb.h
  74. 10
      src/google/protobuf/arena_align.h
  75. 22
      src/google/protobuf/arena_test_util.h
  76. 12
      src/google/protobuf/compiler/BUILD.bazel
  77. 2
      src/google/protobuf/compiler/allowlists/BUILD.bazel
  78. 9
      src/google/protobuf/compiler/allowlists/allowlists.h
  79. 59
      src/google/protobuf/compiler/allowlists/open_enum.cc
  80. 51
      src/google/protobuf/compiler/allowlists/unused_imports.cc
  81. 5
      src/google/protobuf/compiler/annotation_test_util.cc
  82. 6
      src/google/protobuf/compiler/annotation_test_util.h
  83. 2
      src/google/protobuf/compiler/code_generator.cc
  84. 261
      src/google/protobuf/compiler/command_line_interface.cc
  85. 215
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  86. 11
      src/google/protobuf/compiler/cpp/field_generators/cord_field.cc
  87. 28
      src/google/protobuf/compiler/cpp/field_generators/enum_field.cc
  88. 494
      src/google/protobuf/compiler/cpp/field_generators/map_field.cc
  89. 592
      src/google/protobuf/compiler/cpp/field_generators/message_field.cc
  90. 64
      src/google/protobuf/compiler/cpp/field_generators/primitive_field.cc
  91. 32
      src/google/protobuf/compiler/cpp/field_generators/string_field.cc
  92. 142
      src/google/protobuf/compiler/cpp/file.cc
  93. 2
      src/google/protobuf/compiler/cpp/file.h
  94. 2
      src/google/protobuf/compiler/cpp/generator.cc
  95. 58
      src/google/protobuf/compiler/cpp/helpers.cc
  96. 82
      src/google/protobuf/compiler/cpp/helpers.h
  97. 478
      src/google/protobuf/compiler/cpp/message.cc
  98. 27
      src/google/protobuf/compiler/cpp/names.h
  99. 36
      src/google/protobuf/compiler/cpp/parse_function_generator.cc
  100. 14
      src/google/protobuf/compiler/csharp/BUILD.bazel
  101. Some files were not shown because too many files have changed in this diff Show More

@ -51,6 +51,26 @@ jobs:
bazel-cache: cpp_linux/${{ matrix.config.name }} bazel-cache: cpp_linux/${{ matrix.config.name }}
bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }} bazel: test ${{ matrix.targets }} ${{ matrix.config.flags }}
linux-gcc:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
version: ['9.5', '13.1']
name: Linux GCC ${{ matrix.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
- name: Run tests
uses: protocolbuffers/protobuf-ci/bazel-docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:${{ matrix.version }}-5.4.0-2d15d9e888c9e7f90961dbd3afc8ea209717fb4b
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: cpp_linux/gcc-${{ matrix.version }}
bazel: test //pkg/... //src/... @com_google_protobuf_examples//...
linux-release: linux-release:
strategy: strategy:
fail-fast: false # Don't cancel all jobs if one fails. fail-fast: false # Don't cancel all jobs if one fails.
@ -94,23 +114,15 @@ jobs:
fail-fast: false # Don't cancel all jobs if one fails. fail-fast: false # Don't cancel all jobs if one fails.
matrix: matrix:
include: include:
- command: >- - flags: -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14
/test.sh
-Dprotobuf_BUILD_CONFORMANCE=ON
-Dprotobuf_BUILD_EXAMPLES=ON
-DCMAKE_CXX_STANDARD=14
- name: Ninja - name: Ninja
command: >- flags: -G Ninja -DCMAKE_CXX_STANDARD=14
/test.sh
-G Ninja
-Dprotobuf_BUILD_CONFORMANCE=ON
-DCMAKE_CXX_STANDARD=14
- name: Shared - name: Shared
command: >- flags: -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14
/test.sh - name: C++17
-Dprotobuf_BUILD_CONFORMANCE=ON flags: -DCMAKE_CXX_STANDARD=17
-Dprotobuf_BUILD_SHARED_LIBS=ON - name: C++20
-DCMAKE_CXX_STANDARD=14 flags: -DCMAKE_CXX_STANDARD=20
name: Linux CMake ${{ matrix.name}} name: Linux CMake ${{ matrix.name}}
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -120,11 +132,6 @@ jobs:
with: with:
ref: ${{ inputs.safe-checkout }} ref: ${{ inputs.safe-checkout }}
# Initialize/update the submodule from remote to validate a new fetch based on .gitmodules
# We have to do this separately since actions/checkout doesn't support the "--remote" flag
- name: Update submodules
run: git submodule update --init --remote --recursive
- name: Setup ccache - name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1 uses: protocolbuffers/protobuf-ci/ccache@v1
with: with:
@ -133,9 +140,12 @@ jobs:
- name: Run tests - name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1 uses: protocolbuffers/protobuf-ci/docker@v1
with: with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: ${{ matrix.command }} ${{ env.CCACHE_CMAKE_FLAGS }} command: >-
/test.sh ${{ matrix.flags}} ${{ env.CCACHE_CMAKE_FLAGS }}
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=ON
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
linux-cmake-install: linux-cmake-install:
name: Linux CMake Install name: Linux CMake Install
@ -145,9 +155,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with: with:
ref: ${{ inputs.safe-checkout }} ref: ${{ inputs.safe-checkout }}
submodules: recursive
- name: Update submodules
run: git submodule update --init --remote --recursive
- name: Setup ccache - name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1 uses: protocolbuffers/protobuf-ci/ccache@v1
@ -157,19 +165,20 @@ jobs:
- name: Run tests - name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1 uses: protocolbuffers/protobuf-ci/docker@v1
with: with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} \&\& /install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} -Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package \&\&
/test.sh /test.sh
${{ env.CCACHE_CMAKE_FLAGS }} ${{ env.CCACHE_CMAKE_FLAGS }}
-Dprotobuf_REMOVE_INSTALLED_HEADERS=ON -Dprotobuf_REMOVE_INSTALLED_HEADERS=ON
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF -Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF
-Dprotobuf_BUILD_CONFORMANCE=ON -Dprotobuf_BUILD_CONFORMANCE=ON
-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD=14
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
linux-cmake-32-bit: linux-cmake-examples:
name: Linux CMake 32-bit name: Linux CMake Examples
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout pending changes - name: Checkout pending changes
@ -177,31 +186,68 @@ jobs:
with: with:
ref: ${{ inputs.safe-checkout }} ref: ${{ inputs.safe-checkout }}
- name: Update submodules - name: Setup ccache
run: git submodule update --init --remote --recursive uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake-examples
- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }}
-Dprotobuf_USE_EXTERNAL_GTEST=ON -Dprotobuf_ABSL_PROVIDER=package
-Dprotobuf_BUILD_EXAMPLES=OFF \&\&
mkdir examples/build \&\&
cd examples/build \&\&
cmake .. -DCMAKE_CXX_STANDARD=14 \&\&
cmake --build .
linux-cmake-gcc:
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
matrix:
include:
- name: C++14
flags: -DCMAKE_CXX_STANDARD=14
- name: C++17
flags: -DCMAKE_CXX_STANDARD=17
- name: C++20
flags: -DCMAKE_CXX_STANDARD=20
name: Linux CMake GCC ${{ matrix.name }}
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
submodules: recursive
- name: Setup ccache - name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1 uses: protocolbuffers/protobuf-ci/ccache@v1
with: with:
cache-prefix: linux-cmake-32-bit cache-prefix: linux-cmake-gcc-${{ matrix.name }}
- name: Run tests - name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1 uses: protocolbuffers/protobuf-ci/docker@v1
with: with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:f99f051daa8b12f4ebad5927f389bc71372f771ab080290ab451cbaf1648f9ea image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:13.1-5.4.0-307caa02808127e49720f3e77d6a9f3b3ef5a915
platform: linux/386
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
entrypoint: bash
command: >- command: >-
/bin/bash -c ' -c 'set -ex;
cd /workspace; cd /workspace;
ccache -z; ccache -z;
cmake . -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }}; cmake . ${{ matrix.flags }} ${{ env.CCACHE_CMAKE_FLAGS }};
cmake --build . --parallel 20; cmake --build . --parallel 20;
ctest --verbose --parallel 20; ctest --verbose --parallel 20;
ccache -s' ccache -s'
linux-cmake-examples: linux-cmake-submodules:
name: Linux CMake Examples name: Linux CMake Submodules
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout pending changes - name: Checkout pending changes
@ -213,23 +259,46 @@ jobs:
- name: Setup ccache - name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1 uses: protocolbuffers/protobuf-ci/ccache@v1
with: with:
cache-prefix: linux-cmake-examples cache-prefix: linux-cmake-${{ matrix.name }}
- name: Run tests - name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1 uses: protocolbuffers/protobuf-ci/docker@v1
with: with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake@sha256:e0eb6c69b7551d89f0dbdbe11906077a1d501229c28db39623b945e0c5d7029a image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.13.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/install.sh -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }} \&\& /test.sh ${{ env.CCACHE_CMAKE_FLAGS }}
cd examples \&\& -Dprotobuf_BUILD_CONFORMANCE=ON -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14
mkdir build \&\&
cmake linux-cmake-32-bit:
${{ env.CCACHE_CMAKE_FLAGS }} name: Linux CMake 32-bit
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF runs-on: ubuntu-latest
-DCMAKE_CXX_STANDARD=14 steps:
-S . -B build \&\& - name: Checkout pending changes
cmake --build build uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
submodules: recursive
- name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1
with:
cache-prefix: linux-cmake-32-bit
- name: Run tests
uses: protocolbuffers/protobuf-ci/docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:f99f051daa8b12f4ebad5927f389bc71372f771ab080290ab451cbaf1648f9ea
platform: linux/386
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/bin/bash -cex '
cd /workspace;
ccache -z;
cmake . -DCMAKE_CXX_STANDARD=14 ${{ env.CCACHE_CMAKE_FLAGS }};
cmake --build . --parallel 20;
ctest --verbose --parallel 20;
ccache -s'
non-linux: non-linux:
strategy: strategy:
@ -278,11 +347,20 @@ jobs:
-G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF
-Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF
-Dprotobuf_BUILD_EXAMPLES=ON -Dprotobuf_BUILD_EXAMPLES=ON
vsversion: '2019'
- name: Windows CMake 2022
os: windows-2022
flags: >-
-G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF
-Dprotobuf_BUILD_SHARED_LIBS=OFF
-Dprotobuf_BUILD_EXAMPLES=ON
vsversion: '2022'
- name: Windows CMake Shared - name: Windows CMake Shared
os: windows-2019 os: windows-2019
flags: >- flags: >-
-G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF
-Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_SHARED_LIBS=ON
vsversion: '2019'
- name: Windows CMake Install - name: Windows CMake Install
os: windows-2019 os: windows-2019
install-flags: -G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -Dprotobuf_BUILD_TESTS=OFF install-flags: -G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -Dprotobuf_BUILD_TESTS=OFF
@ -290,6 +368,7 @@ jobs:
-G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF -G Ninja -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_CONFORMANCE=OFF
-Dprotobuf_REMOVE_INSTALLED_HEADERS=ON -Dprotobuf_REMOVE_INSTALLED_HEADERS=ON
-Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF -Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF
vsversion: '2019'
name: ${{ matrix.name }} name: ${{ matrix.name }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
@ -297,14 +376,13 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with: with:
ref: ${{ inputs.safe-checkout }} ref: ${{ inputs.safe-checkout }}
submodules: recursive
- name: Update submodules
run: git submodule update --init --remote --recursive
- name: Setup ccache - name: Setup ccache
uses: protocolbuffers/protobuf-ci/ccache@v1 uses: protocolbuffers/protobuf-ci/ccache@v1
with: with:
cache-prefix: ${{ matrix.name }} cache-prefix: ${{ matrix.name }}
vsversion: ${{ matrix.vsversion }}
# Install phase. # Install phase.
- name: Configure CMake for install - name: Configure CMake for install

@ -62,7 +62,7 @@ jobs:
image: mcr.microsoft.com/dotnet/sdk:6.0.100-bullseye-slim image: mcr.microsoft.com/dotnet/sdk:6.0.100-bullseye-slim
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -c ' /bin/bash -cex '
DOTNET_CLI_TELEMETRY_OPTOUT=true DOTNET_CLI_TELEMETRY_OPTOUT=true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
dotnet publish -c Release -f net6.0 /workspace/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj' dotnet publish -c Release -f net6.0 /workspace/csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.csproj'
@ -80,7 +80,7 @@ jobs:
skip-staleness-check: true skip-staleness-check: true
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -c ' /bin/bash -cex '
DOTNET_CLI_TELEMETRY_OPTOUT=true DOTNET_CLI_TELEMETRY_OPTOUT=true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
dotnet vstest /workspace/csharp/src/Google.Protobuf.Test/bin/Release/net6.0/publish/Google.Protobuf.Test.dll' dotnet vstest /workspace/csharp/src/Google.Protobuf.Test/bin/Release/net6.0/publish/Google.Protobuf.Test.dll'

@ -73,3 +73,52 @@ jobs:
run: curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/linkage-monitor-latest-all-deps.jar" run: curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/linkage-monitor-latest-all-deps.jar"
- name: Fails if there's new linkage errors compared with baseline - name: Fails if there's new linkage errors compared with baseline
run: java -Xmx2048m -jar linkage-monitor-latest-all-deps.jar com.google.cloud:libraries-bom run: java -Xmx2048m -jar linkage-monitor-latest-all-deps.jar com.google.cloud:libraries-bom
protobuf-bom:
name: Protobuf Maven BOM
runs-on: ubuntu-latest
steps:
- name: Checkout pending changes
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ inputs.safe-checkout }}
- name: Build protoc
id: build-protoc
uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
architecture: linux-x86_64
- name: Move protoc into place and clean up
run: |
mv ${{ steps.build-protoc.outputs.protoc }} protoc
sudo rm -rf _build
- name: Install snapshot version locally (not using generated pom.xml)
run: |
mvn -e -B -Dhttps.protocols=TLSv1.2 install -Dmaven.test.skip=true
working-directory: java
- name: Generate pom.xml files from the template
uses: protocolbuffers/protobuf-ci/bazel-docker@v1
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-03a376b5d6ef66f827fc307716e3b841cc26b709
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: java_linux/11
# protobuf-java and protobuf-java-util are the member of the BOM
bash: |
bazel build //java/core:core_mvn-pom //java/util:util_mvn-pom
cp bazel-bin/java/core/core_mvn-pom.xml .
cp bazel-bin/java/util/util_mvn-pom.xml .
- name: Copy the generated pom.xml files to the local Maven repository
shell: bash
run: |
LOCAL_MAVEN_GROUP_DIR="${HOME}/.m2/repository/com/google/protobuf"
VERSION=$(grep "<version>" core_mvn-pom.xml | sed "s/<version>\(.*\)<\/version>/\1/" | xargs)
cp core_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java/${VERSION}/protobuf-java-${VERSION}.pom
cp util_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java-util/${VERSION}/protobuf-java-util-${VERSION}.pom
- name: Clean up
run: |
sudo rm -rf _build
- name: Validate Protobuf BOM
uses: googleapis/java-cloud-bom/tests/validate-bom@v26.13.0
with:
bom-path: java/bom/pom.xml

@ -95,7 +95,7 @@ jobs:
platform: linux/386 platform: linux/386
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -c ' /bin/bash -cex '
cd php && php -v && php -m; cd php && php -v && php -m;
composer update --ignore-platform-reqs; composer update --ignore-platform-reqs;
PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }} PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }}
@ -154,14 +154,17 @@ jobs:
- name: Update submodules - name: Update submodules
run: git submodule update --init --remote --recursive run: git submodule update --init --remote --recursive
- name: Uninstall problematic libgd
run: brew uninstall --ignore-dependencies gd
- name: Install dependencies - name: Install dependencies
run: brew install coreutils # For sha256sum run: brew install coreutils gd
- name: Pin PHP version - name: Pin PHP version
uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # 2.24.0 uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # 2.24.0
with: with:
php-version: ${{ matrix.version }} php-version: ${{ matrix.version }}
- name: Check PHP version - name: Check PHP version
run: php --version | grep ${{ matrix.version }} || (echo "Invalid PHP version - $(php --version)" && exit 1) run: php --version | grep ${{ matrix.version }} || (echo "Invalid PHP version - $(php --version)" && exit 1)

@ -63,7 +63,7 @@ jobs:
skip-staleness-check: true skip-staleness-check: true
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >- command: >-
/bin/bash -c ' /bin/bash -cex '
gem install bundler; gem install bundler;
cd /workspace/ruby; cd /workspace/ruby;
bundle; bundle;

@ -1,22 +1,11 @@
# Minimum CMake required # Minimum CMake required. If available, accept the policy-controlled behavior up
cmake_minimum_required(VERSION 3.10) # to 3.26.
cmake_minimum_required(VERSION 3.10...3.26)
if(protobuf_VERBOSE) if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring...") message(STATUS "Protocol Buffers Configuring...")
endif() endif()
# MSVC runtime library flags are selected by an abstraction.
# New in CMake 3.15: https://cmake.org/cmake/help/latest/policy/CMP0091.html
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# option() honors normal variables
# New in CMake 3.13: https://cmake.org/cmake/help/latest/policy/CMP0077.html
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077)
# Project # Project
project(protobuf C CXX) project(protobuf C CXX)
@ -93,7 +82,7 @@ if (protobuf_BUILD_SHARED_LIBS)
endif () endif ()
# Version metadata # Version metadata
set(protobuf_VERSION_STRING "4.22.3") set(protobuf_VERSION_STRING "4.23.0")
set(protobuf_DESCRIPTION "Protocol Buffers") set(protobuf_DESCRIPTION "Protocol Buffers")
set(protobuf_CONTACT "protobuf@googlegroups.com") set(protobuf_CONTACT "protobuf@googlegroups.com")
@ -332,6 +321,9 @@ endif (protobuf_UNICODE)
set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library") set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library")
set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package") set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package")
set(protobuf_JSONCPP_PROVIDER "module" CACHE STRING "Provider of jsoncpp library")
set_property(CACHE protobuf_JSONCPP_PROVIDER PROPERTY STRINGS "module" "package")
if (protobuf_BUILD_TESTS) if (protobuf_BUILD_TESTS)
include(${protobuf_SOURCE_DIR}/cmake/gtest.cmake) include(${protobuf_SOURCE_DIR}/cmake/gtest.cmake)
endif (protobuf_BUILD_TESTS) endif (protobuf_BUILD_TESTS)

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Protobuf-C++' s.name = 'Protobuf-C++'
s.version = '4.22.3' s.version = '4.23.0'
s.summary = 'Protocol Buffers v3 runtime library for C++.' s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf' s.homepage = 'https://github.com/google/protobuf'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'

@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library. # dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Protobuf' s.name = 'Protobuf'
s.version = '3.22.3' s.version = '3.23.0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf' s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'

@ -7,6 +7,10 @@ local_repository(
path = "examples", path = "examples",
) )
# Load common dependencies first to ensure we use the correct version
load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
protobuf_deps()
# Bazel platform rules. # Bazel platform rules.
http_archive( http_archive(
name = "platforms", name = "platforms",
@ -28,10 +32,6 @@ load("@com_google_googletest//:googletest_deps.bzl", "googletest_deps")
googletest_deps() googletest_deps()
# Load common dependencies.
load("//:protobuf_deps.bzl", "PROTOBUF_MAVEN_ARTIFACTS", "protobuf_deps")
protobuf_deps()
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps() rules_jvm_external_deps()

@ -36,6 +36,11 @@ LINK_OPTS = select({
# Suppress linker warnings about files with no symbols defined. # Suppress linker warnings about files with no symbols defined.
"-ignore:4221", "-ignore:4221",
], ],
"@platforms//os:macos": [
"-lpthread",
"-lm",
"-framework CoreFoundation",
],
"//conditions:default": [ "//conditions:default": [
"-lpthread", "-lpthread",
"-lm", "-lm",

@ -1,12 +1,15 @@
if (protobuf_JSONCPP_PROVIDER STREQUAL "module")
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt") if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt")
message(FATAL_ERROR message(FATAL_ERROR
"Cannot find third_party/jsoncpp directory that's needed to " "Cannot find third_party/jsoncpp directory that's needed to "
"build conformance tests. If you use git, make sure you have cloned " "build conformance tests. If you use git, make sure you have cloned "
"submodules:\n" "submodules:\n"
" git submodule update --init --recursive\n" " git submodule update --init --recursive\n"
"If instead you want to skip them, run cmake with:\n" "If instead you want to skip them, run cmake with:\n"
" cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n") " cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n")
endif()
elseif(protobuf_JSONCPP_PROVIDER STREQUAL "package")
find_package(jsoncpp REQUIRED)
endif() endif()
add_custom_command( add_custom_command(
@ -84,6 +87,14 @@ add_test(NAME conformance_cpp_test
DEPENDS conformance_test_runner conformance_cpp) DEPENDS conformance_test_runner conformance_cpp)
set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests") set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp) if(protobuf_JSONCPP_PROVIDER STREQUAL "module")
target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp)
target_link_libraries(conformance_test_runner jsoncpp_lib) target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include)
if(BUILD_SHARED_LIBS)
target_link_libraries(conformance_test_runner jsoncpp_lib)
else()
target_link_libraries(conformance_test_runner jsoncpp_static)
endif()
else()
target_link_libraries(conformance_test_runner jsoncpp)
endif()

@ -1,7 +1,7 @@
option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF) option(protobuf_USE_EXTERNAL_GTEST "Use external Google Test (i.e. not the one in third_party/googletest)" OFF)
if (protobuf_USE_EXTERNAL_GTEST) if (protobuf_USE_EXTERNAL_GTEST)
find_package(GTest REQUIRED) find_package(GTest REQUIRED CONFIG)
else() else()
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt") if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/googletest/CMakeLists.txt")
message(FATAL_ERROR message(FATAL_ERROR
@ -32,9 +32,9 @@ else()
"GTEST_CREATE_SHARED_LIBRARY=1" "GTEST_CREATE_SHARED_LIBRARY=1"
) )
if (protobuf_INSTALL) endif()
set(protobuf_INSTALL_TESTS ON) if (protobuf_INSTALL)
endif() set(protobuf_INSTALL_TESTS ON)
endif() endif()
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})

@ -1,5 +1,22 @@
include(GNUInstallDirs) include(GNUInstallDirs)
foreach(_target IN LISTS protobuf_ABSL_USED_TARGETS)
string(REPLACE :: _ _modified_target ${_target})
list(APPEND _pc_targets ${_modified_target})
endforeach()
list(APPEND _pc_targets "utf8_range")
set(_protobuf_PC_REQUIRES "")
set(_sep "")
foreach (_target IN LISTS _pc_targets)
string(CONCAT _protobuf_PC_REQUIRES "${_protobuf_PC_REQUIRES}" "${_sep}" "${_target}")
set(_sep " ")
endforeach ()
set(_protobuf_PC_CFLAGS)
if (protobuf_BUILD_SHARED_LIBS)
set(_protobuf_PC_CFLAGS -DPROTOBUF_USE_DLLS)
endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf-lite.pc.cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf-lite.pc.cmake

@ -6,6 +6,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Protocol Buffers Name: Protocol Buffers
Description: Google's Data Interchange Format Description: Google's Data Interchange Format
Version: @protobuf_VERSION@ Version: @protobuf_VERSION@
Requires: @_protobuf_PC_REQUIRES@
Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@ Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
Conflicts: protobuf Conflicts: protobuf

@ -6,6 +6,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Protocol Buffers Name: Protocol Buffers
Description: Google's Data Interchange Format Description: Google's Data Interchange Format
Version: @protobuf_VERSION@ Version: @protobuf_VERSION@
Requires: @_protobuf_PC_REQUIRES@
Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@ Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@
Cflags: -I${includedir} Cflags: -I${includedir} @_protobuf_PC_CFLAGS@
Conflicts: protobuf-lite Conflicts: protobuf-lite

@ -2378,7 +2378,7 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() {
// String fields. // String fields.
RunValidJsonTest("StringField", REQUIRED, RunValidJsonTest("StringField", REQUIRED,
R"({"optionalString": "Hello world!"})", R"({"optionalString": "Hello world!"})",
"optional_string: \"Hello world!\""); R"(optional_string: "Hello world!")");
RunValidJsonTest("StringFieldUnicode", REQUIRED, RunValidJsonTest("StringFieldUnicode", REQUIRED,
// Google in Chinese. // Google in Chinese.
R"({"optionalString": ""})", R"({"optionalString": ""})",
@ -2397,6 +2397,9 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() {
// The character is an emoji: grinning face with smiling eyes. 😁 // The character is an emoji: grinning face with smiling eyes. 😁
R"({"optionalString": "\uD83D\uDE01"})", R"({"optionalString": "\uD83D\uDE01"})",
R"(optional_string: "\xF0\x9F\x98\x81")"); R"(optional_string: "\xF0\x9F\x98\x81")");
RunValidJsonTest("StringFieldEmbeddedNull", REQUIRED,
R"({"optionalString": "Hello\u0000world!"})",
R"(optional_string: "Hello\000world!")");
// Unicode escapes must start with "\u" (lowercase u). // Unicode escapes must start with "\u" (lowercase u).
ExpectParseFailureForJson("StringFieldUppercaseEscapeLetter", RECOMMENDED, ExpectParseFailureForJson("StringFieldUppercaseEscapeLetter", RECOMMENDED,

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title> <title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary> <summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description> <description>See project site for more info.</description>
<version>3.22.3</version> <version>3.23.0</version>
<authors>Google Inc.</authors> <authors>Google Inc.</authors>
<owners>protobuf-packages</owners> <owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl> <licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>

@ -73,7 +73,8 @@ $PROTOC -Isrc -I. \
src/google/protobuf/unittest_well_known_types.proto \ src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto \ src/google/protobuf/test_messages_proto3.proto \
src/google/protobuf/test_messages_proto2.proto \ src/google/protobuf/test_messages_proto2.proto \
src/google/protobuf/unittest_proto3_optional.proto src/google/protobuf/unittest_proto3_optional.proto \
src/google/protobuf/unittest_retention.proto
# AddressBook sample protos # AddressBook sample protos
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \ $PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \

@ -364,7 +364,7 @@ namespace Google.Protobuf.TestProtos.Proto2 {
"ZXNwb25zZSKSAQoMVGVzdEpzb25OYW1lEhMKC2ZpZWxkX25hbWUxGAEgASgF", "ZXNwb25zZSKSAQoMVGVzdEpzb25OYW1lEhMKC2ZpZWxkX25hbWUxGAEgASgF",
"EhIKCmZpZWxkTmFtZTIYAiABKAUSEgoKRmllbGROYW1lMxgDIAEoBRIUCgxf", "EhIKCmZpZWxkTmFtZTIYAiABKAUSEgoKRmllbGROYW1lMxgDIAEoBRIUCgxf",
"ZmllbGRfbmFtZTQYBCABKAUSEwoLRklFTERfTkFNRTUYBSABKAUSGgoLZmll", "ZmllbGRfbmFtZTQYBCABKAUSEwoLRklFTERfTkFNRTUYBSABKAUSGgoLZmll",
"bGRfbmFtZTYYBiABKAVSBUB0eXBlIvwGChRUZXN0SHVnZUZpZWxkTnVtYmVy", "bGRfbmFtZTYYBiABKAVSBUB0eXBlIqIGChRUZXN0SHVnZUZpZWxkTnVtYmVy",
"cxIaCg5vcHRpb25hbF9pbnQzMhjw+P//ASABKAUSFAoIZml4ZWRfMzIY8fj/", "cxIaCg5vcHRpb25hbF9pbnQzMhjw+P//ASABKAUSFAoIZml4ZWRfMzIY8fj/",
"/wEgASgFEh4KDnJlcGVhdGVkX2ludDMyGPL4//8BIAMoBUICEAASHAoMcGFj", "/wEgASgFEh4KDnJlcGVhdGVkX2ludDMyGPL4//8BIAMoBUICEAASHAoMcGFj",
"a2VkX2ludDMyGPP4//8BIAMoBUICEAESQAoNb3B0aW9uYWxfZW51bRj0+P//", "a2VkX2ludDMyGPP4//8BIAMoBUICEAESQAoNb3B0aW9uYWxfZW51bRj0+P//",
@ -381,10 +381,8 @@ namespace Google.Protobuf.TestProtos.Proto2 {
"Mi5UZXN0QWxsVHlwZXNIABIaCgxvbmVvZl9zdHJpbmcY/fj//wEgASgJSAAS", "Mi5UZXN0QWxsVHlwZXNIABIaCgxvbmVvZl9zdHJpbmcY/fj//wEgASgJSAAS",
"GQoLb25lb2ZfYnl0ZXMY/vj//wEgASgMSAAaJAoNT3B0aW9uYWxHcm91cBIT", "GQoLb25lb2ZfYnl0ZXMY/vj//wEgASgMSAAaJAoNT3B0aW9uYWxHcm91cBIT",
"Cgdncm91cF9hGPn4//8BIAEoBRo2ChRTdHJpbmdTdHJpbmdNYXBFbnRyeRIL", "Cgdncm91cF9hGPn4//8BIAEoBRo2ChRTdHJpbmdTdHJpbmdNYXBFbnRyeRIL",
"CgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBKmgI4Kr//wEQ8Pj//wEa", "CgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBKg4I4Kr//wEQ8Pj//wEa",
"WhJYCOCq//8BEigucHJvdG9idWZfdW5pdHRlc3RfcHJvdG8yLnRlc3RfYWxs", "AEINCgtvbmVvZl9maWVsZCKxAQoYVGVzdEV4dGVuc2lvbkluc2lkZVRhYmxl",
"X3R5cGVzGiYucHJvdG9idWZfdW5pdHRlc3RfcHJvdG8yLlRlc3RBbGxUeXBl",
"c0INCgtvbmVvZl9maWVsZCKxAQoYVGVzdEV4dGVuc2lvbkluc2lkZVRhYmxl",
"Eg4KBmZpZWxkMRgBIAEoBRIOCgZmaWVsZDIYAiABKAUSDgoGZmllbGQzGAMg", "Eg4KBmZpZWxkMRgBIAEoBRIOCgZmaWVsZDIYAiABKAUSDgoGZmllbGQzGAMg",
"ASgFEg4KBmZpZWxkNBgEIAEoBRIOCgZmaWVsZDYYBiABKAUSDgoGZmllbGQ3", "ASgFEg4KBmZpZWxkNBgEIAEoBRIOCgZmaWVsZDYYBiABKAUSDgoGZmllbGQ3",
"GAcgASgFEg4KBmZpZWxkOBgIIAEoBRIOCgZmaWVsZDkYCSABKAUSDwoHZmll", "GAcgASgFEg4KBmZpZWxkOBgIIAEoBRIOCgZmaWVsZDkYCSABKAUSDwoHZmll",

@ -38,18 +38,18 @@ namespace UnitTest.Issues.TestProtos {
"X09QVElPTl9FTlVNX1VOU1BFQ0lGSUVEEAASGgoWVEVTVF9PUFRJT05fRU5V", "X09QVElPTl9FTlVNX1VOU1BFQ0lGSUVEEAASGgoWVEVTVF9PUFRJT05fRU5V",
"TV9UWVBFMRAWEiMKFlRFU1RfT1BUSU9OX0VOVU1fVFlQRTIQ6f//////////", "TV9UWVBFMRAWEiMKFlRFU1RfT1BUSU9OX0VOVU1fVFlQRTIQ6f//////////",
"ASIhCh9EdW1teU1lc3NhZ2VJbnZhbGlkQXNPcHRpb25UeXBlIooBChxDdXN0", "ASIhCh9EdW1teU1lc3NhZ2VJbnZhbGlkQXNPcHRpb25UeXBlIooBChxDdXN0",
"b21PcHRpb25NaW5JbnRlZ2VyVmFsdWVzOmrQ3rIdAOjGsh2AgICA+P////8B", "b21PcHRpb25NaW5JbnRlZ2VyVmFsdWVzOmqZ1qgdAAAAAAAAAICtja8dAAAA",
"sLyyHYCAgICAgICAgAGAk7IdAPj1sB0AgMSwHf////8P+JewHf//////////", "gJHurx0AAAAAAAAAAJ31rx0AAAAA+JewHf///////////wGAxLAd/////w/4",
"/wGd9a8dAAAAAJHurx0AAAAAAAAAAK2Nrx0AAACAmdaoHQAAAAAAAACAIpEB", "9bAdAICTsh0AsLyyHYCAgICAgICAgAHoxrIdgICAgPj/////AdDesh0AIpEB",
"ChxDdXN0b21PcHRpb25NYXhJbnRlZ2VyVmFsdWVzOnHQ3rIdAejGsh3/////", "ChxDdXN0b21PcHRpb25NYXhJbnRlZ2VyVmFsdWVzOnGZ1qgd/////////3+t",
"B7C8sh3//////////3+Ak7Id/////w/49bAd////////////AYDEsB3+////", "ja8d////f5Hurx3//////////531rx3/////+JewHf7//////////wGAxLAd",
"D/iXsB3+//////////8BnfWvHf////+R7q8d//////////+tja8d////f5nW", "/v///w/49bAd////////////AYCTsh3/////D7C8sh3//////////3/oxrId",
"qB3/////////fyJuChdDdXN0b21PcHRpb25PdGhlclZhbHVlczpT6MayHZz/", "/////wfQ3rIdASJuChdDdXN0b21PcHRpb25PdGhlclZhbHVlczpTiNmiHen/",
"/////////wH136Md54dFQencoh37WYxCysDzP6rcoh0OSGVsbG8sICJXb3Js", "/////////wGy2aIdC0hlbGxvAFdvcmxkqtyiHQ5IZWxsbywgIldvcmxkIunc",
"ZCKy2aIdC0hlbGxvAFdvcmxkiNmiHen//////////wEiNAocU2V0dGluZ1Jl", "oh37WYxCysDzP/Xfox3nh0VB6MayHZz//////////wEiNAocU2V0dGluZ1Jl",
"YWxzRnJvbVBvc2l0aXZlSW50czoU9d+jHQAAQEHp3KIdAAAAAABAY0AiNAoc", "YWxzRnJvbVBvc2l0aXZlSW50czoU6dyiHQAAAAAAQGNA9d+jHQAAQEEiNAoc",
"U2V0dGluZ1JlYWxzRnJvbU5lZ2F0aXZlSW50czoU9d+jHQAAQMHp3KIdAAAA", "U2V0dGluZ1JlYWxzRnJvbU5lZ2F0aXZlSW50czoU6dyiHQAAAAAAQGPA9d+j",
"AABAY8AiSwoSQ29tcGxleE9wdGlvblR5cGUxEgsKA2ZvbxgBIAEoBRIMCgRm", "HQAAQMEiSwoSQ29tcGxleE9wdGlvblR5cGUxEgsKA2ZvbxgBIAEoBRIMCgRm",
"b28yGAIgASgFEgwKBGZvbzMYAyABKAUSDAoEZm9vNBgEIAMoBSKBAwoSQ29t", "b28yGAIgASgFEgwKBGZvbzMYAyABKAUSDAoEZm9vNBgEIAMoBSKBAwoSQ29t",
"cGxleE9wdGlvblR5cGUyEjIKA2JhchgBIAEoCzIlLnByb3RvYnVmX3VuaXR0", "cGxleE9wdGlvblR5cGUyEjIKA2JhchgBIAEoCzIlLnByb3RvYnVmX3VuaXR0",
"ZXN0LkNvbXBsZXhPcHRpb25UeXBlMRILCgNiYXoYAiABKAUSRgoEZnJlZBgD", "ZXN0LkNvbXBsZXhPcHRpb25UeXBlMRILCgNiYXoYAiABKAUSRgoEZnJlZBgD",
@ -60,83 +60,82 @@ namespace UnitTest.Issues.TestProtos {
"bXBsZXhfb3B0NBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiK", "bXBsZXhfb3B0NBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiK",
"9dEDIAEoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBsZXhPcHRpb25UeXBl", "9dEDIAEoCzI4LnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBsZXhPcHRpb25UeXBl",
"Mi5Db21wbGV4T3B0aW9uVHlwZTQiIQoSQ29tcGxleE9wdGlvblR5cGUzEgsK", "Mi5Db21wbGV4T3B0aW9uVHlwZTQiIQoSQ29tcGxleE9wdGlvblR5cGUzEgsK",
"A3F1eBgBIAEoBSJsChVWYXJpb3VzQ29tcGxleE9wdGlvbnM6U6LilR0CCCqi", "A3F1eBgBIAEoBSJOChVWYXJpb3VzQ29tcGxleE9wdGlvbnM6NdKojx0DCLMP",
"4pUdAiBjouKVHQIgWKr9kB0DENsHqv2QHQUKAwjnBdKojx0DCLMPqv2QHQUa", "+t6QHQIICar9kB0WCgMI5wUQ2wcaAwjBAiICCGUiAwjUAaLilR0GCCoiAmNY",
"AwjBAqr9kB0EIgIIZar9kB0FIgMI1AH63pAdAggJIkwKCUFnZ3JlZ2F0ZRIJ", "IkwKCUFnZ3JlZ2F0ZRIJCgFpGAEgASgFEgkKAXMYAiABKAkSKQoDc3ViGAMg",
"CgFpGAEgASgFEgkKAXMYAiABKAkSKQoDc3ViGAMgASgLMhwucHJvdG9idWZf", "ASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlIlkKEEFnZ3JlZ2F0",
"dW5pdHRlc3QuQWdncmVnYXRlIlkKEEFnZ3JlZ2F0ZU1lc3NhZ2USKQoJZmll", "ZU1lc3NhZ2USKQoJZmllbGRuYW1lGAEgASgFQhbyoYc7ERIPRmllbGRBbm5v",
"bGRuYW1lGAEgASgFQhbyoYc7ERIPRmllbGRBbm5vdGF0aW9uOhrC0YY7FQhl", "dGF0aW9uOhrC0YY7FQhlEhFNZXNzYWdlQW5ub3RhdGlvbiKXAQoQTmVzdGVk",
"EhFNZXNzYWdlQW5ub3RhdGlvbiKXAQoQTmVzdGVkT3B0aW9uVHlwZRo7Cg1O", "T3B0aW9uVHlwZRo7Cg1OZXN0ZWRNZXNzYWdlEiIKDG5lc3RlZF9maWVsZBgB",
"ZXN0ZWRNZXNzYWdlEiIKDG5lc3RlZF9maWVsZBgBIAEoBUIMweDDHeoDAAAA", "IAEoBUIMweDDHeoDAAAAAAAAOgbg6cId6QciRgoKTmVzdGVkRW51bRIPCgtV",
"AAAAOgbg6cId6QciRgoKTmVzdGVkRW51bRIPCgtVTlNQRUNJRklFRBAAEh0K", "TlNQRUNJRklFRBAAEh0KEU5FU1RFRF9FTlVNX1ZBTFVFEAEaBrCG+gXsBxoI",
"EU5FU1RFRF9FTlVNX1ZBTFVFEAEaBrCG+gXsBxoIxfbJHesDAAAqUgoKTWV0", "xfbJHesDAAAqUgoKTWV0aG9kT3B0MRIaChZNRVRIT0RPUFQxX1VOU1BFQ0lG",
"aG9kT3B0MRIaChZNRVRIT0RPUFQxX1VOU1BFQ0lGSUVEEAASEwoPTUVUSE9E", "SUVEEAASEwoPTUVUSE9ET1BUMV9WQUwxEAESEwoPTUVUSE9ET1BUMV9WQUwy",
"T1BUMV9WQUwxEAESEwoPTUVUSE9ET1BUMV9WQUwyEAIqXgoNQWdncmVnYXRl", "EAIqXgoNQWdncmVnYXRlRW51bRIPCgtVTlNQRUNJRklFRBAAEiUKBVZBTFVF",
"RW51bRIPCgtVTlNQRUNJRklFRBAAEiUKBVZBTFVFEAEaGsr8iTsVEhNFbnVt", "EAEaGsr8iTsVEhNFbnVtVmFsdWVBbm5vdGF0aW9uGhWSlYg7EBIORW51bUFu",
"VmFsdWVBbm5vdGF0aW9uGhWSlYg7EBIORW51bUFubm90YXRpb24yjgEKHFRl", "bm90YXRpb24yjgEKHFRlc3RTZXJ2aWNlV2l0aEN1c3RvbU9wdGlvbnMSYwoD",
"c3RTZXJ2aWNlV2l0aEN1c3RvbU9wdGlvbnMSYwoDRm9vEikucHJvdG9idWZf", "Rm9vEikucHJvdG9idWZfdW5pdHRlc3QuQ3VzdG9tT3B0aW9uRm9vUmVxdWVz",
"dW5pdHRlc3QuQ3VzdG9tT3B0aW9uRm9vUmVxdWVzdBoqLnByb3RvYnVmX3Vu", "dBoqLnByb3RvYnVmX3VuaXR0ZXN0LkN1c3RvbU9wdGlvbkZvb1Jlc3BvbnNl",
"aXR0ZXN0LkN1c3RvbU9wdGlvbkZvb1Jlc3BvbnNlIgXg+oweAhoJkLKLHtPb", "IgXg+oweAhoJkLKLHtPbgMtJMpkBChBBZ2dyZWdhdGVTZXJ2aWNlEmsKBk1l",
"gMtJMpkBChBBZ2dyZWdhdGVTZXJ2aWNlEmsKBk1ldGhvZBIjLnByb3RvYnVm", "dGhvZBIjLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZU1lc3NhZ2UaIy5w",
"X3VuaXR0ZXN0LkFnZ3JlZ2F0ZU1lc3NhZ2UaIy5wcm90b2J1Zl91bml0dGVz", "cm90b2J1Zl91bml0dGVzdC5BZ2dyZWdhdGVNZXNzYWdlIhfKyJY7EhIQTWV0",
"dC5BZ2dyZWdhdGVNZXNzYWdlIhfKyJY7EhIQTWV0aG9kQW5ub3RhdGlvbhoY", "aG9kQW5ub3RhdGlvbhoYyvuOOxMSEVNlcnZpY2VBbm5vdGF0aW9uOjIKCWZp",
"yvuOOxMSEVNlcnZpY2VBbm5vdGF0aW9uOjIKCWZpbGVfb3B0MRIcLmdvb2ds", "bGVfb3B0MRIcLmdvb2dsZS5wcm90b2J1Zi5GaWxlT3B0aW9ucxiOndgDIAEo",
"ZS5wcm90b2J1Zi5GaWxlT3B0aW9ucxiOndgDIAEoBDo4CgxtZXNzYWdlX29w", "BDo4CgxtZXNzYWdlX29wdDESHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9w",
"dDESHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYnK3YAyABKAU6", "dGlvbnMYnK3YAyABKAU6NAoKZmllbGRfb3B0MRIdLmdvb2dsZS5wcm90b2J1",
"NAoKZmllbGRfb3B0MRIdLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMY", "Zi5GaWVsZE9wdGlvbnMYiLzYAyABKAY6NAoKb25lb2Zfb3B0MRIdLmdvb2ds",
"iLzYAyABKAY6NAoKb25lb2Zfb3B0MRIdLmdvb2dsZS5wcm90b2J1Zi5PbmVv", "ZS5wcm90b2J1Zi5PbmVvZk9wdGlvbnMYz7XYAyABKAU6MgoJZW51bV9vcHQx",
"Zk9wdGlvbnMYz7XYAyABKAU6MgoJZW51bV9vcHQxEhwuZ29vZ2xlLnByb3Rv", "EhwuZ29vZ2xlLnByb3RvYnVmLkVudW1PcHRpb25zGOie2QMgASgPOjwKD2Vu",
"YnVmLkVudW1PcHRpb25zGOie2QMgASgPOjwKD2VudW1fdmFsdWVfb3B0MRIh", "dW1fdmFsdWVfb3B0MRIhLmdvb2dsZS5wcm90b2J1Zi5FbnVtVmFsdWVPcHRp",
"Lmdvb2dsZS5wcm90b2J1Zi5FbnVtVmFsdWVPcHRpb25zGOagXyABKAU6OAoM", "b25zGOagXyABKAU6OAoMc2VydmljZV9vcHQxEh8uZ29vZ2xlLnByb3RvYnVm",
"c2VydmljZV9vcHQxEh8uZ29vZ2xlLnByb3RvYnVmLlNlcnZpY2VPcHRpb25z", "LlNlcnZpY2VPcHRpb25zGKK24QMgASgSOlUKC21ldGhvZF9vcHQxEh4uZ29v",
"GKK24QMgASgSOlUKC21ldGhvZF9vcHQxEh4uZ29vZ2xlLnByb3RvYnVmLk1l", "Z2xlLnByb3RvYnVmLk1ldGhvZE9wdGlvbnMYrM/hAyABKA4yHS5wcm90b2J1",
"dGhvZE9wdGlvbnMYrM/hAyABKA4yHS5wcm90b2J1Zl91bml0dGVzdC5NZXRo", "Zl91bml0dGVzdC5NZXRob2RPcHQxOjQKCGJvb2xfb3B0Eh8uZ29vZ2xlLnBy",
"b2RPcHQxOjQKCGJvb2xfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VP", "b3RvYnVmLk1lc3NhZ2VPcHRpb25zGOqr1gMgASgIOjUKCWludDMyX29wdBIf",
"cHRpb25zGOqr1gMgASgIOjUKCWludDMyX29wdBIfLmdvb2dsZS5wcm90b2J1", "Lmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjtqNYDIAEoBTo1Cglp",
"Zi5NZXNzYWdlT3B0aW9ucxjtqNYDIAEoBTo1CglpbnQ2NF9vcHQSHy5nb29n", "bnQ2NF9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYxqfW",
"bGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYxqfWAyABKAM6NgoKdWludDMy", "AyABKAM6NgoKdWludDMyX29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdl",
"X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxiwotYDIAEo", "T3B0aW9ucxiwotYDIAEoDTo2Cgp1aW50NjRfb3B0Eh8uZ29vZ2xlLnByb3Rv",
"DTo2Cgp1aW50NjRfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp", "YnVmLk1lc3NhZ2VPcHRpb25zGN+O1gMgASgEOjYKCnNpbnQzMl9vcHQSHy5n",
"b25zGN+O1gMgASgEOjYKCnNpbnQzMl9vcHQSHy5nb29nbGUucHJvdG9idWYu", "b29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYwIjWAyABKBE6NgoKc2lu",
"TWVzc2FnZU9wdGlvbnMYwIjWAyABKBE6NgoKc2ludDY0X29wdBIfLmdvb2ds", "dDY0X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxj/gtYD",
"ZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxj/gtYDIAEoEjo3CgtmaXhlZDMy", "IAEoEjo3CgtmaXhlZDMyX29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdl",
"X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxjT/tUDIAEo", "T3B0aW9ucxjT/tUDIAEoBzo3CgtmaXhlZDY0X29wdBIfLmdvb2dsZS5wcm90",
"Bzo3CgtmaXhlZDY0X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0", "b2J1Zi5NZXNzYWdlT3B0aW9ucxji/dUDIAEoBjo4CgxzZml4ZWQzMl9vcHQS",
"aW9ucxji/dUDIAEoBjo4CgxzZml4ZWQzMl9vcHQSHy5nb29nbGUucHJvdG9i", "Hy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMY1fHVAyABKA86OAoM",
"dWYuTWVzc2FnZU9wdGlvbnMY1fHVAyABKA86OAoMc2ZpeGVkNjRfb3B0Eh8u", "c2ZpeGVkNjRfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25z",
"Z29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGOOK1QMgASgQOjUKCWZs", "GOOK1QMgASgQOjUKCWZsb2F0X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNz",
"b2F0X29wdBIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxj+u9QD", "YWdlT3B0aW9ucxj+u9QDIAEoAjo2Cgpkb3VibGVfb3B0Eh8uZ29vZ2xlLnBy",
"IAEoAjo2Cgpkb3VibGVfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VP", "b3RvYnVmLk1lc3NhZ2VPcHRpb25zGM2r1AMgASgBOjYKCnN0cmluZ19vcHQS",
"cHRpb25zGM2r1AMgASgBOjYKCnN0cmluZ19vcHQSHy5nb29nbGUucHJvdG9i", "Hy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYxavUAyABKAk6NQoJ",
"dWYuTWVzc2FnZU9wdGlvbnMYxavUAyABKAk6NQoJYnl0ZXNfb3B0Eh8uZ29v", "Ynl0ZXNfb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGJar",
"Z2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGJar1AMgASgMOnAKCGVudW1f", "1AMgASgMOnAKCGVudW1fb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VP",
"b3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGJGr1AMgASgO", "cHRpb25zGJGr1AMgASgOMjoucHJvdG9idWZfdW5pdHRlc3QuRHVtbXlNZXNz",
"MjoucHJvdG9idWZfdW5pdHRlc3QuRHVtbXlNZXNzYWdlQ29udGFpbmluZ0Vu", "YWdlQ29udGFpbmluZ0VudW0uVGVzdEVudW1UeXBlOnAKEG1lc3NhZ2VfdHlw",
"dW0uVGVzdEVudW1UeXBlOnAKEG1lc3NhZ2VfdHlwZV9vcHQSHy5nb29nbGUu", "ZV9vcHQSHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYr/LTAyAB",
"cHJvdG9idWYuTWVzc2FnZU9wdGlvbnMYr/LTAyABKAsyMi5wcm90b2J1Zl91", "KAsyMi5wcm90b2J1Zl91bml0dGVzdC5EdW1teU1lc3NhZ2VJbnZhbGlkQXNP",
"bml0dGVzdC5EdW1teU1lc3NhZ2VJbnZhbGlkQXNPcHRpb25UeXBlOl8KDGNv", "cHRpb25UeXBlOl8KDGNvbXBsZXhfb3B0MRIfLmdvb2dsZS5wcm90b2J1Zi5N",
"bXBsZXhfb3B0MRIfLmdvb2dsZS5wcm90b2J1Zi5NZXNzYWdlT3B0aW9ucxik", "ZXNzYWdlT3B0aW9ucxik3NIDIAEoCzIlLnByb3RvYnVmX3VuaXR0ZXN0LkNv",
"3NIDIAEoCzIlLnByb3RvYnVmX3VuaXR0ZXN0LkNvbXBsZXhPcHRpb25UeXBl", "bXBsZXhPcHRpb25UeXBlMTpfCgxjb21wbGV4X29wdDISHy5nb29nbGUucHJv",
"MTpfCgxjb21wbGV4X29wdDISHy5nb29nbGUucHJvdG9idWYuTWVzc2FnZU9w", "dG9idWYuTWVzc2FnZU9wdGlvbnMY1Y/SAyABKAsyJS5wcm90b2J1Zl91bml0",
"dGlvbnMY1Y/SAyABKAsyJS5wcm90b2J1Zl91bml0dGVzdC5Db21wbGV4T3B0", "dGVzdC5Db21wbGV4T3B0aW9uVHlwZTI6XwoMY29tcGxleF9vcHQzEh8uZ29v",
"aW9uVHlwZTI6XwoMY29tcGxleF9vcHQzEh8uZ29vZ2xlLnByb3RvYnVmLk1l", "Z2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRpb25zGO+L0gMgASgLMiUucHJvdG9i",
"c3NhZ2VPcHRpb25zGO+L0gMgASgLMiUucHJvdG9idWZfdW5pdHRlc3QuQ29t", "dWZfdW5pdHRlc3QuQ29tcGxleE9wdGlvblR5cGUzOk4KB2ZpbGVvcHQSHC5n",
"cGxleE9wdGlvblR5cGUzOk4KB2ZpbGVvcHQSHC5nb29nbGUucHJvdG9idWYu", "b29nbGUucHJvdG9idWYuRmlsZU9wdGlvbnMYz92wByABKAsyHC5wcm90b2J1",
"RmlsZU9wdGlvbnMYz92wByABKAsyHC5wcm90b2J1Zl91bml0dGVzdC5BZ2dy", "Zl91bml0dGVzdC5BZ2dyZWdhdGU6UAoGbXNnb3B0Eh8uZ29vZ2xlLnByb3Rv",
"ZWdhdGU6UAoGbXNnb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLk1lc3NhZ2VPcHRp", "YnVmLk1lc3NhZ2VPcHRpb25zGJjqsAcgASgLMhwucHJvdG9idWZfdW5pdHRl",
"b25zGJjqsAcgASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlAK", "c3QuQWdncmVnYXRlOlAKCGZpZWxkb3B0Eh0uZ29vZ2xlLnByb3RvYnVmLkZp",
"CGZpZWxkb3B0Eh0uZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucxie9LAH", "ZWxkT3B0aW9ucxie9LAHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3Jl",
"IAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZTpOCgdlbnVtb3B0", "Z2F0ZTpOCgdlbnVtb3B0EhwuZ29vZ2xlLnByb3RvYnVmLkVudW1PcHRpb25z",
"EhwuZ29vZ2xlLnByb3RvYnVmLkVudW1PcHRpb25zGNKCsQcgASgLMhwucHJv", "GNKCsQcgASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlYKCmVu",
"dG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlYKCmVudW12YWxvcHQSIS5nb29n", "dW12YWxvcHQSIS5nb29nbGUucHJvdG9idWYuRW51bVZhbHVlT3B0aW9ucxjJ",
"bGUucHJvdG9idWYuRW51bVZhbHVlT3B0aW9ucxjJn7EHIAEoCzIcLnByb3Rv", "n7EHIAEoCzIcLnByb3RvYnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZTpUCgpzZXJ2",
"YnVmX3VuaXR0ZXN0LkFnZ3JlZ2F0ZTpUCgpzZXJ2aWNlb3B0Eh8uZ29vZ2xl", "aWNlb3B0Eh8uZ29vZ2xlLnByb3RvYnVmLlNlcnZpY2VPcHRpb25zGLnvsQcg",
"LnByb3RvYnVmLlNlcnZpY2VPcHRpb25zGLnvsQcgASgLMhwucHJvdG9idWZf", "ASgLMhwucHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlOlIKCW1ldGhvZG9w",
"dW5pdHRlc3QuQWdncmVnYXRlOlIKCW1ldGhvZG9wdBIeLmdvb2dsZS5wcm90", "dBIeLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zGInpsgcgASgLMhwu",
"b2J1Zi5NZXRob2RPcHRpb25zGInpsgcgASgLMhwucHJvdG9idWZfdW5pdHRl", "cHJvdG9idWZfdW5pdHRlc3QuQWdncmVnYXRlQlWqAhpVbml0VGVzdC5Jc3N1",
"c3QuQWdncmVnYXRlQlWqAhpVbml0VGVzdC5Jc3N1ZXMuVGVzdFByb3Rvc/Do", "ZXMuVGVzdFByb3Rvc/DowR3qrcDlJPrshTsqCGQSDkZpbGVBbm5vdGF0aW9u",
"wR3qrcDlJPrshTsqCGQSDkZpbGVBbm5vdGF0aW9uGhYSFE5lc3RlZEZpbGVB", "GhYSFE5lc3RlZEZpbGVBbm5vdGF0aW9uYgZwcm90bzM="));
"bm5vdGF0aW9uYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, }, new pbr::FileDescriptor[] { global::Google.Protobuf.Reflection.DescriptorReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.MethodOpt1), typeof(global::UnitTest.Issues.TestProtos.AggregateEnum), }, new pb::Extension[] { UnittestCustomOptionsProto3Extensions.FileOpt1, UnittestCustomOptionsProto3Extensions.MessageOpt1, UnittestCustomOptionsProto3Extensions.FieldOpt1, UnittestCustomOptionsProto3Extensions.OneofOpt1, UnittestCustomOptionsProto3Extensions.EnumOpt1, UnittestCustomOptionsProto3Extensions.EnumValueOpt1, UnittestCustomOptionsProto3Extensions.ServiceOpt1, UnittestCustomOptionsProto3Extensions.MethodOpt1, UnittestCustomOptionsProto3Extensions.BoolOpt, UnittestCustomOptionsProto3Extensions.Int32Opt, UnittestCustomOptionsProto3Extensions.Int64Opt, UnittestCustomOptionsProto3Extensions.Uint32Opt, UnittestCustomOptionsProto3Extensions.Uint64Opt, UnittestCustomOptionsProto3Extensions.Sint32Opt, UnittestCustomOptionsProto3Extensions.Sint64Opt, UnittestCustomOptionsProto3Extensions.Fixed32Opt, UnittestCustomOptionsProto3Extensions.Fixed64Opt, UnittestCustomOptionsProto3Extensions.Sfixed32Opt, UnittestCustomOptionsProto3Extensions.Sfixed64Opt, UnittestCustomOptionsProto3Extensions.FloatOpt, UnittestCustomOptionsProto3Extensions.DoubleOpt, UnittestCustomOptionsProto3Extensions.StringOpt, UnittestCustomOptionsProto3Extensions.BytesOpt, UnittestCustomOptionsProto3Extensions.EnumOpt, UnittestCustomOptionsProto3Extensions.MessageTypeOpt, UnittestCustomOptionsProto3Extensions.ComplexOpt1, UnittestCustomOptionsProto3Extensions.ComplexOpt2, UnittestCustomOptionsProto3Extensions.ComplexOpt3, UnittestCustomOptionsProto3Extensions.Fileopt, UnittestCustomOptionsProto3Extensions.Msgopt, UnittestCustomOptionsProto3Extensions.Fieldopt, UnittestCustomOptionsProto3Extensions.Enumopt, UnittestCustomOptionsProto3Extensions.Enumvalopt, UnittestCustomOptionsProto3Extensions.Serviceopt, UnittestCustomOptionsProto3Extensions.Methodopt }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.MethodOpt1), typeof(global::UnitTest.Issues.TestProtos.AggregateEnum), }, new pb::Extension[] { UnittestCustomOptionsProto3Extensions.FileOpt1, UnittestCustomOptionsProto3Extensions.MessageOpt1, UnittestCustomOptionsProto3Extensions.FieldOpt1, UnittestCustomOptionsProto3Extensions.OneofOpt1, UnittestCustomOptionsProto3Extensions.EnumOpt1, UnittestCustomOptionsProto3Extensions.EnumValueOpt1, UnittestCustomOptionsProto3Extensions.ServiceOpt1, UnittestCustomOptionsProto3Extensions.MethodOpt1, UnittestCustomOptionsProto3Extensions.BoolOpt, UnittestCustomOptionsProto3Extensions.Int32Opt, UnittestCustomOptionsProto3Extensions.Int64Opt, UnittestCustomOptionsProto3Extensions.Uint32Opt, UnittestCustomOptionsProto3Extensions.Uint64Opt, UnittestCustomOptionsProto3Extensions.Sint32Opt, UnittestCustomOptionsProto3Extensions.Sint64Opt, UnittestCustomOptionsProto3Extensions.Fixed32Opt, UnittestCustomOptionsProto3Extensions.Fixed64Opt, UnittestCustomOptionsProto3Extensions.Sfixed32Opt, UnittestCustomOptionsProto3Extensions.Sfixed64Opt, UnittestCustomOptionsProto3Extensions.FloatOpt, UnittestCustomOptionsProto3Extensions.DoubleOpt, UnittestCustomOptionsProto3Extensions.StringOpt, UnittestCustomOptionsProto3Extensions.BytesOpt, UnittestCustomOptionsProto3Extensions.EnumOpt, UnittestCustomOptionsProto3Extensions.MessageTypeOpt, UnittestCustomOptionsProto3Extensions.ComplexOpt1, UnittestCustomOptionsProto3Extensions.ComplexOpt2, UnittestCustomOptionsProto3Extensions.ComplexOpt3, UnittestCustomOptionsProto3Extensions.Fileopt, UnittestCustomOptionsProto3Extensions.Msgopt, UnittestCustomOptionsProto3Extensions.Fieldopt, UnittestCustomOptionsProto3Extensions.Enumopt, UnittestCustomOptionsProto3Extensions.Enumvalopt, UnittestCustomOptionsProto3Extensions.Serviceopt, UnittestCustomOptionsProto3Extensions.Methodopt }, new pbr::GeneratedClrTypeInfo[] {

@ -462,6 +462,21 @@ namespace Google.Protobuf.Reflection
} }
} }
[Test]
public void OptionRetention()
{
var proto = UnittestRetentionReflection.Descriptor.Proto;
Assert.AreEqual(1, proto.Options.GetExtension(
UnittestRetentionExtensions.PlainOption));
Assert.AreEqual(2, proto.Options.GetExtension(
UnittestRetentionExtensions.RuntimeRetentionOption));
// This option has a value of 3 in the .proto file, but we expect it
// to be zeroed out in the generated descriptor since it has source
// retention.
Assert.AreEqual(0, proto.Options.GetExtension(
UnittestRetentionExtensions.SourceRetentionOption));
}
private static void TestDescriptorToProto(Func<IMessage> toProtoFunction, IMessage expectedProto) private static void TestDescriptorToProto(Func<IMessage> toProtoFunction, IMessage expectedProto)
{ {
var clone1 = toProtoFunction(); var clone1 = toProtoFunction();

@ -5,7 +5,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright> <Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.22.3</VersionPrefix> <VersionPrefix>3.23.0</VersionPrefix>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<Authors>Google Inc.</Authors> <Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks> <TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks>

@ -122,7 +122,7 @@ namespace Google.Protobuf.Reflection {
"GAcgASgIEjIKJmRlcHJlY2F0ZWRfbGVnYWN5X2pzb25fZmllbGRfY29uZmxp", "GAcgASgIEjIKJmRlcHJlY2F0ZWRfbGVnYWN5X2pzb25fZmllbGRfY29uZmxp",
"Y3RzGAsgASgIQgIYARJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsy", "Y3RzGAsgASgIQgIYARJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsy",
"JC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICA", "JC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICA",
"gIACSgQIBBAFSgQIBRAGSgQIBhAHSgQICBAJSgQICRAKIogICgxGaWVsZE9w", "gIACSgQIBBAFSgQIBRAGSgQIBhAHSgQICBAJSgQICRAKIpwICgxGaWVsZE9w",
"dGlvbnMSOgoFY3R5cGUYASABKA4yIy5nb29nbGUucHJvdG9idWYuRmllbGRP", "dGlvbnMSOgoFY3R5cGUYASABKA4yIy5nb29nbGUucHJvdG9idWYuRmllbGRP",
"cHRpb25zLkNUeXBlOgZTVFJJTkcSDgoGcGFja2VkGAIgASgIEj8KBmpzdHlw", "cHRpb25zLkNUeXBlOgZTVFJJTkcSDgoGcGFja2VkGAIgASgIEj8KBmpzdHlw",
"ZRgGIAEoDjIkLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuSlNUeXBl", "ZRgGIAEoDjIkLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuSlNUeXBl",
@ -130,62 +130,62 @@ namespace Google.Protobuf.Reflection {
"ZF9sYXp5GA8gASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz", "ZF9sYXp5GA8gASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxz",
"ZRITCgR3ZWFrGAogASgIOgVmYWxzZRIbCgxkZWJ1Z19yZWRhY3QYECABKAg6", "ZRITCgR3ZWFrGAogASgIOgVmYWxzZRIbCgxkZWJ1Z19yZWRhY3QYECABKAg6",
"BWZhbHNlEkAKCXJldGVudGlvbhgRIAEoDjItLmdvb2dsZS5wcm90b2J1Zi5G", "BWZhbHNlEkAKCXJldGVudGlvbhgRIAEoDjItLmdvb2dsZS5wcm90b2J1Zi5G",
"aWVsZE9wdGlvbnMuT3B0aW9uUmV0ZW50aW9uEkIKBnRhcmdldBgSIAEoDjIu", "aWVsZE9wdGlvbnMuT3B0aW9uUmV0ZW50aW9uEj8KB3RhcmdldHMYEyADKA4y",
"Lmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuT3B0aW9uVGFyZ2V0VHlw", "Li5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zLk9wdGlvblRhcmdldFR5",
"ZUICGAESPwoHdGFyZ2V0cxgTIAMoDjIuLmdvb2dsZS5wcm90b2J1Zi5GaWVs", "cGUSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy",
"ZE9wdGlvbnMuT3B0aW9uVGFyZ2V0VHlwZRJDChR1bmludGVycHJldGVkX29w", "b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24SVgoadGFyZ2V0X29ic29sZXRl",
"X2RvX25vdF91c2UYEiABKA4yLi5nb29nbGUucHJvdG9idWYuRmllbGRPcHRp",
"b25zLk9wdGlvblRhcmdldFR5cGVCAhgBIi8KBUNUeXBlEgoKBlNUUklORxAA",
"EggKBENPUkQQARIQCgxTVFJJTkdfUElFQ0UQAiI1CgZKU1R5cGUSDQoJSlNf",
"Tk9STUFMEAASDQoJSlNfU1RSSU5HEAESDQoJSlNfTlVNQkVSEAIiVQoPT3B0",
"aW9uUmV0ZW50aW9uEhUKEVJFVEVOVElPTl9VTktOT1dOEAASFQoRUkVURU5U",
"SU9OX1JVTlRJTUUQARIUChBSRVRFTlRJT05fU09VUkNFEAIijAIKEE9wdGlv",
"blRhcmdldFR5cGUSFwoTVEFSR0VUX1RZUEVfVU5LTk9XThAAEhQKEFRBUkdF",
"VF9UWVBFX0ZJTEUQARIfChtUQVJHRVRfVFlQRV9FWFRFTlNJT05fUkFOR0UQ",
"AhIXChNUQVJHRVRfVFlQRV9NRVNTQUdFEAMSFQoRVEFSR0VUX1RZUEVfRklF",
"TEQQBBIVChFUQVJHRVRfVFlQRV9PTkVPRhAFEhQKEFRBUkdFVF9UWVBFX0VO",
"VU0QBhIaChZUQVJHRVRfVFlQRV9FTlVNX0VOVFJZEAcSFwoTVEFSR0VUX1RZ",
"UEVfU0VSVklDRRAIEhYKElRBUkdFVF9UWVBFX01FVEhPRBAJKgkI6AcQgICA",
"gAJKBAgEEAUiXgoMT25lb2ZPcHRpb25zEkMKFHVuaW50ZXJwcmV0ZWRfb3B0",
"aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0",
"aW9uKgkI6AcQgICAgAIixwEKC0VudW1PcHRpb25zEhMKC2FsbG93X2FsaWFz",
"GAIgASgIEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEjIKJmRlcHJlY2F0",
"ZWRfbGVnYWN5X2pzb25fZmllbGRfY29uZmxpY3RzGAYgASgIQgIYARJDChR1",
"bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu",
"VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACSgQIBRAGIn0KEEVudW1W",
"YWx1ZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBgBIAEoCDoFZmFsc2USQwoUdW5p",
"bnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVu",
"aW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiJ7Cg5TZXJ2aWNlT3B0aW9u",
"cxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVk",
"X29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRl",
"ZE9wdGlvbioJCOgHEICAgIACIq0CCg1NZXRob2RPcHRpb25zEhkKCmRlcHJl",
"Y2F0ZWQYISABKAg6BWZhbHNlEl8KEWlkZW1wb3RlbmN5X2xldmVsGCIgASgO",
"Mi8uZ29vZ2xlLnByb3RvYnVmLk1ldGhvZE9wdGlvbnMuSWRlbXBvdGVuY3lM",
"ZXZlbDoTSURFTVBPVEVOQ1lfVU5LTk9XThJDChR1bmludGVycHJldGVkX29w",
"dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w", "dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w",
"dGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoMU1RSSU5H", "dGlvbiJQChBJZGVtcG90ZW5jeUxldmVsEhcKE0lERU1QT1RFTkNZX1VOS05P",
"X1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpTX1NUUklO", "V04QABITCg9OT19TSURFX0VGRkVDVFMQARIOCgpJREVNUE9URU5UEAIqCQjo",
"RxABEg0KCUpTX05VTUJFUhACIlUKD09wdGlvblJldGVudGlvbhIVChFSRVRF", "BxCAgICAAiKeAgoTVW5pbnRlcnByZXRlZE9wdGlvbhI7CgRuYW1lGAIgAygL",
"TlRJT05fVU5LTk9XThAAEhUKEVJFVEVOVElPTl9SVU5USU1FEAESFAoQUkVU", "Mi0uZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24uTmFtZVBh",
"RU5USU9OX1NPVVJDRRACIowCChBPcHRpb25UYXJnZXRUeXBlEhcKE1RBUkdF", "cnQSGAoQaWRlbnRpZmllcl92YWx1ZRgDIAEoCRIaChJwb3NpdGl2ZV9pbnRf",
"VF9UWVBFX1VOS05PV04QABIUChBUQVJHRVRfVFlQRV9GSUxFEAESHwobVEFS", "dmFsdWUYBCABKAQSGgoSbmVnYXRpdmVfaW50X3ZhbHVlGAUgASgDEhQKDGRv",
"R0VUX1RZUEVfRVhURU5TSU9OX1JBTkdFEAISFwoTVEFSR0VUX1RZUEVfTUVT", "dWJsZV92YWx1ZRgGIAEoARIUCgxzdHJpbmdfdmFsdWUYByABKAwSFwoPYWdn",
"U0FHRRADEhUKEVRBUkdFVF9UWVBFX0ZJRUxEEAQSFQoRVEFSR0VUX1RZUEVf", "cmVnYXRlX3ZhbHVlGAggASgJGjMKCE5hbWVQYXJ0EhEKCW5hbWVfcGFydBgB",
"T05FT0YQBRIUChBUQVJHRVRfVFlQRV9FTlVNEAYSGgoWVEFSR0VUX1RZUEVf", "IAIoCRIUCgxpc19leHRlbnNpb24YAiACKAgi1QEKDlNvdXJjZUNvZGVJbmZv",
"RU5VTV9FTlRSWRAHEhcKE1RBUkdFVF9UWVBFX1NFUlZJQ0UQCBIWChJUQVJH", "EjoKCGxvY2F0aW9uGAEgAygLMiguZ29vZ2xlLnByb3RvYnVmLlNvdXJjZUNv",
"RVRfVFlQRV9NRVRIT0QQCSoJCOgHEICAgIACSgQIBBAFIl4KDE9uZW9mT3B0", "ZGVJbmZvLkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygFQgIQ",
"aW9ucxJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUu", "ARIQCgRzcGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMgASgJ",
"cHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACIscBCgtF", "EhkKEXRyYWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0YWNo",
"bnVtT3B0aW9ucxITCgthbGxvd19hbGlhcxgCIAEoCBIZCgpkZXByZWNhdGVk", "ZWRfY29tbWVudHMYBiADKAkinAIKEUdlbmVyYXRlZENvZGVJbmZvEkEKCmFu",
"GAMgASgIOgVmYWxzZRIyCiZkZXByZWNhdGVkX2xlZ2FjeV9qc29uX2ZpZWxk", "bm90YXRpb24YASADKAsyLS5nb29nbGUucHJvdG9idWYuR2VuZXJhdGVkQ29k",
"X2NvbmZsaWN0cxgGIAEoCEICGAESQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y", "ZUluZm8uQW5ub3RhdGlvbhrDAQoKQW5ub3RhdGlvbhIQCgRwYXRoGAEgAygF",
"5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24q", "QgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgViZWdpbhgDIAEoBRILCgNl",
"CQjoBxCAgICAAkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJl", "bmQYBCABKAUSSAoIc2VtYW50aWMYBSABKA4yNi5nb29nbGUucHJvdG9idWYu",
"Y2F0ZWQYASABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcH", "R2VuZXJhdGVkQ29kZUluZm8uQW5ub3RhdGlvbi5TZW1hbnRpYyIoCghTZW1h",
"IAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI", "bnRpYxIICgROT05FEAASBwoDU0VUEAESCQoFQUxJQVMQAkJ+ChNjb20uZ29v",
"6AcQgICAgAIiewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEo", "Z2xlLnByb3RvYnVmQhBEZXNjcmlwdG9yUHJvdG9zSAFaLWdvb2dsZS5nb2xh",
"CDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29v", "bmcub3JnL3Byb3RvYnVmL3R5cGVzL2Rlc2NyaXB0b3JwYvgBAaICA0dQQqoC",
"Z2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKt", "Gkdvb2dsZS5Qcm90b2J1Zi5SZWZsZWN0aW9u"));
"AgoNTWV0aG9kT3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJf",
"ChFpZGVtcG90ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5N",
"ZXRob2RPcHRpb25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VO",
"S05PV04SQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xl",
"LnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lM",
"ZXZlbBIXChNJREVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZF",
"Q1RTEAESDgoKSURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJw",
"cmV0ZWRPcHRpb24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5V",
"bmludGVycHJldGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFs",
"dWUYAyABKAkSGgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0",
"aXZlX2ludF92YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoM",
"c3RyaW5nX3ZhbHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRoz",
"CghOYW1lUGFydBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9u",
"GAIgAigIItUBCg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIo",
"Lmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoI",
"TG9jYXRpb24SEAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAES",
"GAoQbGVhZGluZ19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50",
"cxgEIAEoCRIhChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIpwC",
"ChFHZW5lcmF0ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29v",
"Z2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24awwEK",
"CkFubm90YXRpb24SEAoEcGF0aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUY",
"AiABKAkSDQoFYmVnaW4YAyABKAUSCwoDZW5kGAQgASgFEkgKCHNlbWFudGlj",
"GAUgASgOMjYuZ29vZ2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJbmZvLkFu",
"bm90YXRpb24uU2VtYW50aWMiKAoIU2VtYW50aWMSCAoETk9ORRAAEgcKA1NF",
"VBABEgkKBUFMSUFTEAJCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3Jp",
"cHRvclByb3Rvc0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBl",
"cy9kZXNjcmlwdG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVm",
"bGVjdGlvbg=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
@ -202,7 +202,7 @@ namespace Google.Protobuf.Reflection {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "PhpMetadataNamespace", "RubyPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "PhpMetadataNamespace", "RubyPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "DeprecatedLegacyJsonFieldConflicts", "UninterpretedOption" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "DeprecatedLegacyJsonFieldConflicts", "UninterpretedOption" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "UnverifiedLazy", "Deprecated", "Weak", "DebugRedact", "Retention", "Target", "Targets", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.OptionRetention), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "UnverifiedLazy", "Deprecated", "Weak", "DebugRedact", "Retention", "Targets", "UninterpretedOption", "TargetObsoleteDoNotUse" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.OptionRetention), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "DeprecatedLegacyJsonFieldConflicts", "UninterpretedOption" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "DeprecatedLegacyJsonFieldConflicts", "UninterpretedOption" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null, null),
@ -7698,9 +7698,9 @@ namespace Google.Protobuf.Reflection {
weak_ = other.weak_; weak_ = other.weak_;
debugRedact_ = other.debugRedact_; debugRedact_ = other.debugRedact_;
retention_ = other.retention_; retention_ = other.retention_;
target_ = other.target_;
targets_ = other.targets_.Clone(); targets_ = other.targets_.Clone();
uninterpretedOption_ = other.uninterpretedOption_.Clone(); uninterpretedOption_ = other.uninterpretedOption_.Clone();
targetObsoleteDoNotUse_ = other.targetObsoleteDoNotUse_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
_extensions = pb::ExtensionSet.Clone(other._extensions); _extensions = pb::ExtensionSet.Clone(other._extensions);
} }
@ -8032,36 +8032,6 @@ namespace Google.Protobuf.Reflection {
_hasBits0 &= ~256; _hasBits0 &= ~256;
} }
/// <summary>Field number for the "target" field.</summary>
public const int TargetFieldNumber = 18;
private readonly static global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType TargetDefaultValue = global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType.TargetTypeUnknown;
private global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType target_;
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType Target {
get { if ((_hasBits0 & 512) != 0) { return target_; } else { return TargetDefaultValue; } }
set {
_hasBits0 |= 512;
target_ = value;
}
}
/// <summary>Gets whether the "target" field is set</summary>
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool HasTarget {
get { return (_hasBits0 & 512) != 0; }
}
/// <summary>Clears the value of the "target" field</summary>
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void ClearTarget() {
_hasBits0 &= ~512;
}
/// <summary>Field number for the "targets" field.</summary> /// <summary>Field number for the "targets" field.</summary>
public const int TargetsFieldNumber = 19; public const int TargetsFieldNumber = 19;
private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType> _repeated_targets_codec private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType> _repeated_targets_codec
@ -8087,6 +8057,36 @@ namespace Google.Protobuf.Reflection {
get { return uninterpretedOption_; } get { return uninterpretedOption_; }
} }
/// <summary>Field number for the "target_obsolete_do_not_use" field.</summary>
public const int TargetObsoleteDoNotUseFieldNumber = 18;
private readonly static global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType TargetObsoleteDoNotUseDefaultValue = global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType.TargetTypeUnknown;
private global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType targetObsoleteDoNotUse_;
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType TargetObsoleteDoNotUse {
get { if ((_hasBits0 & 512) != 0) { return targetObsoleteDoNotUse_; } else { return TargetObsoleteDoNotUseDefaultValue; } }
set {
_hasBits0 |= 512;
targetObsoleteDoNotUse_ = value;
}
}
/// <summary>Gets whether the "target_obsolete_do_not_use" field is set</summary>
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool HasTargetObsoleteDoNotUse {
get { return (_hasBits0 & 512) != 0; }
}
/// <summary>Clears the value of the "target_obsolete_do_not_use" field</summary>
[global::System.ObsoleteAttribute]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void ClearTargetObsoleteDoNotUse() {
_hasBits0 &= ~512;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) { public override bool Equals(object other) {
@ -8111,9 +8111,9 @@ namespace Google.Protobuf.Reflection {
if (Weak != other.Weak) return false; if (Weak != other.Weak) return false;
if (DebugRedact != other.DebugRedact) return false; if (DebugRedact != other.DebugRedact) return false;
if (Retention != other.Retention) return false; if (Retention != other.Retention) return false;
if (Target != other.Target) return false;
if(!targets_.Equals(other.targets_)) return false; if(!targets_.Equals(other.targets_)) return false;
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
if (TargetObsoleteDoNotUse != other.TargetObsoleteDoNotUse) return false;
if (!Equals(_extensions, other._extensions)) { if (!Equals(_extensions, other._extensions)) {
return false; return false;
} }
@ -8133,9 +8133,9 @@ namespace Google.Protobuf.Reflection {
if (HasWeak) hash ^= Weak.GetHashCode(); if (HasWeak) hash ^= Weak.GetHashCode();
if (HasDebugRedact) hash ^= DebugRedact.GetHashCode(); if (HasDebugRedact) hash ^= DebugRedact.GetHashCode();
if (HasRetention) hash ^= Retention.GetHashCode(); if (HasRetention) hash ^= Retention.GetHashCode();
if (HasTarget) hash ^= Target.GetHashCode();
hash ^= targets_.GetHashCode(); hash ^= targets_.GetHashCode();
hash ^= uninterpretedOption_.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode();
if (HasTargetObsoleteDoNotUse) hash ^= TargetObsoleteDoNotUse.GetHashCode();
if (_extensions != null) { if (_extensions != null) {
hash ^= _extensions.GetHashCode(); hash ^= _extensions.GetHashCode();
} }
@ -8193,9 +8193,9 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(136, 1); output.WriteRawTag(136, 1);
output.WriteEnum((int) Retention); output.WriteEnum((int) Retention);
} }
if (HasTarget) { if (HasTargetObsoleteDoNotUse) {
output.WriteRawTag(144, 1); output.WriteRawTag(144, 1);
output.WriteEnum((int) Target); output.WriteEnum((int) TargetObsoleteDoNotUse);
} }
targets_.WriteTo(output, _repeated_targets_codec); targets_.WriteTo(output, _repeated_targets_codec);
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
@ -8248,9 +8248,9 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(136, 1); output.WriteRawTag(136, 1);
output.WriteEnum((int) Retention); output.WriteEnum((int) Retention);
} }
if (HasTarget) { if (HasTargetObsoleteDoNotUse) {
output.WriteRawTag(144, 1); output.WriteRawTag(144, 1);
output.WriteEnum((int) Target); output.WriteEnum((int) TargetObsoleteDoNotUse);
} }
targets_.WriteTo(ref output, _repeated_targets_codec); targets_.WriteTo(ref output, _repeated_targets_codec);
uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec); uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec);
@ -8294,11 +8294,11 @@ namespace Google.Protobuf.Reflection {
if (HasRetention) { if (HasRetention) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) Retention); size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) Retention);
} }
if (HasTarget) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) Target);
}
size += targets_.CalculateSize(_repeated_targets_codec); size += targets_.CalculateSize(_repeated_targets_codec);
size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec);
if (HasTargetObsoleteDoNotUse) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) TargetObsoleteDoNotUse);
}
if (_extensions != null) { if (_extensions != null) {
size += _extensions.CalculateSize(); size += _extensions.CalculateSize();
} }
@ -8341,11 +8341,11 @@ namespace Google.Protobuf.Reflection {
if (other.HasRetention) { if (other.HasRetention) {
Retention = other.Retention; Retention = other.Retention;
} }
if (other.HasTarget) {
Target = other.Target;
}
targets_.Add(other.targets_); targets_.Add(other.targets_);
uninterpretedOption_.Add(other.uninterpretedOption_); uninterpretedOption_.Add(other.uninterpretedOption_);
if (other.HasTargetObsoleteDoNotUse) {
TargetObsoleteDoNotUse = other.TargetObsoleteDoNotUse;
}
pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions); pb::ExtensionSet.MergeFrom(ref _extensions, other._extensions);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
} }
@ -8401,7 +8401,7 @@ namespace Google.Protobuf.Reflection {
break; break;
} }
case 144: { case 144: {
Target = (global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) input.ReadEnum(); TargetObsoleteDoNotUse = (global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) input.ReadEnum();
break; break;
} }
case 154: case 154:
@ -8467,7 +8467,7 @@ namespace Google.Protobuf.Reflection {
break; break;
} }
case 144: { case 144: {
Target = (global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) input.ReadEnum(); TargetObsoleteDoNotUse = (global::Google.Protobuf.Reflection.FieldOptions.Types.OptionTargetType) input.ReadEnum();
break; break;
} }
case 154: case 154:

@ -466,3 +466,8 @@ with info about your project (name and website) so we can add an entry for you.
* Website: https://square.github.io/wire/ * Website: https://square.github.io/wire/
* Extensions: 1180 * Extensions: 1180
1. EngFlow
* Website: https://github.com/EngFlow/engflowapis
* Extensions: 1181

@ -206,7 +206,6 @@ Key bindings:
(c-initialize-cc-mode t) (c-initialize-cc-mode t)
(c-init-language-vars protobuf-mode) (c-init-language-vars protobuf-mode)
(c-common-init 'protobuf-mode) (c-common-init 'protobuf-mode)
(easy-menu-add protobuf-menu)
(setq imenu-generic-expression (setq imenu-generic-expression
'(("Message" "^[[:space:]]*message[[:space:]]+\\([[:alnum:]]+\\)" 1) '(("Message" "^[[:space:]]*message[[:space:]]+\\([[:alnum:]]+\\)" 1)
("Enum" "^[[:space:]]*enum[[:space:]]+\\([[:alnum:]]+\\)" 1) ("Enum" "^[[:space:]]*enum[[:space:]]+\\([[:alnum:]]+\\)" 1)

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</dependency> </dependency>
``` ```
@ -37,14 +37,14 @@ protobuf-java-util package:
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</dependency> </dependency>
``` ```
### Gradle ### Gradle
If you are using Gradle, add the following to your `build.gradle` file's If you are using Gradle, add the following to your `build.gradle` file's
dependencies: `implementation 'com.google.protobuf:protobuf-java:3.22.3'` Again, dependencies: `implementation 'com.google.protobuf:protobuf-java:3.23.0'` Again,
be sure to check that the version number matches (or is newer than) the version be sure to check that the version number matches (or is newer than) the version
number of protoc that you are using. number of protoc that you are using.

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId> <artifactId>protobuf-bom</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name> <name>Protocol Buffers [BOM]</name>

@ -121,11 +121,21 @@ internal_gen_well_known_protos_java(
) )
# Should be used as `//java/lite`. # Should be used as `//java/lite`.
protobuf_versioned_java_library( java_library(
name = "lite", name = "lite",
srcs = LITE_SRCS + [ srcs = LITE_SRCS + [
":gen_well_known_protos_javalite", ":gen_well_known_protos_javalite",
], ],
visibility = [
"//java/lite:__pkg__",
],
)
protobuf_versioned_java_library(
name = "lite_bundle",
srcs = LITE_SRCS + [
":gen_well_known_protos_javalite",
],
bundle_description = "Lite version of Protocol Buffers library. This " + bundle_description = "Lite version of Protocol Buffers library. This " +
"version is optimized for code size, but does not " + "version is optimized for code size, but does not " +
"guarantee API/ABI stability.", "guarantee API/ABI stability.",
@ -145,7 +155,7 @@ protobuf_java_export(
"//:lite_well_known_protos", "//:lite_well_known_protos",
], ],
tags = ["manual"], tags = ["manual"],
runtime_deps = [":lite"], runtime_deps = [":lite_bundle"],
) )
protobuf_java_library( protobuf_java_library(
@ -171,7 +181,7 @@ internal_gen_well_known_protos_java(
], ],
) )
protobuf_versioned_java_library( java_library(
name = "core", name = "core",
srcs = glob( srcs = glob(
[ [
@ -181,6 +191,25 @@ protobuf_versioned_java_library(
) + [ ) + [
":gen_well_known_protos_java", ":gen_well_known_protos_java",
], ],
visibility = ["//visibility:public"],
exports = [
":lite_runtime_only",
],
deps = [
":lite_runtime_only",
],
)
protobuf_versioned_java_library(
name = "core_bundle",
srcs = glob(
[
"src/main/java/com/google/protobuf/*.java",
],
exclude = LITE_SRCS,
) + [
":gen_well_known_protos_java",
],
bundle_description = "Core Protocol Buffers library. Protocol Buffers " + bundle_description = "Core Protocol Buffers library. Protocol Buffers " +
"are a way of encoding structured data in an " + "are a way of encoding structured data in an " +
"efficient yet extensible format.", "efficient yet extensible format.",
@ -205,7 +234,7 @@ protobuf_java_export(
"//src/google/protobuf:descriptor_proto_srcs", "//src/google/protobuf:descriptor_proto_srcs",
], ],
tags = ["manual"], tags = ["manual"],
runtime_deps = [":core"], runtime_deps = [":core_bundle"],
) )
filegroup( filegroup(

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</parent> </parent>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>

@ -162,6 +162,8 @@ public final class Descriptors {
} }
/** The syntax of the .proto file. */ /** The syntax of the .proto file. */
@Deprecated
public
enum Syntax { enum Syntax {
UNKNOWN("unknown"), UNKNOWN("unknown"),
PROTO2("proto2"), PROTO2("proto2"),
@ -175,6 +177,8 @@ public final class Descriptors {
} }
/** Get the syntax of the .proto file. */ /** Get the syntax of the .proto file. */
@Deprecated
public
Syntax getSyntax() { Syntax getSyntax() {
if (Syntax.PROTO3.name.equals(proto.getSyntax())) { if (Syntax.PROTO3.name.equals(proto.getSyntax())) {
return Syntax.PROTO3; return Syntax.PROTO3;

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</parent> </parent>
<artifactId>protobuf-kotlin-lite</artifactId> <artifactId>protobuf-kotlin-lite</artifactId>

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</parent> </parent>
<artifactId>protobuf-kotlin</artifactId> <artifactId>protobuf-kotlin</artifactId>

@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following:
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-javalite</artifactId> <artifactId>protobuf-javalite</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</dependency> </dependency>
``` ```

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</parent> </parent>
<artifactId>protobuf-javalite</artifactId> <artifactId>protobuf-javalite</artifactId>

@ -4,7 +4,7 @@
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name> <name>Protocol Buffers [Parent]</name>

@ -8,7 +8,7 @@
</parent> </parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId> <artifactId>protoc</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protobuf Compiler</name> <name>Protobuf Compiler</name>
<description> <description>

@ -5,11 +5,27 @@ load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_versioned_j
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION") load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//java/internal:testing.bzl", "junit_tests") load("//java/internal:testing.bzl", "junit_tests")
protobuf_versioned_java_library( java_library(
name = "util", name = "util",
srcs = glob([ srcs = glob([
"src/main/java/com/google/protobuf/util/*.java", "src/main/java/com/google/protobuf/util/*.java",
]), ]),
visibility = ["//visibility:public"],
deps = [
"//java/core",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_code_gson_gson",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
"@maven//:com_google_j2objc_j2objc_annotations",
],
)
protobuf_versioned_java_library(
name = "util_bundle",
srcs = glob([
"src/main/java/com/google/protobuf/util/*.java",
]),
bundle_description = "Utilities for Protocol Buffers", bundle_description = "Utilities for Protocol Buffers",
bundle_name = "Protocol Buffers [Util]", bundle_name = "Protocol Buffers [Util]",
bundle_symbolic_name = "com.google.protobuf.util", bundle_symbolic_name = "com.google.protobuf.util",
@ -32,7 +48,7 @@ protobuf_java_export(
pom_template = "pom_template.xml", pom_template = "pom_template.xml",
tags = ["manual"], tags = ["manual"],
visibility = ["//java:__pkg__"], visibility = ["//java:__pkg__"],
runtime_deps = [":util"], runtime_deps = [":util_bundle"],
) )
filegroup( filegroup(

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId> <artifactId>protobuf-parent</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</parent> </parent>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>

@ -7,11 +7,9 @@ load(":defs.bzl", "objc_proto_camel_case_name")
# The WKTs have to be checked in to support the CocoaPods and Xcode builds. This # The WKTs have to be checked in to support the CocoaPods and Xcode builds. This
# generule and test ensure the source are current. # generule and test ensure the source are current.
# #
# Within the ":objectivec" target, the outputs of the genrule are then used to # TODO: Improve the bazel build so it uses these generated headers so it is
# ensure they are always "current". This implementation is basically the same # always current, and only the builds that can't easily build protoc and
# has how the WKTs are handled in src/google/protobuf/BUILD.bazel for the C++ # generate the files rely on the checked in ones.
# version. They share the potential downsides around layer checks and that
# someone could #include the header with the `wkt/` prefix on the name.
_WELL_KNOWN_TYPES = [ _WELL_KNOWN_TYPES = [
"any", "any",
@ -45,6 +43,7 @@ genrule(
for ext in _OBJC_EXTS for ext in _OBJC_EXTS
]), ]),
exec_tools = ["//:protoc"], exec_tools = ["//:protoc"],
tags = ["manual"],
) )
staleness_test( staleness_test(
@ -61,6 +60,16 @@ staleness_test(
objc_library( objc_library(
name = "objectivec", name = "objectivec",
hdrs = [ hdrs = [
"GPBAny.pbobjc.h",
"GPBApi.pbobjc.h",
"GPBDuration.pbobjc.h",
"GPBEmpty.pbobjc.h",
"GPBFieldMask.pbobjc.h",
"GPBSourceContext.pbobjc.h",
"GPBStruct.pbobjc.h",
"GPBTimestamp.pbobjc.h",
"GPBType.pbobjc.h",
"GPBWrappers.pbobjc.h",
"GPBArray.h", "GPBArray.h",
"GPBBootstrap.h", "GPBBootstrap.h",
"GPBCodedInputStream.h", "GPBCodedInputStream.h",
@ -101,30 +110,39 @@ objc_library(
"GPBUnknownFieldSet_PackagePrivate.h", "GPBUnknownFieldSet_PackagePrivate.h",
"GPBUnknownField_PackagePrivate.h", "GPBUnknownField_PackagePrivate.h",
"GPBUtilities_PackagePrivate.h", "GPBUtilities_PackagePrivate.h",
] + ["wkt/GPB" + wkt + ".pbobjc.h" for wkt in _OBJC_WKT_NAMES], ],
copts = [ copts = [
"-Wno-vla", "-Wno-vla",
], ],
includes = [ includes = [
".", ".",
"wkt",
], ],
non_arc_srcs = [ non_arc_srcs = [
"GPBAny.pbobjc.m",
"GPBApi.pbobjc.m",
"GPBArray.m", "GPBArray.m",
"GPBCodedInputStream.m", "GPBCodedInputStream.m",
"GPBCodedOutputStream.m", "GPBCodedOutputStream.m",
"GPBDescriptor.m", "GPBDescriptor.m",
"GPBDictionary.m", "GPBDictionary.m",
"GPBDuration.pbobjc.m",
"GPBEmpty.pbobjc.m",
"GPBExtensionInternals.m", "GPBExtensionInternals.m",
"GPBExtensionRegistry.m", "GPBExtensionRegistry.m",
"GPBFieldMask.pbobjc.m",
"GPBMessage.m", "GPBMessage.m",
"GPBRootObject.m", "GPBRootObject.m",
"GPBSourceContext.pbobjc.m",
"GPBStruct.pbobjc.m",
"GPBTimestamp.pbobjc.m",
"GPBType.pbobjc.m",
"GPBUnknownField.m", "GPBUnknownField.m",
"GPBUnknownFieldSet.m", "GPBUnknownFieldSet.m",
"GPBUtilities.m", "GPBUtilities.m",
"GPBWellKnownTypes.m", "GPBWellKnownTypes.m",
"GPBWireFormat.m", "GPBWireFormat.m",
] + ["wkt/GPB" + wkt + ".pbobjc.m" for wkt in _OBJC_WKT_NAMES], "GPBWrappers.pbobjc.m",
],
target_compatible_with = select({ target_compatible_with = select({
"@platforms//os:macos": [], "@platforms//os:macos": [],
"@platforms//os:ios": [], "@platforms//os:ios": [],

@ -7225,7 +7225,7 @@ bool upb_MiniTable_Link(upb_MiniTable* mt, const upb_MiniTable** sub_tables,
upb_MiniTableField* f = (upb_MiniTableField*)&mt->fields[i]; upb_MiniTableField* f = (upb_MiniTableField*)&mt->fields[i];
if (upb_MiniTableField_CType(f) == kUpb_CType_Enum) { if (upb_MiniTableField_CType(f) == kUpb_CType_Enum) {
const upb_MiniTableEnum* sub = sub_enums[enum_count++]; const upb_MiniTableEnum* sub = sub_enums[enum_count++];
if (enum_count > sub_table_count) return false; if (enum_count > sub_enum_count) return false;
if (sub != NULL) { if (sub != NULL) {
if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false; if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false;
} }

@ -365,7 +365,7 @@ typedef enum {
kUpb_CType_Float = 2, kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3, kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4, kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. kUpb_CType_Enum = 5, // Enum values are int32. TODO(b/279178239): rename
kUpb_CType_Message = 6, kUpb_CType_Message = 6,
kUpb_CType_Double = 7, kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8, kUpb_CType_Int64 = 8,
@ -2720,7 +2720,8 @@ UPB_API_INLINE int32_t upb_Message_GetInt32(const upb_Message* msg,
UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg, UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg,
const upb_MiniTableField* field, const upb_MiniTableField* field,
int32_t value, upb_Arena* a) { int32_t value, upb_Arena* a) {
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32); UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 ||
upb_MiniTableField_CType(field) == kUpb_CType_Enum);
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte);
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); UPB_ASSUME(!upb_IsRepeatedOrMap(field));
return _upb_Message_SetField(msg, field, &value, a); return _upb_Message_SetField(msg, field, &value, a);
@ -2746,7 +2747,7 @@ UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg,
return _upb_Message_SetField(msg, field, &value, a); return _upb_Message_SetField(msg, field, &value, a);
} }
UPB_API_INLINE void upb_Message_SetEnumProto2( UPB_API_INLINE void upb_Message_SetClosedEnum(
upb_Message* msg, const upb_MiniTable* msg_mini_table, upb_Message* msg, const upb_MiniTable* msg_mini_table,
const upb_MiniTableField* field, int32_t value) { const upb_MiniTableField* field, int32_t value) {
UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field)); UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field));
@ -3472,6 +3473,23 @@ UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorSet_file_mutable_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) { UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorSet_file(msg, &size); google_protobuf_FileDescriptorSet_file(msg, &size);
@ -3585,6 +3603,23 @@ UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_dependency(msg, &size); google_protobuf_FileDescriptorProto_dependency(msg, &size);
@ -3605,6 +3640,23 @@ UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDes
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_message_type(msg, &size); google_protobuf_FileDescriptorProto_message_type(msg, &size);
@ -3625,6 +3677,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_enum_type(msg, &size); google_protobuf_FileDescriptorProto_enum_type(msg, &size);
@ -3645,6 +3714,23 @@ UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_service_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_service(msg, &size); google_protobuf_FileDescriptorProto_service(msg, &size);
@ -3665,6 +3751,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_Fi
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_extension_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_extension(msg, &size); google_protobuf_FileDescriptorProto_extension(msg, &size);
@ -3715,6 +3818,23 @@ UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_public_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_public_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_public_dependency(msg, &size); google_protobuf_FileDescriptorProto_public_dependency(msg, &size);
@ -3735,6 +3855,23 @@ UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(co
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_weak_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_weak_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_weak_dependency(msg, &size); google_protobuf_FileDescriptorProto_weak_dependency(msg, &size);
@ -4053,6 +4190,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_field_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_field(msg, &size); google_protobuf_DescriptorProto_field(msg, &size);
@ -4073,6 +4227,23 @@ UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_Descrip
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_nested_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_nested_type(msg, &size); google_protobuf_DescriptorProto_nested_type(msg, &size);
@ -4093,6 +4264,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_Des
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_enum_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_enum_type(msg, &size); google_protobuf_DescriptorProto_enum_type(msg, &size);
@ -4113,6 +4301,23 @@ UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_p
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_extension_range(msg, &size); google_protobuf_DescriptorProto_extension_range(msg, &size);
@ -4133,6 +4338,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_extension(msg, &size); google_protobuf_DescriptorProto_extension(msg, &size);
@ -4168,6 +4390,23 @@ UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_oneof_decl(msg, &size); google_protobuf_DescriptorProto_oneof_decl(msg, &size);
@ -4188,6 +4427,23 @@ UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_pr
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_reserved_range(msg, &size); google_protobuf_DescriptorProto_reserved_range(msg, &size);
@ -4208,6 +4464,23 @@ UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(c
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_name(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_name(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_reserved_name(msg, &size); google_protobuf_DescriptorProto_reserved_name(msg, &size);
@ -4664,6 +4937,23 @@ UPB_INLINE const google_protobuf_ExtensionRangeOptions_Declaration* const* googl
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_declaration(const google_protobuf_ExtensionRangeOptions* msg) { UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_declaration(const google_protobuf_ExtensionRangeOptions* msg) {
size_t size; size_t size;
google_protobuf_ExtensionRangeOptions_declaration(msg, &size); google_protobuf_ExtensionRangeOptions_declaration(msg, &size);
@ -4699,6 +4989,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Ext
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) { UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) {
size_t size; size_t size;
google_protobuf_ExtensionRangeOptions_uninterpreted_option(msg, &size); google_protobuf_ExtensionRangeOptions_uninterpreted_option(msg, &size);
@ -5315,6 +5622,23 @@ UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_value_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_value_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_value(msg, &size); google_protobuf_EnumDescriptorProto_value(msg, &size);
@ -5350,6 +5674,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* g
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_reserved_range(msg, &size); google_protobuf_EnumDescriptorProto_reserved_range(msg, &size);
@ -5370,6 +5711,23 @@ UPB_INLINE upb_StringView const* google_protobuf_EnumDescriptorProto_reserved_na
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_name(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_name(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_reserved_name(msg, &size); google_protobuf_EnumDescriptorProto_reserved_name(msg, &size);
@ -5711,6 +6069,23 @@ UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_S
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ServiceDescriptorProto_method_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ServiceDescriptorProto_method_mutable_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto* msg) { UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_ServiceDescriptorProto_method(msg, &size); google_protobuf_ServiceDescriptorProto_method(msg, &size);
@ -6284,6 +6659,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileOptions_uninterpreted_option_upb_array(const google_protobuf_FileOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(20, 184), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FileOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(20, 184), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions* msg) { UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions* msg) {
size_t size; size_t size;
google_protobuf_FileOptions_uninterpreted_option(msg, &size); google_protobuf_FileOptions_uninterpreted_option(msg, &size);
@ -6522,6 +6914,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Mes
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_upb_array(const google_protobuf_MessageOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 8, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MessageOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 8, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions* msg) { UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions* msg) {
size_t size; size_t size;
google_protobuf_MessageOptions_uninterpreted_option(msg, &size); google_protobuf_MessageOptions_uninterpreted_option(msg, &size);
@ -6775,6 +7184,23 @@ UPB_INLINE int32_t const* google_protobuf_FieldOptions_targets(const google_prot
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_targets_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) {
const upb_MiniTableField field = {19, UPB_SIZE(28, 32), 0, 4, 14, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FieldOptions_targets_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {19, UPB_SIZE(28, 32), 0, 4, 14, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FieldOptions_has_targets(const google_protobuf_FieldOptions* msg) { UPB_INLINE bool google_protobuf_FieldOptions_has_targets(const google_protobuf_FieldOptions* msg) {
size_t size; size_t size;
google_protobuf_FieldOptions_targets(msg, &size); google_protobuf_FieldOptions_targets(msg, &size);
@ -6795,6 +7221,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Fie
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(32, 40), 0, 5, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(32, 40), 0, 5, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions* msg) { UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions* msg) {
size_t size; size_t size;
google_protobuf_FieldOptions_uninterpreted_option(msg, &size); google_protobuf_FieldOptions_uninterpreted_option(msg, &size);
@ -6942,6 +7385,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_One
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_upb_array(const google_protobuf_OneofOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_OneofOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions* msg) { UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions* msg) {
size_t size; size_t size;
google_protobuf_OneofOptions_uninterpreted_option(msg, &size); google_protobuf_OneofOptions_uninterpreted_option(msg, &size);
@ -7070,6 +7530,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Enu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_upb_array(const google_protobuf_EnumOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions* msg) { UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions* msg) {
size_t size; size_t size;
google_protobuf_EnumOptions_uninterpreted_option(msg, &size); google_protobuf_EnumOptions_uninterpreted_option(msg, &size);
@ -7180,6 +7657,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Enu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions* msg) { UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions* msg) {
size_t size; size_t size;
google_protobuf_EnumValueOptions_uninterpreted_option(msg, &size); google_protobuf_EnumValueOptions_uninterpreted_option(msg, &size);
@ -7282,6 +7776,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Ser
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions* msg) { UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions* msg) {
size_t size; size_t size;
google_protobuf_ServiceOptions_uninterpreted_option(msg, &size); google_protobuf_ServiceOptions_uninterpreted_option(msg, &size);
@ -7399,6 +7910,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Met
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_upb_array(const google_protobuf_MethodOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 8, 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MethodOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 8, 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions* msg) { UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions* msg) {
size_t size; size_t size;
google_protobuf_MethodOptions_uninterpreted_option(msg, &size); google_protobuf_MethodOptions_uninterpreted_option(msg, &size);
@ -7490,6 +8018,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_pro
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_UninterpretedOption_name_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_UninterpretedOption_name_mutable_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption* msg) { UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption* msg) {
size_t size; size_t size;
google_protobuf_UninterpretedOption_name(msg, &size); google_protobuf_UninterpretedOption_name(msg, &size);
@ -7762,6 +8307,23 @@ UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_location_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_location_mutable_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_location(msg, &size); google_protobuf_SourceCodeInfo_location(msg, &size);
@ -7845,6 +8407,23 @@ UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const goo
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_path_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_path_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_path(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_path(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_path(msg, &size); google_protobuf_SourceCodeInfo_Location_path(msg, &size);
@ -7865,6 +8444,23 @@ UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const goo
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_span_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_span_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_span(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_span(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_span(msg, &size); google_protobuf_SourceCodeInfo_Location_span(msg, &size);
@ -7915,6 +8511,23 @@ UPB_INLINE upb_StringView const* google_protobuf_SourceCodeInfo_Location_leading
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_leading_detached_comments(msg, &size); google_protobuf_SourceCodeInfo_Location_leading_detached_comments(msg, &size);
@ -8052,6 +8665,23 @@ UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_pro
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_mutable_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo* msg) { UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo* msg) {
size_t size; size_t size;
google_protobuf_GeneratedCodeInfo_annotation(msg, &size); google_protobuf_GeneratedCodeInfo_annotation(msg, &size);
@ -8135,6 +8765,23 @@ UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(cons
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_mutable_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg) {
size_t size; size_t size;
google_protobuf_GeneratedCodeInfo_Annotation_path(msg, &size); google_protobuf_GeneratedCodeInfo_Annotation_path(msg, &size);

@ -127,7 +127,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO() ZEND_END_ARG_INFO()
#define PHP_PROTOBUF_VERSION "3.22.3" #define PHP_PROTOBUF_VERSION "3.23.0"
// ptr -> PHP object cache. This is a weak map that caches lazily-created // ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types: // wrapper objects around upb types:

@ -229,6 +229,7 @@ cc_dist_library(
testonly = 1, testonly = 1,
tags = ["manual"], tags = ["manual"],
deps = [ deps = [
"//src/google/protobuf:test_textproto",
"//src/google/protobuf/compiler:mock_code_generator", "//src/google/protobuf/compiler:mock_code_generator",
"//src/google/protobuf/testing", "//src/google/protobuf/testing",
], ],

@ -42,8 +42,8 @@ def protobuf_deps():
_github_archive( _github_archive(
name = "com_google_absl", name = "com_google_absl",
repo = "https://github.com/abseil/abseil-cpp", repo = "https://github.com/abseil/abseil-cpp",
commit = "78be63686ba732b25052be15f8d6dee891c05749", # Abseil LTS 20230125 commit = "c2435f8342c2d0ed8101cb43adfd605fdc52dca2", # Abseil LTS 20230125.3
sha256 = "4f356a07b9ec06ef51f943928508566e992f621ed5fa4dd588865d7bed1284cd", sha256 = "ea1d31db00eb37e607bfda17ffac09064670ddf05da067944c4766f517876390",
) )
if not native.existing_rule("zlib"): if not native.existing_rule("zlib"):
@ -151,7 +151,7 @@ def protobuf_deps():
_github_archive( _github_archive(
name = "upb", name = "upb",
repo = "https://github.com/protocolbuffers/upb", repo = "https://github.com/protocolbuffers/upb",
commit = "8c10056074a2698a134dae73dea86ba3d7e0d56b", commit = "7a04b4027d737828c9c5b8be56c838d5db0db80f",
sha256 = "c530b25f1afa08016228b7c07066d9cd545b852684bd06dd9235b47d00185b33", sha256 = "2444c0ce7a869ce320a57fc13d96900364ddac8b8da779e1315b5d83fc38bbc1",
patches = ["@com_google_protobuf//build_defs:upb.patch"], patches = ["@com_google_protobuf//build_defs:upb.patch"],
) )

@ -1,6 +1,6 @@
""" Contains version numbers to be used in other bzl files """ """ Contains version numbers to be used in other bzl files """
PROTOC_VERSION = "22.3" PROTOC_VERSION = "23.0"
PROTOBUF_JAVA_VERSION = "3.22.3" PROTOBUF_JAVA_VERSION = "3.23.0"
PROTOBUF_PYTHON_VERSION = "4.22.3" PROTOBUF_PYTHON_VERSION = "4.23.0"
PROTOBUF_PHP_VERSION = "3.22.3" PROTOBUF_PHP_VERSION = "3.23.0"
PROTOBUF_RUBY_VERSION = "3.22.3" PROTOBUF_RUBY_VERSION = "3.23.0"

@ -30,4 +30,4 @@
# Copyright 2007 Google Inc. All Rights Reserved. # Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '4.22.3' __version__ = '4.23.0'

@ -74,8 +74,8 @@ def _Deprecated(func):
def NewFunc(*args, **kwargs): def NewFunc(*args, **kwargs):
warnings.warn( warnings.warn(
'Call to deprecated function %s(). Note: Do add unlinked descriptors ' 'Call to deprecated function %s(). Note: Do add unlinked descriptors '
'to descriptor_pool is wrong. Use Add() or AddSerializedFile() ' 'to descriptor_pool is wrong. Please use Add() or AddSerializedFile() '
'instead.' % func.__name__, 'instead. This function will be removed soon.' % func.__name__,
category=DeprecationWarning) category=DeprecationWarning)
return func(*args, **kwargs) return func(*args, **kwargs)
NewFunc.__name__ = func.__name__ NewFunc.__name__ = func.__name__
@ -246,12 +246,6 @@ class DescriptorPool(object):
self._descriptors[desc.full_name] = desc self._descriptors[desc.full_name] = desc
self._AddFileDescriptor(desc.file) self._AddFileDescriptor(desc.file)
# Add EnumDescriptor to descriptor pool is deprecated. Please use Add()
# or AddSerializedFile() to add a FileDescriptorProto instead.
@_Deprecated
def AddEnumDescriptor(self, enum_desc):
self._AddEnumDescriptor(enum_desc)
# Never call this method. It is for internal usage only. # Never call this method. It is for internal usage only.
def _AddEnumDescriptor(self, enum_desc): def _AddEnumDescriptor(self, enum_desc):
"""Adds an EnumDescriptor to the pool. """Adds an EnumDescriptor to the pool.
@ -811,12 +805,17 @@ class DescriptorPool(object):
self._file_descriptors[file_proto.name] = file_descriptor self._file_descriptors[file_proto.name] = file_descriptor
# Add extensions to the pool # Add extensions to the pool
def AddExtensionForNested(message_type):
for nested in message_type.nested_types:
AddExtensionForNested(nested)
for extension in message_type.extensions:
self._AddExtensionDescriptor(extension)
file_desc = self._file_descriptors[file_proto.name] file_desc = self._file_descriptors[file_proto.name]
for extension in file_desc.extensions_by_name.values(): for extension in file_desc.extensions_by_name.values():
self._AddExtensionDescriptor(extension) self._AddExtensionDescriptor(extension)
for message_type in file_desc.message_types_by_name.values(): for message_type in file_desc.message_types_by_name.values():
for extension in message_type.extensions: AddExtensionForNested(message_type)
self._AddExtensionDescriptor(extension)
return file_desc return file_desc

@ -38,6 +38,7 @@ in generated code.
__author__ = 'jieluo@google.com (Jie Luo)' __author__ = 'jieluo@google.com (Jie Luo)'
from google.protobuf.internal import enum_type_wrapper from google.protobuf.internal import enum_type_wrapper
from google.protobuf.internal import python_message
from google.protobuf import message as _message from google.protobuf import message as _message
from google.protobuf import reflection as _reflection from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database from google.protobuf import symbol_database as _symbol_database
@ -108,6 +109,28 @@ def BuildTopDescriptorsAndMessages(file_des, module_name, module):
module[name] = BuildMessage(msg_des) module[name] = BuildMessage(msg_des)
def AddHelpersToExtensions(file_des):
"""Adds field helpers to extensions.
Args:
file_des: FileDescriptor of the .proto file
"""
def AddHelpersToExtension(extension):
python_message._AttachFieldHelpers(
extension.containing_type._concrete_class, extension)
def AddHelpersToNestedExtensions(msg_des):
for nested_type in msg_des.nested_types:
AddHelpersToNestedExtensions(nested_type)
for extension in msg_des.extensions:
AddHelpersToExtension(extension)
for extension in file_des.extensions_by_name.values():
AddHelpersToExtension(extension)
for message_type in file_des.message_types_by_name.values():
AddHelpersToNestedExtensions(message_type)
def BuildServices(file_des, module_name, module): def BuildServices(file_des, module_name, module):
"""Builds services classes and services stub class. """Builds services classes and services stub class.

@ -1373,6 +1373,33 @@ class Proto2Test(unittest.TestCase):
123, 123,
msg1.submessage.Extensions[more_extensions_pb2.optional_int_extension]) msg1.submessage.Extensions[more_extensions_pb2.optional_int_extension])
def testCopyFromAll(self):
message = unittest_pb2.TestAllTypes()
test_util.SetAllFields(message)
copy = unittest_pb2.TestAllTypes()
copy.CopyFrom(message)
self.assertEqual(message, copy)
message.repeated_nested_message.add().bb = 123
self.assertNotEqual(message, copy)
def testCopyFromAllExtensions(self):
all_set = unittest_pb2.TestAllExtensions()
test_util.SetAllExtensions(all_set)
copy = unittest_pb2.TestAllExtensions()
copy.CopyFrom(all_set)
self.assertEqual(all_set, copy)
all_set.Extensions[unittest_pb2.repeatedgroup_extension].add().a = 321
self.assertNotEqual(all_set, copy)
def testCopyFromAllPackedExtensions(self):
all_set = unittest_pb2.TestPackedExtensions()
test_util.SetAllPackedExtensions(all_set)
copy = unittest_pb2.TestPackedExtensions()
copy.CopyFrom(all_set)
self.assertEqual(all_set, copy)
all_set.Extensions[unittest_pb2.packed_float_extension].extend([61.0, 71.0])
self.assertNotEqual(all_set, copy)
def testGoldenExtensions(self): def testGoldenExtensions(self):
golden_data = test_util.GoldenFileData('golden_message') golden_data = test_util.GoldenFileData('golden_message')
golden_message = unittest_pb2.TestAllExtensions() golden_message = unittest_pb2.TestAllExtensions()
@ -1382,7 +1409,11 @@ class Proto2Test(unittest.TestCase):
self.assertEqual(all_set, golden_message) self.assertEqual(all_set, golden_message)
self.assertEqual(golden_data, golden_message.SerializeToString()) self.assertEqual(golden_data, golden_message.SerializeToString())
golden_copy = copy.deepcopy(golden_message) golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString()) self.assertEqual(golden_message, golden_copy)
# Depend on a specific serialization order for extensions is not
# reasonable to guarantee.
if api_implementation.Type() != 'upb':
self.assertEqual(golden_data, golden_copy.SerializeToString())
def testGoldenPackedExtensions(self): def testGoldenPackedExtensions(self):
golden_data = test_util.GoldenFileData('golden_packed_fields_message') golden_data = test_util.GoldenFileData('golden_packed_fields_message')
@ -1393,7 +1424,11 @@ class Proto2Test(unittest.TestCase):
self.assertEqual(all_set, golden_message) self.assertEqual(all_set, golden_message)
self.assertEqual(golden_data, all_set.SerializeToString()) self.assertEqual(golden_data, all_set.SerializeToString())
golden_copy = copy.deepcopy(golden_message) golden_copy = copy.deepcopy(golden_message)
self.assertEqual(golden_data, golden_copy.SerializeToString()) self.assertEqual(golden_message, golden_copy)
# Depend on a specific serialization order for extensions is not
# reasonable to guarantee.
if api_implementation.Type() != 'upb':
self.assertEqual(golden_data, golden_copy.SerializeToString())
def testPickleIncompleteProto(self): def testPickleIncompleteProto(self):
golden_message = unittest_pb2.TestRequired(a=1) golden_message = unittest_pb2.TestRequired(a=1)

@ -1,4 +1,12 @@
# Internal helpers for building the Python protobuf runtime. """
Internal helpers for building the Python protobuf runtime.
"""
def _remove_cross_repo_path(path):
components = path.split("/")
if components[0] == "..":
return "/".join(components[2:])
return path
def _internal_copy_files_impl(ctx): def _internal_copy_files_impl(ctx):
strip_prefix = ctx.attr.strip_prefix strip_prefix = ctx.attr.strip_prefix
@ -7,10 +15,11 @@ def _internal_copy_files_impl(ctx):
src_dests = [] src_dests = []
for src in ctx.files.srcs: for src in ctx.files.srcs:
if src.short_path[:len(strip_prefix)] != strip_prefix: short_path = _remove_cross_repo_path(src.short_path)
if short_path[:len(strip_prefix)] != strip_prefix:
fail("Source does not start with %s: %s" % fail("Source does not start with %s: %s" %
(strip_prefix, src.short_path)) (strip_prefix, short_path))
dest = ctx.actions.declare_file(src.short_path[len(strip_prefix):]) dest = ctx.actions.declare_file(short_path[len(strip_prefix):])
src_dests.append([src, dest]) src_dests.append([src, dest])
if ctx.attr.is_windows: if ctx.attr.is_windows:

@ -6841,7 +6841,7 @@ bool upb_MiniTable_Link(upb_MiniTable* mt, const upb_MiniTable** sub_tables,
upb_MiniTableField* f = (upb_MiniTableField*)&mt->fields[i]; upb_MiniTableField* f = (upb_MiniTableField*)&mt->fields[i];
if (upb_MiniTableField_CType(f) == kUpb_CType_Enum) { if (upb_MiniTableField_CType(f) == kUpb_CType_Enum) {
const upb_MiniTableEnum* sub = sub_enums[enum_count++]; const upb_MiniTableEnum* sub = sub_enums[enum_count++];
if (enum_count > sub_table_count) return false; if (enum_count > sub_enum_count) return false;
if (sub != NULL) { if (sub != NULL) {
if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false; if (!upb_MiniTable_SetSubEnum(mt, f, sub)) return false;
} }

@ -367,7 +367,7 @@ typedef enum {
kUpb_CType_Float = 2, kUpb_CType_Float = 2,
kUpb_CType_Int32 = 3, kUpb_CType_Int32 = 3,
kUpb_CType_UInt32 = 4, kUpb_CType_UInt32 = 4,
kUpb_CType_Enum = 5, // Enum values are int32. kUpb_CType_Enum = 5, // Enum values are int32. TODO(b/279178239): rename
kUpb_CType_Message = 6, kUpb_CType_Message = 6,
kUpb_CType_Double = 7, kUpb_CType_Double = 7,
kUpb_CType_Int64 = 8, kUpb_CType_Int64 = 8,
@ -2722,7 +2722,8 @@ UPB_API_INLINE int32_t upb_Message_GetInt32(const upb_Message* msg,
UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg, UPB_API_INLINE bool upb_Message_SetInt32(upb_Message* msg,
const upb_MiniTableField* field, const upb_MiniTableField* field,
int32_t value, upb_Arena* a) { int32_t value, upb_Arena* a) {
UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32); UPB_ASSUME(upb_MiniTableField_CType(field) == kUpb_CType_Int32 ||
upb_MiniTableField_CType(field) == kUpb_CType_Enum);
UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte); UPB_ASSUME(_upb_MiniTableField_GetRep(field) == kUpb_FieldRep_4Byte);
UPB_ASSUME(!upb_IsRepeatedOrMap(field)); UPB_ASSUME(!upb_IsRepeatedOrMap(field));
return _upb_Message_SetField(msg, field, &value, a); return _upb_Message_SetField(msg, field, &value, a);
@ -2748,7 +2749,7 @@ UPB_API_INLINE bool upb_Message_SetUInt32(upb_Message* msg,
return _upb_Message_SetField(msg, field, &value, a); return _upb_Message_SetField(msg, field, &value, a);
} }
UPB_API_INLINE void upb_Message_SetEnumProto2( UPB_API_INLINE void upb_Message_SetClosedEnum(
upb_Message* msg, const upb_MiniTable* msg_mini_table, upb_Message* msg, const upb_MiniTable* msg_mini_table,
const upb_MiniTableField* field, int32_t value) { const upb_MiniTableField* field, int32_t value) {
UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field)); UPB_ASSERT(upb_MiniTableField_IsClosedEnum(field));
@ -3474,6 +3475,23 @@ UPB_INLINE const google_protobuf_FileDescriptorProto* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorSet_file_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorSet_file_mutable_upb_array(const google_protobuf_FileDescriptorSet* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) { UPB_INLINE bool google_protobuf_FileDescriptorSet_has_file(const google_protobuf_FileDescriptorSet* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorSet_file(msg, &size); google_protobuf_FileDescriptorSet_file(msg, &size);
@ -3587,6 +3605,23 @@ UPB_INLINE upb_StringView const* google_protobuf_FileDescriptorProto_dependency(
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {3, UPB_SIZE(4, 40), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_dependency(msg, &size); google_protobuf_FileDescriptorProto_dependency(msg, &size);
@ -3607,6 +3642,23 @@ UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_FileDes
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_message_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_message_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(8, 48), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_message_type(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_message_type(msg, &size); google_protobuf_FileDescriptorProto_message_type(msg, &size);
@ -3627,6 +3679,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_enum_type_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_enum_type_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(12, 56), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_enum_type(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_enum_type(msg, &size); google_protobuf_FileDescriptorProto_enum_type(msg, &size);
@ -3647,6 +3716,23 @@ UPB_INLINE const google_protobuf_ServiceDescriptorProto* const* google_protobuf_
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_service_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_service_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(16, 64), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_service(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_service(msg, &size); google_protobuf_FileDescriptorProto_service(msg, &size);
@ -3667,6 +3753,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_Fi
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_extension_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_extension_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {7, UPB_SIZE(20, 72), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_extension(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_extension(msg, &size); google_protobuf_FileDescriptorProto_extension(msg, &size);
@ -3717,6 +3820,23 @@ UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_public_dependency(
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_public_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {10, UPB_SIZE(32, 96), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_public_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_public_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_public_dependency(msg, &size); google_protobuf_FileDescriptorProto_public_dependency(msg, &size);
@ -3737,6 +3857,23 @@ UPB_INLINE int32_t const* google_protobuf_FileDescriptorProto_weak_dependency(co
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileDescriptorProto_weak_dependency_mutable_upb_array(const google_protobuf_FileDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {11, UPB_SIZE(36, 104), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileDescriptorProto_has_weak_dependency(const google_protobuf_FileDescriptorProto* msg) { UPB_INLINE bool google_protobuf_FileDescriptorProto_has_weak_dependency(const google_protobuf_FileDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_FileDescriptorProto_weak_dependency(msg, &size); google_protobuf_FileDescriptorProto_weak_dependency(msg, &size);
@ -4055,6 +4192,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_field_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_field_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_field(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_field(msg, &size); google_protobuf_DescriptorProto_field(msg, &size);
@ -4075,6 +4229,23 @@ UPB_INLINE const google_protobuf_DescriptorProto* const* google_protobuf_Descrip
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_nested_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_nested_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {3, UPB_SIZE(8, 32), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_nested_type(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_nested_type(msg, &size); google_protobuf_DescriptorProto_nested_type(msg, &size);
@ -4095,6 +4266,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto* const* google_protobuf_Des
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_enum_type_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_enum_type_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_enum_type(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_enum_type(msg, &size); google_protobuf_DescriptorProto_enum_type(msg, &size);
@ -4115,6 +4303,23 @@ UPB_INLINE const google_protobuf_DescriptorProto_ExtensionRange* const* google_p
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, 3, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_extension_range(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_extension_range(msg, &size); google_protobuf_DescriptorProto_extension_range(msg, &size);
@ -4135,6 +4340,23 @@ UPB_INLINE const google_protobuf_FieldDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_extension_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_extension_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(20, 56), 0, 4, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_extension(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_extension(msg, &size); google_protobuf_DescriptorProto_extension(msg, &size);
@ -4170,6 +4392,23 @@ UPB_INLINE const google_protobuf_OneofDescriptorProto* const* google_protobuf_De
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_oneof_decl_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_oneof_decl_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {8, UPB_SIZE(28, 72), 0, 6, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_oneof_decl(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_oneof_decl(msg, &size); google_protobuf_DescriptorProto_oneof_decl(msg, &size);
@ -4190,6 +4429,23 @@ UPB_INLINE const google_protobuf_DescriptorProto_ReservedRange* const* google_pr
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_range_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {9, UPB_SIZE(32, 80), 0, 7, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_range(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_reserved_range(msg, &size); google_protobuf_DescriptorProto_reserved_range(msg, &size);
@ -4210,6 +4466,23 @@ UPB_INLINE upb_StringView const* google_protobuf_DescriptorProto_reserved_name(c
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_DescriptorProto_reserved_name_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_DescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_DescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {10, UPB_SIZE(36, 88), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_name(const google_protobuf_DescriptorProto* msg) { UPB_INLINE bool google_protobuf_DescriptorProto_has_reserved_name(const google_protobuf_DescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_DescriptorProto_reserved_name(msg, &size); google_protobuf_DescriptorProto_reserved_name(msg, &size);
@ -4666,6 +4939,23 @@ UPB_INLINE const google_protobuf_ExtensionRangeOptions_Declaration* const* googl
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_declaration_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_declaration(const google_protobuf_ExtensionRangeOptions* msg) { UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_declaration(const google_protobuf_ExtensionRangeOptions* msg) {
size_t size; size_t size;
google_protobuf_ExtensionRangeOptions_declaration(msg, &size); google_protobuf_ExtensionRangeOptions_declaration(msg, &size);
@ -4701,6 +4991,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Ext
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ExtensionRangeOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ExtensionRangeOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(12, 16), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) { UPB_INLINE bool google_protobuf_ExtensionRangeOptions_has_uninterpreted_option(const google_protobuf_ExtensionRangeOptions* msg) {
size_t size; size_t size;
google_protobuf_ExtensionRangeOptions_uninterpreted_option(msg, &size); google_protobuf_ExtensionRangeOptions_uninterpreted_option(msg, &size);
@ -5317,6 +5624,23 @@ UPB_INLINE const google_protobuf_EnumValueDescriptorProto* const* google_protobu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_value_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_value_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_value(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_value(msg, &size); google_protobuf_EnumDescriptorProto_value(msg, &size);
@ -5352,6 +5676,23 @@ UPB_INLINE const google_protobuf_EnumDescriptorProto_EnumReservedRange* const* g
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_range_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {4, UPB_SIZE(12, 40), 0, 2, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_range(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_reserved_range(msg, &size); google_protobuf_EnumDescriptorProto_reserved_range(msg, &size);
@ -5372,6 +5713,23 @@ UPB_INLINE upb_StringView const* google_protobuf_EnumDescriptorProto_reserved_na
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumDescriptorProto_reserved_name_mutable_upb_array(const google_protobuf_EnumDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {5, UPB_SIZE(16, 48), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_name(const google_protobuf_EnumDescriptorProto* msg) { UPB_INLINE bool google_protobuf_EnumDescriptorProto_has_reserved_name(const google_protobuf_EnumDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_EnumDescriptorProto_reserved_name(msg, &size); google_protobuf_EnumDescriptorProto_reserved_name(msg, &size);
@ -5713,6 +6071,23 @@ UPB_INLINE const google_protobuf_MethodDescriptorProto* const* google_protobuf_S
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ServiceDescriptorProto_method_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ServiceDescriptorProto_method_mutable_upb_array(const google_protobuf_ServiceDescriptorProto* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 24), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto* msg) { UPB_INLINE bool google_protobuf_ServiceDescriptorProto_has_method(const google_protobuf_ServiceDescriptorProto* msg) {
size_t size; size_t size;
google_protobuf_ServiceDescriptorProto_method(msg, &size); google_protobuf_ServiceDescriptorProto_method(msg, &size);
@ -6286,6 +6661,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Fil
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FileOptions_uninterpreted_option_upb_array(const google_protobuf_FileOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(20, 184), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FileOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FileOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(20, 184), 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions* msg) { UPB_INLINE bool google_protobuf_FileOptions_has_uninterpreted_option(const google_protobuf_FileOptions* msg) {
size_t size; size_t size;
google_protobuf_FileOptions_uninterpreted_option(msg, &size); google_protobuf_FileOptions_uninterpreted_option(msg, &size);
@ -6524,6 +6916,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Mes
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_upb_array(const google_protobuf_MessageOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 8, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_MessageOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MessageOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 8, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions* msg) { UPB_INLINE bool google_protobuf_MessageOptions_has_uninterpreted_option(const google_protobuf_MessageOptions* msg) {
size_t size; size_t size;
google_protobuf_MessageOptions_uninterpreted_option(msg, &size); google_protobuf_MessageOptions_uninterpreted_option(msg, &size);
@ -6747,18 +7156,18 @@ UPB_INLINE bool google_protobuf_FieldOptions_has_retention(const google_protobuf
const upb_MiniTableField field = {17, 20, 9, 2, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {17, 20, 9, 2, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
return _upb_Message_HasNonExtensionField(msg, &field); return _upb_Message_HasNonExtensionField(msg, &field);
} }
UPB_INLINE void google_protobuf_FieldOptions_clear_target(google_protobuf_FieldOptions* msg) { UPB_INLINE void google_protobuf_FieldOptions_clear_target_obsolete_do_not_use(google_protobuf_FieldOptions* msg) {
const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
_upb_Message_ClearNonExtensionField(msg, &field); _upb_Message_ClearNonExtensionField(msg, &field);
} }
UPB_INLINE int32_t google_protobuf_FieldOptions_target(const google_protobuf_FieldOptions* msg) { UPB_INLINE int32_t google_protobuf_FieldOptions_target_obsolete_do_not_use(const google_protobuf_FieldOptions* msg) {
int32_t default_val = 0; int32_t default_val = 0;
int32_t ret; int32_t ret;
const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
_upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret);
return ret; return ret;
} }
UPB_INLINE bool google_protobuf_FieldOptions_has_target(const google_protobuf_FieldOptions* msg) { UPB_INLINE bool google_protobuf_FieldOptions_has_target_obsolete_do_not_use(const google_protobuf_FieldOptions* msg) {
const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
return _upb_Message_HasNonExtensionField(msg, &field); return _upb_Message_HasNonExtensionField(msg, &field);
} }
@ -6777,6 +7186,23 @@ UPB_INLINE int32_t const* google_protobuf_FieldOptions_targets(const google_prot
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_targets_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) {
const upb_MiniTableField field = {19, UPB_SIZE(28, 32), 0, 4, 14, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FieldOptions_targets_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {19, UPB_SIZE(28, 32), 0, 4, 14, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FieldOptions_has_targets(const google_protobuf_FieldOptions* msg) { UPB_INLINE bool google_protobuf_FieldOptions_has_targets(const google_protobuf_FieldOptions* msg) {
size_t size; size_t size;
google_protobuf_FieldOptions_targets(msg, &size); google_protobuf_FieldOptions_targets(msg, &size);
@ -6797,6 +7223,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Fie
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_upb_array(const google_protobuf_FieldOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(32, 40), 0, 5, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_FieldOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_FieldOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(32, 40), 0, 5, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions* msg) { UPB_INLINE bool google_protobuf_FieldOptions_has_uninterpreted_option(const google_protobuf_FieldOptions* msg) {
size_t size; size_t size;
google_protobuf_FieldOptions_uninterpreted_option(msg, &size); google_protobuf_FieldOptions_uninterpreted_option(msg, &size);
@ -6839,7 +7282,7 @@ UPB_INLINE void google_protobuf_FieldOptions_set_retention(google_protobuf_Field
const upb_MiniTableField field = {17, 20, 9, 2, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {17, 20, 9, 2, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
_upb_Message_SetNonExtensionField(msg, &field, &value); _upb_Message_SetNonExtensionField(msg, &field, &value);
} }
UPB_INLINE void google_protobuf_FieldOptions_set_target(google_protobuf_FieldOptions *msg, int32_t value) { UPB_INLINE void google_protobuf_FieldOptions_set_target_obsolete_do_not_use(google_protobuf_FieldOptions *msg, int32_t value) {
const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)}; const upb_MiniTableField field = {18, 24, 10, 3, 14, kUpb_FieldMode_Scalar | (kUpb_FieldRep_4Byte << kUpb_FieldRep_Shift)};
_upb_Message_SetNonExtensionField(msg, &field, &value); _upb_Message_SetNonExtensionField(msg, &field, &value);
} }
@ -6944,6 +7387,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_One
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_upb_array(const google_protobuf_OneofOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_OneofOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_OneofOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions* msg) { UPB_INLINE bool google_protobuf_OneofOptions_has_uninterpreted_option(const google_protobuf_OneofOptions* msg) {
size_t size; size_t size;
google_protobuf_OneofOptions_uninterpreted_option(msg, &size); google_protobuf_OneofOptions_uninterpreted_option(msg, &size);
@ -7072,6 +7532,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Enu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_upb_array(const google_protobuf_EnumOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions* msg) { UPB_INLINE bool google_protobuf_EnumOptions_has_uninterpreted_option(const google_protobuf_EnumOptions* msg) {
size_t size; size_t size;
google_protobuf_EnumOptions_uninterpreted_option(msg, &size); google_protobuf_EnumOptions_uninterpreted_option(msg, &size);
@ -7182,6 +7659,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Enu
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_EnumValueOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_EnumValueOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions* msg) { UPB_INLINE bool google_protobuf_EnumValueOptions_has_uninterpreted_option(const google_protobuf_EnumValueOptions* msg) {
size_t size; size_t size;
google_protobuf_EnumValueOptions_uninterpreted_option(msg, &size); google_protobuf_EnumValueOptions_uninterpreted_option(msg, &size);
@ -7284,6 +7778,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Ser
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_ServiceOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_ServiceOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions* msg) { UPB_INLINE bool google_protobuf_ServiceOptions_has_uninterpreted_option(const google_protobuf_ServiceOptions* msg) {
size_t size; size_t size;
google_protobuf_ServiceOptions_uninterpreted_option(msg, &size); google_protobuf_ServiceOptions_uninterpreted_option(msg, &size);
@ -7401,6 +7912,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption* const* google_protobuf_Met
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_upb_array(const google_protobuf_MethodOptions* msg, size_t* size) {
const upb_MiniTableField field = {999, 8, 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_MethodOptions_uninterpreted_option_mutable_upb_array(const google_protobuf_MethodOptions* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {999, 8, 0, 1, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions* msg) { UPB_INLINE bool google_protobuf_MethodOptions_has_uninterpreted_option(const google_protobuf_MethodOptions* msg) {
size_t size; size_t size;
google_protobuf_MethodOptions_uninterpreted_option(msg, &size); google_protobuf_MethodOptions_uninterpreted_option(msg, &size);
@ -7492,6 +8020,23 @@ UPB_INLINE const google_protobuf_UninterpretedOption_NamePart* const* google_pro
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_UninterpretedOption_name_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_UninterpretedOption_name_mutable_upb_array(const google_protobuf_UninterpretedOption* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(4, 8), 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption* msg) { UPB_INLINE bool google_protobuf_UninterpretedOption_has_name(const google_protobuf_UninterpretedOption* msg) {
size_t size; size_t size;
google_protobuf_UninterpretedOption_name(msg, &size); google_protobuf_UninterpretedOption_name(msg, &size);
@ -7764,6 +8309,23 @@ UPB_INLINE const google_protobuf_SourceCodeInfo_Location* const* google_protobuf
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_location_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_location_mutable_upb_array(const google_protobuf_SourceCodeInfo* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_has_location(const google_protobuf_SourceCodeInfo* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_location(msg, &size); google_protobuf_SourceCodeInfo_location(msg, &size);
@ -7847,6 +8409,23 @@ UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_path(const goo
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_path_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_path_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 8), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_path(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_path(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_path(msg, &size); google_protobuf_SourceCodeInfo_Location_path(msg, &size);
@ -7867,6 +8446,23 @@ UPB_INLINE int32_t const* google_protobuf_SourceCodeInfo_Location_span(const goo
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_span_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_span_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {2, UPB_SIZE(8, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_span(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_span(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_span(msg, &size); google_protobuf_SourceCodeInfo_Location_span(msg, &size);
@ -7917,6 +8513,23 @@ UPB_INLINE upb_StringView const* google_protobuf_SourceCodeInfo_Location_leading
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size) {
const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_SourceCodeInfo_Location_leading_detached_comments_mutable_upb_array(const google_protobuf_SourceCodeInfo_Location* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {6, UPB_SIZE(12, 56), 0, kUpb_NoSub, 12, kUpb_FieldMode_Array | kUpb_LabelFlags_IsAlternate | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg) { UPB_INLINE bool google_protobuf_SourceCodeInfo_Location_has_leading_detached_comments(const google_protobuf_SourceCodeInfo_Location* msg) {
size_t size; size_t size;
google_protobuf_SourceCodeInfo_Location_leading_detached_comments(msg, &size); google_protobuf_SourceCodeInfo_Location_leading_detached_comments(msg, &size);
@ -8054,6 +8667,23 @@ UPB_INLINE const google_protobuf_GeneratedCodeInfo_Annotation* const* google_pro
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_annotation_mutable_upb_array(const google_protobuf_GeneratedCodeInfo* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, 0, 0, 0, 11, kUpb_FieldMode_Array | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo* msg) { UPB_INLINE bool google_protobuf_GeneratedCodeInfo_has_annotation(const google_protobuf_GeneratedCodeInfo* msg) {
size_t size; size_t size;
google_protobuf_GeneratedCodeInfo_annotation(msg, &size); google_protobuf_GeneratedCodeInfo_annotation(msg, &size);
@ -8137,6 +8767,23 @@ UPB_INLINE int32_t const* google_protobuf_GeneratedCodeInfo_Annotation_path(cons
return NULL; return NULL;
} }
} }
UPB_INLINE const upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
const upb_Array* arr = upb_Message_GetArray(msg, &field);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE upb_Array* _google_protobuf_GeneratedCodeInfo_Annotation_path_mutable_upb_array(const google_protobuf_GeneratedCodeInfo_Annotation* msg, size_t* size, upb_Arena* arena) {
const upb_MiniTableField field = {1, UPB_SIZE(4, 16), 0, kUpb_NoSub, 5, kUpb_FieldMode_Array | kUpb_LabelFlags_IsPacked | (UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)};
upb_Array* arr = upb_Message_GetOrCreateMutableArray(
(upb_Message*)msg, &field, arena);
if (size) {
*size = arr ? arr->size : 0;
}
return arr;
}
UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg) { UPB_INLINE bool google_protobuf_GeneratedCodeInfo_Annotation_has_path(const google_protobuf_GeneratedCodeInfo_Annotation* msg) {
size_t size; size_t size;
google_protobuf_GeneratedCodeInfo_Annotation_path(msg, &size); google_protobuf_GeneratedCodeInfo_Annotation_path(msg, &size);

@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "google-protobuf" s.name = "google-protobuf"
s.version = "3.22.3" s.version = "3.23.0"
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 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.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers" s.summary = "Protocol Buffers"

@ -9,7 +9,7 @@
<groupId>com.google.protobuf.jruby</groupId> <groupId>com.google.protobuf.jruby</groupId>
<artifactId>protobuf-jruby</artifactId> <artifactId>protobuf-jruby</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
<name>Protocol Buffer JRuby native extension</name> <name>Protocol Buffer JRuby native extension</name>
<description> <description>
Protocol Buffers are a way of encoding structured data in an efficient yet Protocol Buffers are a way of encoding structured data in an efficient yet
@ -76,7 +76,7 @@
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>
<version>3.22.3</version> <version>3.23.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jruby</groupId> <groupId>org.jruby</groupId>

@ -9,6 +9,19 @@ package(
default_visibility = ["//src/google/protobuf:__subpackages__"], default_visibility = ["//src/google/protobuf:__subpackages__"],
) )
# Represents the current Rust protobuf runtime for the build. Depending on the value of
# `:rust_proto_library_kernel` build setting it forwards to the cpp or upb kernels. This is the
# target that users are expected to depend on.
#
# Rust gencode (via `rust_upb_proto_library` and `rust_cc_proto_library`) doesn't depend on this
# target, instead, it depends on the kernel-specific libraries directly. The reason is that we need
# to be able to use both kernels in the same build. That allows us to have one tap config for both
# kernels, and to run tests using a single Blaze invocation.
#
# WARNING: It's critical that users do not end up using Rust Protobufs with multiple kernels in
# their binaries. Currently this is achieved by using bzl visibility on kernel specific rules.
# TODO(b/149440343): Hide the kernel-specific targets once we can restrict a target visibility to a
# rule.
rust_library( rust_library(
name = "protobuf", name = "protobuf",
srcs = ["protobuf.rs"], srcs = ["protobuf.rs"],
@ -22,6 +35,17 @@ rust_library(
}), }),
) )
# Represents Rust Protobuf runtime using the upb kernel.
#
# `rust_upb_proto_library` implicitly depends on this target. This target cannot depend on
# `:rust_proto_library_kernel` build setting; it has to be fully functional under any value of that
# setting.
#
# `shared.rs` contains kernel-agnostic logic and simple kernel-specific logic controlled by
# `#[cfg(...)]` attributes. That forces us to compile this file twice, once for each kernel. As a
# result this file is declared in both `:protobuf_upb` and `:protobuf_cpp`. This is in principle
# identical to how we compile regular Rust source files twice (once for production, and once for
# unittesting).
rust_library( rust_library(
name = "protobuf_upb", name = "protobuf_upb",
srcs = ["shared.rs"], srcs = ["shared.rs"],
@ -36,13 +60,16 @@ rust_test(
tags = [ tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. # TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm", "not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
], ],
) )
# Represents Rust Protobuf runtime using the cpp kernel.
#
# `rust_cpp_proto_library` implicitly depends on this target. This target cannot depend on
# `:rust_proto_library_kernel` build setting; it has to be fully functional under any value of that
# setting.
#
# See the comment for `:protobuf` for discussion of `shared.rs` file.
rust_library( rust_library(
name = "protobuf_cpp", name = "protobuf_cpp",
srcs = ["shared.rs"], srcs = ["shared.rs"],
@ -57,14 +84,9 @@ rust_test(
tags = [ tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. # TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm", "not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
], ],
) )
# TODO(b/270125787): Move to the right location once rust_proto_library is no longer experimental.
proto_lang_toolchain( proto_lang_toolchain(
name = "proto_rust_upb_toolchain", name = "proto_rust_upb_toolchain",
command_line = "--rust_out=experimental-codegen=enabled,kernel=upb:$(OUT)", command_line = "--rust_out=experimental-codegen=enabled,kernel=upb:$(OUT)",

@ -169,6 +169,7 @@ def _compile_rust(ctx, attr, src, extra_srcs, deps):
lib = ctx.actions.declare_file(lib_name) lib = ctx.actions.declare_file(lib_name)
rmeta = ctx.actions.declare_file(rmeta_name) rmeta = ctx.actions.declare_file(rmeta_name)
# TODO(b/270125787): Use higher level rules_rust API once available.
providers = rustc_compile_action( providers = rustc_compile_action(
ctx = ctx, ctx = ctx,
attr = attr, attr = attr,

@ -17,10 +17,6 @@ rust_test(
tags = [ tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. # TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm", "not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
], ],
) )

@ -50,8 +50,6 @@ use std::slice;
/// dropped. /// dropped.
/// ///
/// Note that this type is neither `Sync` nor `Send`. /// Note that this type is neither `Sync` nor `Send`.
///
/// TODO(b/272728844): Replace this placeholder code with a real implementation.
pub struct Arena { pub struct Arena {
ptr: NonNull<u8>, ptr: NonNull<u8>,
_not_sync: PhantomData<UnsafeCell<()>>, _not_sync: PhantomData<UnsafeCell<()>>,

@ -41,6 +41,7 @@ pub extern crate upb as __runtime;
pub use __runtime::SerializedData; pub use __runtime::SerializedData;
use std::fmt; use std::fmt;
use std::slice;
/// Represents error during deserialization. /// Represents error during deserialization.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -55,8 +56,15 @@ impl fmt::Display for ParseError {
/// Represents an ABI-stable version of &[u8]/string_view (a borrowed slice of /// Represents an ABI-stable version of &[u8]/string_view (a borrowed slice of
/// bytes) for FFI use only. /// bytes) for FFI use only.
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)]
pub struct PtrAndLen { pub struct PtrAndLen {
/// Borrows the memory. /// Borrows the memory.
pub ptr: *const u8, pub ptr: *const u8,
pub len: usize, pub len: usize,
} }
impl PtrAndLen {
pub unsafe fn as_ref<'a>(self) -> &'a [u8] {
slice::from_raw_parts(self.ptr, self.len)
}
}

@ -6,6 +6,7 @@ cc_library(
name = "test_utils", name = "test_utils",
srcs = ["test_utils.cc"], srcs = ["test_utils.cc"],
deps = [ deps = [
"//third_party/absl/strings",
"//rust/cpp_kernel:cpp_api", "//rust/cpp_kernel:cpp_api",
"//rust/test:unittest_cc_proto", "//rust/test:unittest_cc_proto",
], ],

@ -29,45 +29,89 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use std::ptr::NonNull; use std::ptr::NonNull;
use unittest_proto::proto2_unittest::TestAllExtensions;
use unittest_proto::proto2_unittest::TestAllTypes; use unittest_proto::proto2_unittest::TestAllTypes;
macro_rules! assert_serializes_equally { macro_rules! proto_assert_eq {
($msg:ident) => {{ ($lhs:expr, $rhs:expr) => {{
let mut msg = $msg; let lhs = &$lhs;
let serialized_cpp = let rhs = &$rhs;
unsafe { Serialize(msg.__unstable_cpp_repr_grant_permission_to_break()) };
let serialized_rs = msg.serialize();
assert_eq!(*serialized_rs, *serialized_cpp); assert_eq!(lhs.optional_int64(), rhs.optional_int64());
assert_eq!(lhs.optional_bytes(), rhs.optional_bytes());
assert_eq!(lhs.optional_bool(), rhs.optional_bool());
}}; }};
} }
// Helper functions invoking C++ Protobuf APIs directly in C++.
// Defined in `test_utils.cc`.
extern "C" {
fn DeserializeTestAllTypes(data: *const u8, len: usize) -> NonNull<u8>;
fn MutateTestAllTypes(msg: NonNull<u8>);
fn SerializeTestAllTypes(msg: NonNull<u8>) -> protobuf_cpp::SerializedData;
fn NewWithExtension() -> NonNull<u8>;
fn GetBytesExtension(msg: NonNull<u8>) -> protobuf_cpp::PtrAndLen;
}
#[test] #[test]
fn mutate_message_in_cpp() { fn mutate_message_in_cpp() {
let mut msg = TestAllTypes::new(); let mut msg1 = TestAllTypes::new();
unsafe { MutateInt64Field(msg.__unstable_cpp_repr_grant_permission_to_break()) }; unsafe {
assert_serializes_equally!(msg); MutateTestAllTypes(msg1.__unstable_cpp_repr_grant_permission_to_break());
}
let mut msg2 = TestAllTypes::new();
msg2.optional_int64_set(Some(42));
msg2.optional_bytes_set(Some(b"something mysterious"));
msg2.optional_bool_set(Some(false));
proto_assert_eq!(msg1, msg2);
} }
#[test] #[test]
fn mutate_message_in_rust() { fn deserialize_in_rust() {
let mut msg = TestAllTypes::new(); let mut msg1 = TestAllTypes::new();
msg.optional_int64_set(Some(43)); msg1.optional_int64_set(Some(-1));
assert_serializes_equally!(msg); msg1.optional_bytes_set(Some(b"some cool data I guess"));
let serialized =
unsafe { SerializeTestAllTypes(msg1.__unstable_cpp_repr_grant_permission_to_break()) };
let mut msg2 = TestAllTypes::new();
msg2.deserialize(&serialized).unwrap();
proto_assert_eq!(msg1, msg2);
} }
#[test] #[test]
fn deserialize_message_in_rust() { fn deserialize_in_cpp() {
let serialized = unsafe { SerializeMutatedInstance() }; let mut msg1 = TestAllTypes::new();
let mut msg = TestAllTypes::new(); msg1.optional_int64_set(Some(-1));
msg.deserialize(&serialized).unwrap(); msg1.optional_bytes_set(Some(b"some cool data I guess"));
assert_serializes_equally!(msg); let data = msg1.serialize();
let msg2 = unsafe {
TestAllTypes::__unstable_wrap_cpp_grant_permission_to_break(DeserializeTestAllTypes(
data.as_ptr(),
data.len(),
))
};
proto_assert_eq!(msg1, msg2);
} }
// Helper functions invoking C++ Protobuf APIs directly in C++. Defined in // This test ensures that random fields we (Rust) don't know about don't
// `//third_party/protobuf/rust/test/cpp/interop:test_utils`. // accidentally get destroyed by Rust.
extern "C" { #[test]
fn SerializeMutatedInstance() -> protobuf_cpp::SerializedData; fn smuggle_extension() {
fn MutateInt64Field(msg: NonNull<u8>); let msg1 = unsafe {
fn Serialize(msg: NonNull<u8>) -> protobuf_cpp::SerializedData; TestAllExtensions::__unstable_wrap_cpp_grant_permission_to_break(NewWithExtension())
};
let data = msg1.serialize();
let mut msg2 = TestAllExtensions::new();
msg2.deserialize(&data).unwrap();
let bytes = unsafe {
GetBytesExtension(msg2.__unstable_cpp_repr_grant_permission_to_break()).as_ref()
};
assert_eq!(&*bytes, b"smuggled");
} }

@ -28,22 +28,38 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream> #include <cstddef>
#include "absl/strings/string_view.h"
#include "google/protobuf/rust/cpp_kernel/cpp_api.h" #include "google/protobuf/rust/cpp_kernel/cpp_api.h"
#include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest.pb.h"
extern "C" void MutateInt64Field(protobuf_unittest::TestAllTypes* msg) { extern "C" void MutateTestAllTypes(protobuf_unittest::TestAllTypes* msg) {
msg->set_optional_int64(42); msg->set_optional_int64(42);
msg->set_optional_bytes("something mysterious");
msg->set_optional_bool(false);
} }
extern "C" google::protobuf::rust_internal::SerializedData Serialize( extern "C" google::protobuf::rust_internal::SerializedData SerializeTestAllTypes(
const protobuf_unittest::TestAllTypes* msg) { const protobuf_unittest::TestAllTypes* msg) {
return google::protobuf::rust_internal::SerializeMsg(msg); return google::protobuf::rust_internal::SerializeMsg(msg);
} }
extern "C" google::protobuf::rust_internal::SerializedData SerializeMutatedInstance() { extern "C" void* DeserializeTestAllTypes(const void* data, size_t size) {
protobuf_unittest::TestAllTypes* inst = new protobuf_unittest::TestAllTypes(); auto* proto = new protobuf_unittest::TestAllTypes;
MutateInt64Field(inst); proto->ParseFromArray(data, size);
return Serialize(inst); return proto;
}
extern "C" void* NewWithExtension() {
auto* proto = new protobuf_unittest::TestAllExtensions;
proto->SetExtension(protobuf_unittest::optional_bytes_extension, "smuggled");
return proto;
}
extern "C" google::protobuf::rust_internal::PtrAndLen GetBytesExtension(
const protobuf_unittest::TestAllExtensions* proto) {
absl::string_view bytes =
proto->GetExtension(protobuf_unittest::optional_bytes_extension);
return {bytes.data(), bytes.size()};
} }

@ -16,44 +16,12 @@
load("@rules_rust//rust:defs.bzl", "rust_test") load("@rules_rust//rust:defs.bzl", "rust_test")
rust_test(
name = "unittest_proto_upb_test",
srcs = ["unittest_proto_test.rs"],
tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
],
deps = ["//rust/test:unittest_upb_rust_proto"],
)
rust_test(
name = "unittest_proto_cpp_test",
srcs = ["unittest_proto_test.rs"],
tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
],
deps = ["//rust/test:unittest_cc_rust_proto"],
)
rust_test( rust_test(
name = "child_parent_upb_test", name = "child_parent_upb_test",
srcs = ["child_parent_test.rs"], srcs = ["child_parent_test.rs"],
tags = [ tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. # TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm", "not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
], ],
deps = [ deps = [
"//rust/test:child_upb_rust_proto", "//rust/test:child_upb_rust_proto",
@ -141,3 +109,23 @@ rust_test(
], ],
deps = ["//rust/test:unittest_upb_rust_proto"], deps = ["//rust/test:unittest_upb_rust_proto"],
) )
rust_test(
name = "serialization_upb_test",
srcs = ["serialization_test.rs"],
tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm",
],
deps = ["//rust/test:unittest_upb_rust_proto"],
)
rust_test(
name = "serialization_cpp_test",
srcs = ["serialization_test.rs"],
tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm",
],
deps = ["//rust/test:unittest_cc_rust_proto"],
)

@ -0,0 +1,61 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2023 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.
use unittest_proto::proto2_unittest::TestAllTypes;
#[test]
fn serialize_deserialize_message() {
let mut msg = TestAllTypes::new();
msg.optional_int64_set(Some(42));
msg.optional_bool_set(Some(true));
msg.optional_bytes_set(Some(b"serialize deserialize test"));
let serialized = msg.serialize();
let mut msg2 = TestAllTypes::new();
assert!(msg2.deserialize(&serialized).is_ok());
assert_eq!(msg.optional_int64(), msg2.optional_int64());
assert_eq!(msg.optional_bool(), msg2.optional_bool());
assert_eq!(msg.optional_bytes(), msg2.optional_bytes());
}
#[test]
fn deserialize_empty() {
let mut msg = TestAllTypes::new();
assert!(msg.deserialize(&[]).is_ok());
}
#[test]
fn deserialize_error() {
let mut msg = TestAllTypes::new();
let data = b"not a serialized proto";
assert!(msg.deserialize(&*data).is_err());
}

@ -18,10 +18,6 @@ rust_test(
tags = [ tags = [
# TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain. # TODO(b/270274576): Enable testing on arm once we have a Rust Arm toolchain.
"not_build:arm", "not_build:arm",
# TODO(b/243126140): Enable tsan once we support sanitizers with Rust.
"notsan",
# TODO(b/243126140): Enable msan once we support sanitizers with Rust.
"nomsan",
], ],
) )

@ -278,6 +278,8 @@ set(libprotobuf_lite_hdrs
# @//pkg:protoc # @//pkg:protoc
set(libprotoc_srcs set(libprotoc_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/empty_package.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/empty_package.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/open_enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/unused_imports.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/weak_imports.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/allowlists/weak_imports.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc
@ -554,6 +556,7 @@ set(common_test_srcs
# @//pkg:common_test # @//pkg:common_test
set(common_test_hdrs set(common_test_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.h ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_textproto.h
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.h ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.h
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.h ${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.h
) )
@ -748,6 +751,7 @@ set(util_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format.proto ${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format_proto3.proto ${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.proto ${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest_proto3.proto
) )
# @//src/google/protobuf/stubs:test_srcs # @//src/google/protobuf/stubs:test_srcs

@ -810,6 +810,7 @@ cc_library(
deps = [ deps = [
":cc_lite_test_protos", ":cc_lite_test_protos",
":test_util2", ":test_util2",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_check",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
], ],
@ -848,6 +849,7 @@ cc_library(
"//src/google/protobuf/testing", "//src/google/protobuf/testing",
"@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
], ],
) )
@ -960,6 +962,7 @@ cc_test(
":cc_test_protos", ":cc_test_protos",
":descriptor_legacy", ":descriptor_legacy",
":protobuf", ":protobuf",
":test_textproto",
"//src/google/protobuf/compiler:importer", "//src/google/protobuf/compiler:importer",
"//src/google/protobuf/testing", "//src/google/protobuf/testing",
"@com_google_absl//absl/log:die_if_null", "@com_google_absl//absl/log:die_if_null",
@ -970,6 +973,20 @@ cc_test(
], ],
) )
cc_library(
name = "test_textproto",
testonly = True,
hdrs = ["test_textproto.h"],
strip_include_prefix = "/src",
visibility = ["//pkg:__pkg__"],
deps = [
":protobuf",
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/memory",
"@com_google_googletest//:gtest",
],
)
cc_test( cc_test(
name = "drop_unknown_fields_test", name = "drop_unknown_fields_test",
srcs = ["drop_unknown_fields_test.cc"], srcs = ["drop_unknown_fields_test.cc"],
@ -1296,9 +1313,13 @@ cc_test(
}), }),
deps = [ deps = [
":cc_test_protos", ":cc_test_protos",
":lite_test_util",
":protobuf", ":protobuf",
":protobuf_lite",
"//src/google/protobuf/io",
"//src/google/protobuf/stubs", "//src/google/protobuf/stubs",
"//src/google/protobuf/testing", "//src/google/protobuf/testing",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
], ],

@ -16,13 +16,14 @@
// Must be included last. // Must be included last.
#include "google/protobuf/port_def.inc" #include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::PROTOBUF_NAMESPACE_ID; namespace _pb = ::google::protobuf;
namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; namespace _pbi = ::google::protobuf::internal;
#if defined(__llvm__) #if defined(__llvm__)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wuninitialized" #pragma clang diagnostic ignored "-Wuninitialized"
#endif // __llvm__ #endif // __llvm__
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
PROTOBUF_CONSTEXPR Any::Any( PROTOBUF_CONSTEXPR Any::Any(
::_pbi::ConstantInitialized): _impl_{ ::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.type_url_)*/ { /*decltype(_impl_.type_url_)*/ {
@ -45,7 +46,8 @@ struct AnyDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_; PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 AnyDefaultTypeInternal _Any_default_instance_;
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1]; static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fany_2eproto[1];
static constexpr const ::_pb::EnumDescriptor** static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr; file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
@ -54,24 +56,24 @@ static constexpr const ::_pb::ServiceDescriptor**
const ::uint32_t TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( const ::uint32_t TableStruct_google_2fprotobuf_2fany_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
protodesc_cold) = { protodesc_cold) = {
~0u, // no _has_bits_ ~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _internal_metadata_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, _internal_metadata_),
~0u, // no _extensions_ ~0u, // no _extensions_
~0u, // no _oneof_case_ ~0u, // no _oneof_case_
~0u, // no _weak_field_map_ ~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_ ~0u, // no _inlined_string_donated_
~0u, // no _split_ ~0u, // no _split_
~0u, // no sizeof(Split) ~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.type_url_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, _impl_.type_url_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _impl_.value_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Any, _impl_.value_),
}; };
static const ::_pbi::MigrationSchema static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Any)}, {0, -1, -1, sizeof(::google::protobuf::Any)},
}; };
static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {
&::PROTOBUF_NAMESPACE_ID::_Any_default_instance_._instance, &::google::protobuf::_Any_default_instance_._instance,
}; };
const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { const char descriptor_table_protodef_google_2fprotobuf_2fany_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
"\n\031google/protobuf/any.proto\022\017google.prot" "\n\031google/protobuf/any.proto\022\017google.prot"
@ -117,13 +119,14 @@ PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2
// Force running AddDescriptors() at dynamic initialization time. // Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto); static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fany_2eproto(&descriptor_table_google_2fprotobuf_2fany_2eproto);
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
// =================================================================== // ===================================================================
bool Any::GetAnyFieldDescriptors( bool Any::GetAnyFieldDescriptors(
const ::PROTOBUF_NAMESPACE_ID::Message& message, const ::google::protobuf::Message& message,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field, const ::google::protobuf::FieldDescriptor** type_url_field,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field) { const ::google::protobuf::FieldDescriptor** value_field) {
return ::_pbi::GetAnyFieldDescriptors( return ::_pbi::GetAnyFieldDescriptors(
message, type_url_field, value_field); message, type_url_field, value_field);
} }
@ -137,13 +140,13 @@ class Any::_Internal {
public: public:
}; };
Any::Any(::PROTOBUF_NAMESPACE_ID::Arena* arena) Any::Any(::google::protobuf::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) { : ::google::protobuf::Message(arena) {
SharedCtor(arena); SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Any) // @@protoc_insertion_point(arena_constructor:google.protobuf.Any)
} }
Any::Any(const Any& from) Any::Any(const Any& from)
: ::PROTOBUF_NAMESPACE_ID::Message() { : ::google::protobuf::Message() {
Any* const _this = this; (void)_this; Any* const _this = this; (void)_this;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_.type_url_) {} decltype(_impl_.type_url_) {}
@ -153,7 +156,7 @@ Any::Any(const Any& from)
, /*decltype(_impl_._cached_size_)*/{} , /*decltype(_impl_._cached_size_)*/{}
, /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}}; , /*decltype(_impl_._any_metadata_)*/{&_impl_.type_url_, &_impl_.value_}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
_impl_.type_url_.InitDefault(); _impl_.type_url_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.type_url_.Set("", GetArenaForAllocation()); _impl_.type_url_.Set("", GetArenaForAllocation());
@ -193,7 +196,7 @@ inline void Any::SharedCtor(::_pb::Arena* arena) {
Any::~Any() { Any::~Any() {
// @@protoc_insertion_point(destructor:google.protobuf.Any) // @@protoc_insertion_point(destructor:google.protobuf.Any)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
(void)arena; (void)arena;
return; return;
} }
@ -211,7 +214,7 @@ void Any::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size); _impl_._cached_size_.Set(size);
} }
void Any::Clear() { PROTOBUF_NOINLINE void Any::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Any) // @@protoc_insertion_point(message_clear_start:google.protobuf.Any)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
@ -219,7 +222,7 @@ void Any::Clear() {
_impl_.type_url_.ClearToEmpty(); _impl_.type_url_.ClearToEmpty();
_impl_.value_.ClearToEmpty(); _impl_.value_.ClearToEmpty();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
} }
const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
@ -260,7 +263,7 @@ const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
} }
ptr = UnknownFieldParse( ptr = UnknownFieldParse(
tag, tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(),
ptr, ctx); ptr, ctx);
CHK_(ptr != nullptr); CHK_(ptr != nullptr);
} // while } // while
@ -273,7 +276,7 @@ failure:
} }
::uint8_t* Any::_InternalSerialize( ::uint8_t* Any::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
@ -281,8 +284,8 @@ failure:
// string type_url = 1; // string type_url = 1;
if (!this->_internal_type_url().empty()) { if (!this->_internal_type_url().empty()) {
const std::string& _s = this->_internal_type_url(); const std::string& _s = this->_internal_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Any.type_url");
target = stream->WriteStringMaybeAliased(1, _s, target); target = stream->WriteStringMaybeAliased(1, _s, target);
} }
@ -294,7 +297,7 @@ failure:
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
} }
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any) // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any)
return target; return target;
@ -310,27 +313,27 @@ failure:
// string type_url = 1; // string type_url = 1;
if (!this->_internal_type_url().empty()) { if (!this->_internal_type_url().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_type_url()); this->_internal_type_url());
} }
// bytes value = 2; // bytes value = 2;
if (!this->_internal_value().empty()) { if (!this->_internal_value().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize(
this->_internal_value()); this->_internal_value());
} }
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
} }
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Any::_class_data_ = { const ::google::protobuf::Message::ClassData Any::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ::google::protobuf::Message::CopyWithSourceCheck,
Any::MergeImpl Any::MergeImpl
}; };
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Any::GetClassData() const { return &_class_data_; } const ::google::protobuf::Message::ClassData*Any::GetClassData() const { return &_class_data_; }
void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { void Any::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) {
auto* const _this = static_cast<Any*>(&to_msg); auto* const _this = static_cast<Any*>(&to_msg);
auto& from = static_cast<const Any&>(from_msg); auto& from = static_cast<const Any&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any) // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
@ -344,7 +347,7 @@ void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
if (!from._internal_value().empty()) { if (!from._internal_value().empty()) {
_this->_internal_set_value(from._internal_value()); _this->_internal_set_value(from._internal_value());
} }
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
} }
void Any::CopyFrom(const Any& from) { void Any::CopyFrom(const Any& from) {
@ -354,7 +357,7 @@ void Any::CopyFrom(const Any& from) {
MergeFrom(from); MergeFrom(from);
} }
bool Any::IsInitialized() const { PROTOBUF_NOINLINE bool Any::IsInitialized() const {
return true; return true;
} }
@ -369,19 +372,22 @@ void Any::InternalSwap(Any* other) {
&other->_impl_.value_, rhs_arena); &other->_impl_.value_, rhs_arena);
} }
::PROTOBUF_NAMESPACE_ID::Metadata Any::GetMetadata() const { ::google::protobuf::Metadata Any::GetMetadata() const {
return ::_pbi::AssignDescriptors( return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once, &descriptor_table_google_2fprotobuf_2fany_2eproto_getter, &descriptor_table_google_2fprotobuf_2fany_2eproto_once,
file_level_metadata_google_2fprotobuf_2fany_2eproto[0]); file_level_metadata_google_2fprotobuf_2fany_2eproto[0]);
} }
// @@protoc_insertion_point(namespace_scope) // @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
PROTOBUF_NAMESPACE_OPEN } // namespace google
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Any* namespace google {
Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Any >(Arena* arena) { namespace protobuf {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Any >(arena); template<> PROTOBUF_NOINLINE ::google::protobuf::Any*
Arena::CreateMaybeMessage< ::google::protobuf::Any >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Any >(arena);
} }
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
#if defined(__llvm__) #if defined(__llvm__)
#pragma clang diagnostic pop #pragma clang diagnostic pop

@ -9,13 +9,13 @@
#include <type_traits> #include <type_traits>
#include "google/protobuf/port_def.inc" #include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 3021000 #if PROTOBUF_VERSION < 4023000
#error "This file was generated by a newer version of protoc which is" #error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update" #error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers." #error "your headers."
#endif // PROTOBUF_VERSION #endif // PROTOBUF_VERSION
#if 4022003 < PROTOBUF_MIN_PROTOC_VERSION #if 4023000 < PROTOBUF_MIN_PROTOC_VERSION
#error "This file was generated by an older version of protoc which is" #error "This file was generated by an older version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please" #error "incompatible with your Protocol Buffer headers. Please"
#error "regenerate this file with a newer version of protoc." #error "regenerate this file with a newer version of protoc."
@ -38,27 +38,32 @@
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto PROTOBUF_EXPORT #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fany_2eproto PROTOBUF_EXPORT
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
namespace internal { namespace internal {
class AnyMetadata; class AnyMetadata;
} // namespace internal } // namespace internal
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
// Internal implementation detail -- do not use these members. // Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto { struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fany_2eproto {
static const ::uint32_t offsets[]; static const ::uint32_t offsets[];
}; };
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable PROTOBUF_EXPORT extern const ::google::protobuf::internal::DescriptorTable
descriptor_table_google_2fprotobuf_2fany_2eproto; descriptor_table_google_2fprotobuf_2fany_2eproto;
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
class Any; class Any;
struct AnyDefaultTypeInternal; struct AnyDefaultTypeInternal;
PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_; PROTOBUF_EXPORT extern AnyDefaultTypeInternal _Any_default_instance_;
template <> template <>
PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::Any* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Any>(Arena*); PROTOBUF_EXPORT ::google::protobuf::Any* Arena::CreateMaybeMessage<::google::protobuf::Any>(Arena*);
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
// =================================================================== // ===================================================================
@ -66,11 +71,11 @@ PROTOBUF_NAMESPACE_OPEN
// ------------------------------------------------------------------- // -------------------------------------------------------------------
class PROTOBUF_EXPORT Any final : class PROTOBUF_EXPORT Any final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ { public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {
public: public:
inline Any() : Any(nullptr) {} inline Any() : Any(nullptr) {}
~Any() override; ~Any() override;
explicit PROTOBUF_CONSTEXPR Any(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); explicit PROTOBUF_CONSTEXPR Any(::google::protobuf::internal::ConstantInitialized);
Any(const Any& from); Any(const Any& from);
Any(Any&& from) noexcept Any(Any&& from) noexcept
@ -96,20 +101,20 @@ class PROTOBUF_EXPORT Any final :
return *this; return *this;
} }
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance);
} }
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>();
} }
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { static const ::google::protobuf::Descriptor* descriptor() {
return GetDescriptor(); return GetDescriptor();
} }
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { static const ::google::protobuf::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor; return default_instance().GetMetadata().descriptor;
} }
static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { static const ::google::protobuf::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection; return default_instance().GetMetadata().reflection;
} }
static const Any& default_instance() { static const Any& default_instance() {
@ -124,31 +129,31 @@ class PROTOBUF_EXPORT Any final :
// implements Any ----------------------------------------------- // implements Any -----------------------------------------------
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message) { bool PackFrom(const ::google::protobuf::Message& message) {
ABSL_DCHECK_NE(&message, this); ABSL_DCHECK_NE(&message, this);
return _impl_._any_metadata_.PackFrom(GetArena(), message); return _impl_._any_metadata_.PackFrom(GetArena(), message);
} }
bool PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message, bool PackFrom(const ::google::protobuf::Message& message,
::absl::string_view type_url_prefix) { ::absl::string_view type_url_prefix) {
ABSL_DCHECK_NE(&message, this); ABSL_DCHECK_NE(&message, this);
return _impl_._any_metadata_.PackFrom(GetArena(), message, type_url_prefix); return _impl_._any_metadata_.PackFrom(GetArena(), message, type_url_prefix);
} }
bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const { bool UnpackTo(::google::protobuf::Message* message) const {
return _impl_._any_metadata_.UnpackTo(message); return _impl_._any_metadata_.UnpackTo(message);
} }
static bool GetAnyFieldDescriptors( static bool GetAnyFieldDescriptors(
const ::PROTOBUF_NAMESPACE_ID::Message& message, const ::google::protobuf::Message& message,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** type_url_field, const ::google::protobuf::FieldDescriptor** type_url_field,
const ::PROTOBUF_NAMESPACE_ID::FieldDescriptor** value_field); const ::google::protobuf::FieldDescriptor** value_field);
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::google::protobuf::Message&>::value>::type>
bool PackFrom(const T& message) { bool PackFrom(const T& message) {
return _impl_._any_metadata_.PackFrom<T>(GetArena(), message); return _impl_._any_metadata_.PackFrom<T>(GetArena(), message);
} }
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::google::protobuf::Message&>::value>::type>
bool PackFrom(const T& message, bool PackFrom(const T& message,
::absl::string_view type_url_prefix) { ::absl::string_view type_url_prefix) {
return _impl_._any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);} return _impl_._any_metadata_.PackFrom<T>(GetArena(), message, type_url_prefix);}
template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::PROTOBUF_NAMESPACE_ID::Message&>::value>::type> template <typename T, class = typename std::enable_if<!std::is_convertible<T, const ::google::protobuf::Message&>::value>::type>
bool UnpackTo(T* message) const { bool UnpackTo(T* message) const {
return _impl_._any_metadata_.UnpackTo<T>(message); return _impl_._any_metadata_.UnpackTo<T>(message);
} }
@ -170,7 +175,7 @@ class PROTOBUF_EXPORT Any final :
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP #endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other); InternalSwap(other);
} else { } else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); ::google::protobuf::internal::GenericSwap(this, other);
} }
} }
void UnsafeArenaSwap(Any* other) { void UnsafeArenaSwap(Any* other) {
@ -181,46 +186,46 @@ class PROTOBUF_EXPORT Any final :
// implements Message ---------------------------------------------- // implements Message ----------------------------------------------
Any* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { Any* New(::google::protobuf::Arena* arena = nullptr) const final {
return CreateMaybeMessage<Any>(arena); return CreateMaybeMessage<Any>(arena);
} }
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; using ::google::protobuf::Message::CopyFrom;
void CopyFrom(const Any& from); void CopyFrom(const Any& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; using ::google::protobuf::Message::MergeFrom;
void MergeFrom( const Any& from) { void MergeFrom( const Any& from) {
Any::MergeImpl(*this, from); Any::MergeImpl(*this, from);
} }
private: private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); static void MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg);
public: public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final; bool IsInitialized() const final;
::size_t ByteSizeLong() const final; ::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final;
::uint8_t* _InternalSerialize( ::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); } int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private: private:
void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); void SharedCtor(::google::protobuf::Arena* arena);
void SharedDtor(); void SharedDtor();
void SetCachedSize(int size) const final; void SetCachedSize(int size) const final;
void InternalSwap(Any* other); void InternalSwap(Any* other);
private: private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; friend class ::google::protobuf::internal::AnyMetadata;
static ::absl::string_view FullMessageName() { static ::absl::string_view FullMessageName() {
return "google.protobuf.Any"; return "google.protobuf.Any";
} }
protected: protected:
explicit Any(::PROTOBUF_NAMESPACE_ID::Arena* arena); explicit Any(::google::protobuf::Arena* arena);
public: public:
static const ClassData _class_data_; static const ClassData _class_data_;
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; const ::google::protobuf::Message::ClassData*GetClassData() const final;
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; ::google::protobuf::Metadata GetMetadata() const final;
// nested types ---------------------------------------------------- // nested types ----------------------------------------------------
@ -233,10 +238,6 @@ class PROTOBUF_EXPORT Any final :
// string type_url = 1; // string type_url = 1;
void clear_type_url() ; void clear_type_url() ;
const std::string& type_url() const; const std::string& type_url() const;
template <typename Arg_ = const std::string&, typename... Args_> template <typename Arg_ = const std::string&, typename... Args_>
void set_type_url(Arg_&& arg, Args_... args); void set_type_url(Arg_&& arg, Args_... args);
std::string* mutable_type_url(); std::string* mutable_type_url();
@ -253,10 +254,6 @@ class PROTOBUF_EXPORT Any final :
// bytes value = 2; // bytes value = 2;
void clear_value() ; void clear_value() ;
const std::string& value() const; const std::string& value() const;
template <typename Arg_ = const std::string&, typename... Args_> template <typename Arg_ = const std::string&, typename... Args_>
void set_value(Arg_&& arg, Args_... args); void set_value(Arg_&& arg, Args_... args);
std::string* mutable_value(); std::string* mutable_value();
@ -274,14 +271,14 @@ class PROTOBUF_EXPORT Any final :
private: private:
class _Internal; class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; template <typename T> friend class ::google::protobuf::Arena::InternalHelper;
typedef void InternalArenaConstructable_; typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_; typedef void DestructorSkippable_;
struct Impl_ { struct Impl_ {
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr type_url_; ::google::protobuf::internal::ArenaStringPtr type_url_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr value_; ::google::protobuf::internal::ArenaStringPtr value_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; mutable ::google::protobuf::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata _any_metadata_; ::google::protobuf::internal::AnyMetadata _any_metadata_;
}; };
union { Impl_ _impl_; }; union { Impl_ _impl_; };
friend struct ::TableStruct_google_2fprotobuf_2fany_2eproto; friend struct ::TableStruct_google_2fprotobuf_2fany_2eproto;
@ -328,8 +325,6 @@ inline const std::string& Any::_internal_type_url() const {
} }
inline void Any::_internal_set_type_url(const std::string& value) { inline void Any::_internal_set_type_url(const std::string& value) {
; ;
_impl_.type_url_.Set(value, GetArenaForAllocation()); _impl_.type_url_.Set(value, GetArenaForAllocation());
} }
inline std::string* Any::_internal_mutable_type_url() { inline std::string* Any::_internal_mutable_type_url() {
@ -375,8 +370,6 @@ inline const std::string& Any::_internal_value() const {
} }
inline void Any::_internal_set_value(const std::string& value) { inline void Any::_internal_set_value(const std::string& value) {
; ;
_impl_.value_.Set(value, GetArenaForAllocation()); _impl_.value_.Set(value, GetArenaForAllocation());
} }
inline std::string* Any::_internal_mutable_value() { inline std::string* Any::_internal_mutable_value() {
@ -402,7 +395,8 @@ inline void Any::set_allocated_value(std::string* value) {
#endif // __GNUC__ #endif // __GNUC__
// @@protoc_insertion_point(namespace_scope) // @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)

@ -16,9 +16,10 @@
// Must be included last. // Must be included last.
#include "google/protobuf/port_def.inc" #include "google/protobuf/port_def.inc"
PROTOBUF_PRAGMA_INIT_SEG PROTOBUF_PRAGMA_INIT_SEG
namespace _pb = ::PROTOBUF_NAMESPACE_ID; namespace _pb = ::google::protobuf;
namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; namespace _pbi = ::google::protobuf::internal;
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
PROTOBUF_CONSTEXPR Api::Api( PROTOBUF_CONSTEXPR Api::Api(
::_pbi::ConstantInitialized): _impl_{ ::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_._has_bits_)*/{} /*decltype(_impl_._has_bits_)*/{}
@ -100,7 +101,8 @@ struct MixinDefaultTypeInternal {
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_; PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MixinDefaultTypeInternal _Mixin_default_instance_;
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3]; static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fapi_2eproto[3];
static constexpr const ::_pb::EnumDescriptor** static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
@ -108,21 +110,21 @@ static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr; file_level_service_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
const ::uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( const ::uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(
protodesc_cold) = { protodesc_cold) = {
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_._has_bits_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_._has_bits_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _internal_metadata_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _internal_metadata_),
~0u, // no _extensions_ ~0u, // no _extensions_
~0u, // no _oneof_case_ ~0u, // no _oneof_case_
~0u, // no _weak_field_map_ ~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_ ~0u, // no _inlined_string_donated_
~0u, // no _split_ ~0u, // no _split_
~0u, // no sizeof(Split) ~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.name_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.name_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.methods_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.methods_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.options_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.options_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.version_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.version_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.source_context_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.source_context_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.mixins_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.mixins_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _impl_.syntax_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Api, _impl_.syntax_),
~0u, ~0u,
~0u, ~0u,
~0u, ~0u,
@ -131,43 +133,43 @@ const ::uint32_t TableStruct_google_2fprotobuf_2fapi_2eproto::offsets[] PROTOBUF
~0u, ~0u,
~0u, ~0u,
~0u, // no _has_bits_ ~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _internal_metadata_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _internal_metadata_),
~0u, // no _extensions_ ~0u, // no _extensions_
~0u, // no _oneof_case_ ~0u, // no _oneof_case_
~0u, // no _weak_field_map_ ~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_ ~0u, // no _inlined_string_donated_
~0u, // no _split_ ~0u, // no _split_
~0u, // no sizeof(Split) ~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.name_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.name_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_type_url_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.request_type_url_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.request_streaming_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.request_streaming_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_type_url_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.response_type_url_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.response_streaming_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.response_streaming_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.options_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.options_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Method, _impl_.syntax_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Method, _impl_.syntax_),
~0u, // no _has_bits_ ~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _internal_metadata_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, _internal_metadata_),
~0u, // no _extensions_ ~0u, // no _extensions_
~0u, // no _oneof_case_ ~0u, // no _oneof_case_
~0u, // no _weak_field_map_ ~0u, // no _weak_field_map_
~0u, // no _inlined_string_donated_ ~0u, // no _inlined_string_donated_
~0u, // no _split_ ~0u, // no _split_
~0u, // no sizeof(Split) ~0u, // no sizeof(Split)
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.name_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, _impl_.name_),
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Mixin, _impl_.root_), PROTOBUF_FIELD_OFFSET(::google::protobuf::Mixin, _impl_.root_),
}; };
static const ::_pbi::MigrationSchema static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 15, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Api)}, {0, 15, -1, sizeof(::google::protobuf::Api)},
{ 22, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Method)}, {22, -1, -1, sizeof(::google::protobuf::Method)},
{ 37, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::Mixin)}, {37, -1, -1, sizeof(::google::protobuf::Mixin)},
}; };
static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {
&::PROTOBUF_NAMESPACE_ID::_Api_default_instance_._instance, &::google::protobuf::_Api_default_instance_._instance,
&::PROTOBUF_NAMESPACE_ID::_Method_default_instance_._instance, &::google::protobuf::_Method_default_instance_._instance,
&::PROTOBUF_NAMESPACE_ID::_Mixin_default_instance_._instance, &::google::protobuf::_Mixin_default_instance_._instance,
}; };
const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { const char descriptor_table_protodef_google_2fprotobuf_2fapi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
"\n\031google/protobuf/api.proto\022\017google.prot" "\n\031google/protobuf/api.proto\022\017google.prot"
@ -231,7 +233,8 @@ PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2
// Force running AddDescriptors() at dynamic initialization time. // Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto); static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fapi_2eproto(&descriptor_table_google_2fprotobuf_2fapi_2eproto);
PROTOBUF_NAMESPACE_OPEN namespace google {
namespace protobuf {
// =================================================================== // ===================================================================
class Api::_Internal { class Api::_Internal {
@ -239,14 +242,13 @@ class Api::_Internal {
using HasBits = decltype(std::declval<Api>()._impl_._has_bits_); using HasBits = decltype(std::declval<Api>()._impl_._has_bits_);
static constexpr ::int32_t kHasBitsOffset = static constexpr ::int32_t kHasBitsOffset =
8 * PROTOBUF_FIELD_OFFSET(Api, _impl_._has_bits_); 8 * PROTOBUF_FIELD_OFFSET(Api, _impl_._has_bits_);
static const ::PROTOBUF_NAMESPACE_ID::SourceContext& source_context(const Api* msg); static const ::google::protobuf::SourceContext& source_context(const Api* msg);
static void set_has_source_context(HasBits* has_bits) { static void set_has_source_context(HasBits* has_bits) {
(*has_bits)[0] |= 1u; (*has_bits)[0] |= 1u;
} }
}; };
const ::PROTOBUF_NAMESPACE_ID::SourceContext& const ::google::protobuf::SourceContext& Api::_Internal::source_context(const Api* msg) {
Api::_Internal::source_context(const Api* msg) {
return *msg->_impl_.source_context_; return *msg->_impl_.source_context_;
} }
void Api::clear_options() { void Api::clear_options() {
@ -256,13 +258,13 @@ void Api::clear_source_context() {
if (_impl_.source_context_ != nullptr) _impl_.source_context_->Clear(); if (_impl_.source_context_ != nullptr) _impl_.source_context_->Clear();
_impl_._has_bits_[0] &= ~0x00000001u; _impl_._has_bits_[0] &= ~0x00000001u;
} }
Api::Api(::PROTOBUF_NAMESPACE_ID::Arena* arena) Api::Api(::google::protobuf::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) { : ::google::protobuf::Message(arena) {
SharedCtor(arena); SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Api) // @@protoc_insertion_point(arena_constructor:google.protobuf.Api)
} }
Api::Api(const Api& from) Api::Api(const Api& from)
: ::PROTOBUF_NAMESPACE_ID::Message() { : ::google::protobuf::Message() {
Api* const _this = this; (void)_this; Api* const _this = this; (void)_this;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_._has_bits_){from._impl_._has_bits_} decltype(_impl_._has_bits_){from._impl_._has_bits_}
@ -278,7 +280,7 @@ Api::Api(const Api& from)
, decltype(_impl_.syntax_) {} , decltype(_impl_.syntax_) {}
}; };
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault(); _impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.name_.Set("", GetArenaForAllocation()); _impl_.name_.Set("", GetArenaForAllocation());
@ -294,7 +296,7 @@ Api::Api(const Api& from)
_this->_impl_.version_.Set(from._internal_version(), _this->GetArenaForAllocation()); _this->_impl_.version_.Set(from._internal_version(), _this->GetArenaForAllocation());
} }
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) { if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_impl_.source_context_ = new ::PROTOBUF_NAMESPACE_ID::SourceContext(*from._impl_.source_context_); _this->_impl_.source_context_ = new ::google::protobuf::SourceContext(*from._impl_.source_context_);
} }
_this->_impl_.syntax_ = from._impl_.syntax_; _this->_impl_.syntax_ = from._impl_.syntax_;
// @@protoc_insertion_point(copy_constructor:google.protobuf.Api) // @@protoc_insertion_point(copy_constructor:google.protobuf.Api)
@ -328,7 +330,7 @@ inline void Api::SharedCtor(::_pb::Arena* arena) {
Api::~Api() { Api::~Api() {
// @@protoc_insertion_point(destructor:google.protobuf.Api) // @@protoc_insertion_point(destructor:google.protobuf.Api)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
(void)arena; (void)arena;
return; return;
} }
@ -337,9 +339,9 @@ Api::~Api() {
inline void Api::SharedDtor() { inline void Api::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr); ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_internal_mutable_methods()->~RepeatedPtrField(); _impl_.methods_.~RepeatedPtrField();
_internal_mutable_options()->~RepeatedPtrField(); _impl_.options_.~RepeatedPtrField();
_internal_mutable_mixins()->~RepeatedPtrField(); _impl_.mixins_.~RepeatedPtrField();
_impl_.name_.Destroy(); _impl_.name_.Destroy();
_impl_.version_.Destroy(); _impl_.version_.Destroy();
if (this != internal_default_instance()) delete _impl_.source_context_; if (this != internal_default_instance()) delete _impl_.source_context_;
@ -349,7 +351,7 @@ void Api::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size); _impl_._cached_size_.Set(size);
} }
void Api::Clear() { PROTOBUF_NOINLINE void Api::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Api) // @@protoc_insertion_point(message_clear_start:google.protobuf.Api)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
@ -367,7 +369,7 @@ void Api::Clear() {
} }
_impl_.syntax_ = 0; _impl_.syntax_ = 0;
_impl_._has_bits_.Clear(); _impl_._has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
} }
const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
@ -394,10 +396,10 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
ptr -= 1; ptr -= 1;
do { do {
ptr += 1; ptr += 1;
ptr = ctx->ParseMessage(_internal_add_methods(), ptr); ptr = ctx->ParseMessage(_internal_mutable_methods()->Add(), ptr);
CHK_(ptr); CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr)); } while (::google::protobuf::internal::ExpectTag<18>(ptr));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -408,10 +410,10 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
ptr -= 1; ptr -= 1;
do { do {
ptr += 1; ptr += 1;
ptr = ctx->ParseMessage(_internal_add_options(), ptr); ptr = ctx->ParseMessage(_internal_mutable_options()->Add(), ptr);
CHK_(ptr); CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr)); } while (::google::protobuf::internal::ExpectTag<26>(ptr));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -442,10 +444,10 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
ptr -= 1; ptr -= 1;
do { do {
ptr += 1; ptr += 1;
ptr = ctx->ParseMessage(_internal_add_mixins(), ptr); ptr = ctx->ParseMessage(_internal_mutable_mixins()->Add(), ptr);
CHK_(ptr); CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } while (::google::protobuf::internal::ExpectTag<50>(ptr));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -453,9 +455,9 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
// .google.protobuf.Syntax syntax = 7; // .google.protobuf.Syntax syntax = 7;
case 7: case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) { if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
::int32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); ::int32_t val = ::google::protobuf::internal::ReadVarint32(&ptr);
CHK_(ptr); CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val)); _internal_set_syntax(static_cast<::google::protobuf::Syntax>(val));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -471,7 +473,7 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
} }
ptr = UnknownFieldParse( ptr = UnknownFieldParse(
tag, tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(),
ptr, ctx); ptr, ctx);
CHK_(ptr != nullptr); CHK_(ptr != nullptr);
} // while } // while
@ -485,7 +487,7 @@ failure:
} }
::uint8_t* Api::_InternalSerialize( ::uint8_t* Api::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
@ -493,39 +495,39 @@ failure:
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
const std::string& _s = this->_internal_name(); const std::string& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.name");
target = stream->WriteStringMaybeAliased(1, _s, target); target = stream->WriteStringMaybeAliased(1, _s, target);
} }
// repeated .google.protobuf.Method methods = 2; // repeated .google.protobuf.Method methods = 2;
for (unsigned i = 0, for (unsigned i = 0,
n = static_cast<unsigned>(this->_internal_methods_size()); i < n; i++) { n = static_cast<unsigned>(this->_internal_methods_size()); i < n; i++) {
const auto& repfield = this->_internal_methods(i); const auto& repfield = this->_internal_methods().Get(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream); InternalWriteMessage(2, repfield, repfield.GetCachedSize(), target, stream);
} }
// repeated .google.protobuf.Option options = 3; // repeated .google.protobuf.Option options = 3;
for (unsigned i = 0, for (unsigned i = 0,
n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
const auto& repfield = this->_internal_options(i); const auto& repfield = this->_internal_options().Get(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream); InternalWriteMessage(3, repfield, repfield.GetCachedSize(), target, stream);
} }
// string version = 4; // string version = 4;
if (!this->_internal_version().empty()) { if (!this->_internal_version().empty()) {
const std::string& _s = this->_internal_version(); const std::string& _s = this->_internal_version();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Api.version");
target = stream->WriteStringMaybeAliased(4, _s, target); target = stream->WriteStringMaybeAliased(4, _s, target);
} }
cached_has_bits = _impl_._has_bits_[0]; cached_has_bits = _impl_._has_bits_[0];
// .google.protobuf.SourceContext source_context = 5; // .google.protobuf.SourceContext source_context = 5;
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(5, _Internal::source_context(this), InternalWriteMessage(5, _Internal::source_context(this),
_Internal::source_context(this).GetCachedSize(), target, stream); _Internal::source_context(this).GetCachedSize(), target, stream);
} }
@ -533,8 +535,8 @@ failure:
// repeated .google.protobuf.Mixin mixins = 6; // repeated .google.protobuf.Mixin mixins = 6;
for (unsigned i = 0, for (unsigned i = 0,
n = static_cast<unsigned>(this->_internal_mixins_size()); i < n; i++) { n = static_cast<unsigned>(this->_internal_mixins_size()); i < n; i++) {
const auto& repfield = this->_internal_mixins(i); const auto& repfield = this->_internal_mixins().Get(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
} }
@ -547,7 +549,7 @@ failure:
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
} }
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api) // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api)
return target; return target;
@ -565,32 +567,32 @@ failure:
total_size += 1UL * this->_internal_methods_size(); total_size += 1UL * this->_internal_methods_size();
for (const auto& msg : this->_internal_methods()) { for (const auto& msg : this->_internal_methods()) {
total_size += total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); ::google::protobuf::internal::WireFormatLite::MessageSize(msg);
} }
// repeated .google.protobuf.Option options = 3; // repeated .google.protobuf.Option options = 3;
total_size += 1UL * this->_internal_options_size(); total_size += 1UL * this->_internal_options_size();
for (const auto& msg : this->_internal_options()) { for (const auto& msg : this->_internal_options()) {
total_size += total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); ::google::protobuf::internal::WireFormatLite::MessageSize(msg);
} }
// repeated .google.protobuf.Mixin mixins = 6; // repeated .google.protobuf.Mixin mixins = 6;
total_size += 1UL * this->_internal_mixins_size(); total_size += 1UL * this->_internal_mixins_size();
for (const auto& msg : this->_internal_mixins()) { for (const auto& msg : this->_internal_mixins()) {
total_size += total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); ::google::protobuf::internal::WireFormatLite::MessageSize(msg);
} }
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string version = 4; // string version = 4;
if (!this->_internal_version().empty()) { if (!this->_internal_version().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_version()); this->_internal_version());
} }
@ -598,7 +600,7 @@ failure:
cached_has_bits = _impl_._has_bits_[0]; cached_has_bits = _impl_._has_bits_[0];
if (cached_has_bits & 0x00000001u) { if (cached_has_bits & 0x00000001u) {
total_size += 1 + total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( ::google::protobuf::internal::WireFormatLite::MessageSize(
*_impl_.source_context_); *_impl_.source_context_);
} }
@ -611,14 +613,14 @@ failure:
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
} }
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Api::_class_data_ = { const ::google::protobuf::Message::ClassData Api::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ::google::protobuf::Message::CopyWithSourceCheck,
Api::MergeImpl Api::MergeImpl
}; };
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Api::GetClassData() const { return &_class_data_; } const ::google::protobuf::Message::ClassData*Api::GetClassData() const { return &_class_data_; }
void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { void Api::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) {
auto* const _this = static_cast<Api*>(&to_msg); auto* const _this = static_cast<Api*>(&to_msg);
auto& from = static_cast<const Api&>(from_msg); auto& from = static_cast<const Api&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api) // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api)
@ -636,13 +638,13 @@ void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
_this->_internal_set_version(from._internal_version()); _this->_internal_set_version(from._internal_version());
} }
if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) { if ((from._impl_._has_bits_[0] & 0x00000001u) != 0) {
_this->_internal_mutable_source_context()->::PROTOBUF_NAMESPACE_ID::SourceContext::MergeFrom( _this->_internal_mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(
from._internal_source_context()); from._internal_source_context());
} }
if (from._internal_syntax() != 0) { if (from._internal_syntax() != 0) {
_this->_internal_set_syntax(from._internal_syntax()); _this->_internal_set_syntax(from._internal_syntax());
} }
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
} }
void Api::CopyFrom(const Api& from) { void Api::CopyFrom(const Api& from) {
@ -652,7 +654,7 @@ void Api::CopyFrom(const Api& from) {
MergeFrom(from); MergeFrom(from);
} }
bool Api::IsInitialized() const { PROTOBUF_NOINLINE bool Api::IsInitialized() const {
return true; return true;
} }
@ -669,7 +671,7 @@ void Api::InternalSwap(Api* other) {
&other->_impl_.name_, rhs_arena); &other->_impl_.name_, rhs_arena);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.version_, lhs_arena, ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.version_, lhs_arena,
&other->_impl_.version_, rhs_arena); &other->_impl_.version_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap< ::google::protobuf::internal::memswap<
PROTOBUF_FIELD_OFFSET(Api, _impl_.syntax_) PROTOBUF_FIELD_OFFSET(Api, _impl_.syntax_)
+ sizeof(Api::_impl_.syntax_) + sizeof(Api::_impl_.syntax_)
- PROTOBUF_FIELD_OFFSET(Api, _impl_.source_context_)>( - PROTOBUF_FIELD_OFFSET(Api, _impl_.source_context_)>(
@ -677,7 +679,7 @@ void Api::InternalSwap(Api* other) {
reinterpret_cast<char*>(&other->_impl_.source_context_)); reinterpret_cast<char*>(&other->_impl_.source_context_));
} }
::PROTOBUF_NAMESPACE_ID::Metadata Api::GetMetadata() const { ::google::protobuf::Metadata Api::GetMetadata() const {
return ::_pbi::AssignDescriptors( return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]); file_level_metadata_google_2fprotobuf_2fapi_2eproto[0]);
@ -691,13 +693,13 @@ class Method::_Internal {
void Method::clear_options() { void Method::clear_options() {
_internal_mutable_options()->Clear(); _internal_mutable_options()->Clear();
} }
Method::Method(::PROTOBUF_NAMESPACE_ID::Arena* arena) Method::Method(::google::protobuf::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) { : ::google::protobuf::Message(arena) {
SharedCtor(arena); SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Method) // @@protoc_insertion_point(arena_constructor:google.protobuf.Method)
} }
Method::Method(const Method& from) Method::Method(const Method& from)
: ::PROTOBUF_NAMESPACE_ID::Message() { : ::google::protobuf::Message() {
Method* const _this = this; (void)_this; Method* const _this = this; (void)_this;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_.options_){from._impl_.options_} decltype(_impl_.options_){from._impl_.options_}
@ -715,7 +717,7 @@ Method::Method(const Method& from)
, /*decltype(_impl_._cached_size_)*/{}}; , /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault(); _impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.name_.Set("", GetArenaForAllocation()); _impl_.name_.Set("", GetArenaForAllocation());
@ -777,7 +779,7 @@ inline void Method::SharedCtor(::_pb::Arena* arena) {
Method::~Method() { Method::~Method() {
// @@protoc_insertion_point(destructor:google.protobuf.Method) // @@protoc_insertion_point(destructor:google.protobuf.Method)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
(void)arena; (void)arena;
return; return;
} }
@ -786,7 +788,7 @@ Method::~Method() {
inline void Method::SharedDtor() { inline void Method::SharedDtor() {
ABSL_DCHECK(GetArenaForAllocation() == nullptr); ABSL_DCHECK(GetArenaForAllocation() == nullptr);
_internal_mutable_options()->~RepeatedPtrField(); _impl_.options_.~RepeatedPtrField();
_impl_.name_.Destroy(); _impl_.name_.Destroy();
_impl_.request_type_url_.Destroy(); _impl_.request_type_url_.Destroy();
_impl_.response_type_url_.Destroy(); _impl_.response_type_url_.Destroy();
@ -796,7 +798,7 @@ void Method::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size); _impl_._cached_size_.Set(size);
} }
void Method::Clear() { PROTOBUF_NOINLINE void Method::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Method) // @@protoc_insertion_point(message_clear_start:google.protobuf.Method)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
@ -809,7 +811,7 @@ void Method::Clear() {
::memset(&_impl_.request_streaming_, 0, static_cast<::size_t>( ::memset(&_impl_.request_streaming_, 0, static_cast<::size_t>(
reinterpret_cast<char*>(&_impl_.syntax_) - reinterpret_cast<char*>(&_impl_.syntax_) -
reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_)); reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
} }
const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
@ -843,7 +845,7 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
// bool request_streaming = 3; // bool request_streaming = 3;
case 3: case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) { if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 24)) {
_impl_.request_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); _impl_.request_streaming_ = ::google::protobuf::internal::ReadVarint64(&ptr);
CHK_(ptr); CHK_(ptr);
} else { } else {
goto handle_unusual; goto handle_unusual;
@ -863,7 +865,7 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
// bool response_streaming = 5; // bool response_streaming = 5;
case 5: case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) { if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 40)) {
_impl_.response_streaming_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); _impl_.response_streaming_ = ::google::protobuf::internal::ReadVarint64(&ptr);
CHK_(ptr); CHK_(ptr);
} else { } else {
goto handle_unusual; goto handle_unusual;
@ -875,10 +877,10 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
ptr -= 1; ptr -= 1;
do { do {
ptr += 1; ptr += 1;
ptr = ctx->ParseMessage(_internal_add_options(), ptr); ptr = ctx->ParseMessage(_internal_mutable_options()->Add(), ptr);
CHK_(ptr); CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break; if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr)); } while (::google::protobuf::internal::ExpectTag<50>(ptr));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -886,9 +888,9 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
// .google.protobuf.Syntax syntax = 7; // .google.protobuf.Syntax syntax = 7;
case 7: case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) { if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
::int32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); ::int32_t val = ::google::protobuf::internal::ReadVarint32(&ptr);
CHK_(ptr); CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val)); _internal_set_syntax(static_cast<::google::protobuf::Syntax>(val));
} else { } else {
goto handle_unusual; goto handle_unusual;
} }
@ -904,7 +906,7 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
} }
ptr = UnknownFieldParse( ptr = UnknownFieldParse(
tag, tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(),
ptr, ctx); ptr, ctx);
CHK_(ptr != nullptr); CHK_(ptr != nullptr);
} // while } // while
@ -917,7 +919,7 @@ failure:
} }
::uint8_t* Method::_InternalSerialize( ::uint8_t* Method::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
@ -925,16 +927,16 @@ failure:
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
const std::string& _s = this->_internal_name(); const std::string& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.name");
target = stream->WriteStringMaybeAliased(1, _s, target); target = stream->WriteStringMaybeAliased(1, _s, target);
} }
// string request_type_url = 2; // string request_type_url = 2;
if (!this->_internal_request_type_url().empty()) { if (!this->_internal_request_type_url().empty()) {
const std::string& _s = this->_internal_request_type_url(); const std::string& _s = this->_internal_request_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.request_type_url");
target = stream->WriteStringMaybeAliased(2, _s, target); target = stream->WriteStringMaybeAliased(2, _s, target);
} }
@ -948,8 +950,8 @@ failure:
// string response_type_url = 4; // string response_type_url = 4;
if (!this->_internal_response_type_url().empty()) { if (!this->_internal_response_type_url().empty()) {
const std::string& _s = this->_internal_response_type_url(); const std::string& _s = this->_internal_response_type_url();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Method.response_type_url");
target = stream->WriteStringMaybeAliased(4, _s, target); target = stream->WriteStringMaybeAliased(4, _s, target);
} }
@ -963,8 +965,8 @@ failure:
// repeated .google.protobuf.Option options = 6; // repeated .google.protobuf.Option options = 6;
for (unsigned i = 0, for (unsigned i = 0,
n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) { n = static_cast<unsigned>(this->_internal_options_size()); i < n; i++) {
const auto& repfield = this->_internal_options(i); const auto& repfield = this->_internal_options().Get(i);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream); InternalWriteMessage(6, repfield, repfield.GetCachedSize(), target, stream);
} }
@ -977,7 +979,7 @@ failure:
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
} }
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method) // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method)
return target; return target;
@ -995,24 +997,24 @@ failure:
total_size += 1UL * this->_internal_options_size(); total_size += 1UL * this->_internal_options_size();
for (const auto& msg : this->_internal_options()) { for (const auto& msg : this->_internal_options()) {
total_size += total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); ::google::protobuf::internal::WireFormatLite::MessageSize(msg);
} }
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string request_type_url = 2; // string request_type_url = 2;
if (!this->_internal_request_type_url().empty()) { if (!this->_internal_request_type_url().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_request_type_url()); this->_internal_request_type_url());
} }
// string response_type_url = 4; // string response_type_url = 4;
if (!this->_internal_response_type_url().empty()) { if (!this->_internal_response_type_url().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_response_type_url()); this->_internal_response_type_url());
} }
@ -1035,14 +1037,14 @@ failure:
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
} }
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Method::_class_data_ = { const ::google::protobuf::Message::ClassData Method::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ::google::protobuf::Message::CopyWithSourceCheck,
Method::MergeImpl Method::MergeImpl
}; };
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Method::GetClassData() const { return &_class_data_; } const ::google::protobuf::Message::ClassData*Method::GetClassData() const { return &_class_data_; }
void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { void Method::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) {
auto* const _this = static_cast<Method*>(&to_msg); auto* const _this = static_cast<Method*>(&to_msg);
auto& from = static_cast<const Method&>(from_msg); auto& from = static_cast<const Method&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method) // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method)
@ -1069,7 +1071,7 @@ void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
if (from._internal_syntax() != 0) { if (from._internal_syntax() != 0) {
_this->_internal_set_syntax(from._internal_syntax()); _this->_internal_set_syntax(from._internal_syntax());
} }
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
} }
void Method::CopyFrom(const Method& from) { void Method::CopyFrom(const Method& from) {
@ -1079,7 +1081,7 @@ void Method::CopyFrom(const Method& from) {
MergeFrom(from); MergeFrom(from);
} }
bool Method::IsInitialized() const { PROTOBUF_NOINLINE bool Method::IsInitialized() const {
return true; return true;
} }
@ -1095,7 +1097,7 @@ void Method::InternalSwap(Method* other) {
&other->_impl_.request_type_url_, rhs_arena); &other->_impl_.request_type_url_, rhs_arena);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.response_type_url_, lhs_arena, ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.response_type_url_, lhs_arena,
&other->_impl_.response_type_url_, rhs_arena); &other->_impl_.response_type_url_, rhs_arena);
::PROTOBUF_NAMESPACE_ID::internal::memswap< ::google::protobuf::internal::memswap<
PROTOBUF_FIELD_OFFSET(Method, _impl_.syntax_) PROTOBUF_FIELD_OFFSET(Method, _impl_.syntax_)
+ sizeof(Method::_impl_.syntax_) + sizeof(Method::_impl_.syntax_)
- PROTOBUF_FIELD_OFFSET(Method, _impl_.request_streaming_)>( - PROTOBUF_FIELD_OFFSET(Method, _impl_.request_streaming_)>(
@ -1103,7 +1105,7 @@ void Method::InternalSwap(Method* other) {
reinterpret_cast<char*>(&other->_impl_.request_streaming_)); reinterpret_cast<char*>(&other->_impl_.request_streaming_));
} }
::PROTOBUF_NAMESPACE_ID::Metadata Method::GetMetadata() const { ::google::protobuf::Metadata Method::GetMetadata() const {
return ::_pbi::AssignDescriptors( return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]); file_level_metadata_google_2fprotobuf_2fapi_2eproto[1]);
@ -1114,13 +1116,13 @@ class Mixin::_Internal {
public: public:
}; };
Mixin::Mixin(::PROTOBUF_NAMESPACE_ID::Arena* arena) Mixin::Mixin(::google::protobuf::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena) { : ::google::protobuf::Message(arena) {
SharedCtor(arena); SharedCtor(arena);
// @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin) // @@protoc_insertion_point(arena_constructor:google.protobuf.Mixin)
} }
Mixin::Mixin(const Mixin& from) Mixin::Mixin(const Mixin& from)
: ::PROTOBUF_NAMESPACE_ID::Message() { : ::google::protobuf::Message() {
Mixin* const _this = this; (void)_this; Mixin* const _this = this; (void)_this;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_.name_) {} decltype(_impl_.name_) {}
@ -1129,7 +1131,7 @@ Mixin::Mixin(const Mixin& from)
, /*decltype(_impl_._cached_size_)*/{}}; , /*decltype(_impl_._cached_size_)*/{}};
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
_impl_.name_.InitDefault(); _impl_.name_.InitDefault();
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
_impl_.name_.Set("", GetArenaForAllocation()); _impl_.name_.Set("", GetArenaForAllocation());
@ -1168,7 +1170,7 @@ inline void Mixin::SharedCtor(::_pb::Arena* arena) {
Mixin::~Mixin() { Mixin::~Mixin() {
// @@protoc_insertion_point(destructor:google.protobuf.Mixin) // @@protoc_insertion_point(destructor:google.protobuf.Mixin)
if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { if (auto *arena = _internal_metadata_.DeleteReturnArena<::google::protobuf::UnknownFieldSet>()) {
(void)arena; (void)arena;
return; return;
} }
@ -1185,7 +1187,7 @@ void Mixin::SetCachedSize(int size) const {
_impl_._cached_size_.Set(size); _impl_._cached_size_.Set(size);
} }
void Mixin::Clear() { PROTOBUF_NOINLINE void Mixin::Clear() {
// @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin) // @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused // Prevent compiler warnings about cached_has_bits being unused
@ -1193,7 +1195,7 @@ void Mixin::Clear() {
_impl_.name_.ClearToEmpty(); _impl_.name_.ClearToEmpty();
_impl_.root_.ClearToEmpty(); _impl_.root_.ClearToEmpty();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
} }
const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
@ -1235,7 +1237,7 @@ const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
} }
ptr = UnknownFieldParse( ptr = UnknownFieldParse(
tag, tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>(),
ptr, ctx); ptr, ctx);
CHK_(ptr != nullptr); CHK_(ptr != nullptr);
} // while } // while
@ -1248,7 +1250,7 @@ failure:
} }
::uint8_t* Mixin::_InternalSerialize( ::uint8_t* Mixin::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { ::uint8_t* target, ::google::protobuf::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)
::uint32_t cached_has_bits = 0; ::uint32_t cached_has_bits = 0;
(void) cached_has_bits; (void) cached_has_bits;
@ -1256,22 +1258,22 @@ failure:
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
const std::string& _s = this->_internal_name(); const std::string& _s = this->_internal_name();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.name");
target = stream->WriteStringMaybeAliased(1, _s, target); target = stream->WriteStringMaybeAliased(1, _s, target);
} }
// string root = 2; // string root = 2;
if (!this->_internal_root().empty()) { if (!this->_internal_root().empty()) {
const std::string& _s = this->_internal_root(); const std::string& _s = this->_internal_root();
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
_s.data(), static_cast<int>(_s.length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root"); _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "google.protobuf.Mixin.root");
target = stream->WriteStringMaybeAliased(2, _s, target); target = stream->WriteStringMaybeAliased(2, _s, target);
} }
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
} }
// @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin) // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin)
return target; return target;
@ -1287,27 +1289,27 @@ failure:
// string name = 1; // string name = 1;
if (!this->_internal_name().empty()) { if (!this->_internal_name().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_name()); this->_internal_name());
} }
// string root = 2; // string root = 2;
if (!this->_internal_root().empty()) { if (!this->_internal_root().empty()) {
total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this->_internal_root()); this->_internal_root());
} }
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
} }
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Mixin::_class_data_ = { const ::google::protobuf::Message::ClassData Mixin::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, ::google::protobuf::Message::CopyWithSourceCheck,
Mixin::MergeImpl Mixin::MergeImpl
}; };
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Mixin::GetClassData() const { return &_class_data_; } const ::google::protobuf::Message::ClassData*Mixin::GetClassData() const { return &_class_data_; }
void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { void Mixin::MergeImpl(::google::protobuf::Message& to_msg, const ::google::protobuf::Message& from_msg) {
auto* const _this = static_cast<Mixin*>(&to_msg); auto* const _this = static_cast<Mixin*>(&to_msg);
auto& from = static_cast<const Mixin&>(from_msg); auto& from = static_cast<const Mixin&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin) // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin)
@ -1321,7 +1323,7 @@ void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF
if (!from._internal_root().empty()) { if (!from._internal_root().empty()) {
_this->_internal_set_root(from._internal_root()); _this->_internal_set_root(from._internal_root());
} }
_this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(from._internal_metadata_);
} }
void Mixin::CopyFrom(const Mixin& from) { void Mixin::CopyFrom(const Mixin& from) {
@ -1331,7 +1333,7 @@ void Mixin::CopyFrom(const Mixin& from) {
MergeFrom(from); MergeFrom(from);
} }
bool Mixin::IsInitialized() const { PROTOBUF_NOINLINE bool Mixin::IsInitialized() const {
return true; return true;
} }
@ -1346,26 +1348,29 @@ void Mixin::InternalSwap(Mixin* other) {
&other->_impl_.root_, rhs_arena); &other->_impl_.root_, rhs_arena);
} }
::PROTOBUF_NAMESPACE_ID::Metadata Mixin::GetMetadata() const { ::google::protobuf::Metadata Mixin::GetMetadata() const {
return ::_pbi::AssignDescriptors( return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once, &descriptor_table_google_2fprotobuf_2fapi_2eproto_getter, &descriptor_table_google_2fprotobuf_2fapi_2eproto_once,
file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]); file_level_metadata_google_2fprotobuf_2fapi_2eproto[2]);
} }
// @@protoc_insertion_point(namespace_scope) // @@protoc_insertion_point(namespace_scope)
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
PROTOBUF_NAMESPACE_OPEN } // namespace google
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Api* namespace google {
Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Api >(Arena* arena) { namespace protobuf {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Api >(arena); template<> PROTOBUF_NOINLINE ::google::protobuf::Api*
Arena::CreateMaybeMessage< ::google::protobuf::Api >(Arena* arena) {
return Arena::CreateMessageInternal< ::google::protobuf::Api >(arena);
} }
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Method* template<> PROTOBUF_NOINLINE ::google::protobuf::Method*
Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Method >(Arena* arena) { Arena::CreateMaybeMessage< ::google::protobuf::Method >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Method >(arena); return Arena::CreateMessageInternal< ::google::protobuf::Method >(arena);
} }
template<> PROTOBUF_NOINLINE ::PROTOBUF_NAMESPACE_ID::Mixin* template<> PROTOBUF_NOINLINE ::google::protobuf::Mixin*
Arena::CreateMaybeMessage< ::PROTOBUF_NAMESPACE_ID::Mixin >(Arena* arena) { Arena::CreateMaybeMessage< ::google::protobuf::Mixin >(Arena* arena) {
return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::Mixin >(arena); return Arena::CreateMessageInternal< ::google::protobuf::Mixin >(arena);
} }
PROTOBUF_NAMESPACE_CLOSE } // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope) // @@protoc_insertion_point(global_scope)
#include "google/protobuf/port_undef.inc" #include "google/protobuf/port_undef.inc"

File diff suppressed because it is too large Load Diff

@ -99,7 +99,7 @@ struct ArenaAlignDefault {
} }
static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Ceil(size_t n) { static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Ceil(size_t n) {
return (n + align - 1) & -align; return (n + align - 1) & ~(align - 1);
} }
static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Floor(size_t n) { static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Floor(size_t n) {
return (n & ~(align - 1)); return (n & ~(align - 1));
@ -113,7 +113,7 @@ struct ArenaAlignDefault {
template <typename T> template <typename T>
static inline PROTOBUF_ALWAYS_INLINE T* Ceil(T* ptr) { static inline PROTOBUF_ALWAYS_INLINE T* Ceil(T* ptr) {
uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr); uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr);
return reinterpret_cast<T*>((intptr + align - 1) & -align); return reinterpret_cast<T*>((intptr + align - 1) & ~(align - 1));
} }
template <typename T> template <typename T>
@ -142,7 +142,9 @@ struct ArenaAlign {
return (reinterpret_cast<uintptr_t>(ptr) & (align - 1)) == 0U; return (reinterpret_cast<uintptr_t>(ptr) & (align - 1)) == 0U;
} }
constexpr size_t Ceil(size_t n) const { return (n + align - 1) & -align; } constexpr size_t Ceil(size_t n) const {
return (n + align - 1) & ~(align - 1);
}
constexpr size_t Floor(size_t n) const { return (n & ~(align - 1)); } constexpr size_t Floor(size_t n) const { return (n & ~(align - 1)); }
constexpr size_t Padded(size_t n) const { constexpr size_t Padded(size_t n) const {
@ -156,7 +158,7 @@ struct ArenaAlign {
template <typename T> template <typename T>
T* Ceil(T* ptr) const { T* Ceil(T* ptr) const {
uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr); uintptr_t intptr = reinterpret_cast<uintptr_t>(ptr);
return reinterpret_cast<T*>((intptr + align - 1) & -align); return reinterpret_cast<T*>((intptr + align - 1) & ~(align - 1));
} }
template <typename T> template <typename T>

@ -31,6 +31,9 @@
#ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ #ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__
#define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__ #define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__
#include <cstddef>
#include "absl/container/flat_hash_set.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "google/protobuf/arena.h" #include "google/protobuf/arena.h"
#include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/coded_stream.h"
@ -84,6 +87,25 @@ struct ArenaTestPeer {
} }
}; };
struct CleanupGrowthInfo {
size_t space_used;
absl::flat_hash_set<void*> cleanups;
};
template <typename Func>
CleanupGrowthInfo CleanupGrowth(Arena& arena, Func f) {
auto old_space_used = arena.SpaceUsed();
auto old_cleanups = ArenaTestPeer::PeekCleanupListForTesting(&arena);
f();
auto new_space_used = arena.SpaceUsed();
auto new_cleanups = ArenaTestPeer::PeekCleanupListForTesting(&arena);
CleanupGrowthInfo res;
res.space_used = new_space_used - old_space_used;
res.cleanups.insert(new_cleanups.begin(), new_cleanups.end());
for (auto p : old_cleanups) res.cleanups.erase(p);
return res;
}
class NoHeapChecker { class NoHeapChecker {
public: public:
NoHeapChecker() { capture_alloc.Hook(); } NoHeapChecker() { capture_alloc.Hook(); }

@ -11,16 +11,16 @@ load(
) )
load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_proto//proto:defs.bzl", "proto_library")
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test") load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") load("//build_defs:cpp_opts.bzl", "COPTS")
proto_library( proto_library(
name = "plugin_proto", name = "plugin_proto",
srcs = ["plugin.proto"], srcs = ["plugin.proto"],
strip_import_prefix = "/src",
visibility = [ visibility = [
"//:__pkg__", "//:__pkg__",
"//pkg:__pkg__", "//pkg:__pkg__",
], ],
strip_import_prefix = "/src",
deps = ["//:descriptor_proto"], deps = ["//:descriptor_proto"],
) )
@ -93,11 +93,14 @@ cc_library(
"//src/google/protobuf:descriptor_legacy", "//src/google/protobuf:descriptor_legacy",
"//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler/allowlists", "//src/google/protobuf/compiler/allowlists",
"@com_google_absl//absl/algorithm",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:btree",
"@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/types:span",
], ],
) )
@ -309,12 +312,11 @@ cc_library(
visibility = ["//src/google/protobuf:__subpackages__"], visibility = ["//src/google/protobuf:__subpackages__"],
deps = [ deps = [
"//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/types:span",
"@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/types:span",
], ],
) )
cc_test( cc_test(
name = "retention_unittest", name = "retention_unittest",
srcs = ["retention_unittest.cc"], srcs = ["retention_unittest.cc"],
@ -322,9 +324,9 @@ cc_test(
":importer", ":importer",
":retention", ":retention",
"//src/google/protobuf/io", "//src/google/protobuf/io",
"@com_google_absl//absl/log:die_if_null",
"@com_google_googletest//:gtest", "@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
"@com_google_absl//absl/log:die_if_null",
], ],
) )

@ -21,6 +21,8 @@ cc_library(
name = "allowlists", name = "allowlists",
srcs = [ srcs = [
"empty_package.cc", "empty_package.cc",
"open_enum.cc",
"unused_imports.cc",
"weak_imports.cc", "weak_imports.cc",
], ],
hdrs = ["allowlists.h"], hdrs = ["allowlists.h"],

@ -43,6 +43,15 @@ bool IsWeakImportFile(absl::string_view file);
// Returns whether a file can have an empty package. // Returns whether a file can have an empty package.
bool IsEmptyPackageFile(absl::string_view file); bool IsEmptyPackageFile(absl::string_view file);
// Returns whether a file can contain a cc_open_enum.
bool IsOpenEnumFile(absl::string_view file);
// Returns whether a message can contain a cc_open_enum.
bool IsOpenEnumMessage(absl::string_view msg);
// Returns whether a file can contain an unused import.
bool IsUnusedImportFile(absl::string_view file);
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google

@ -0,0 +1,59 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/allowlists/allowlist.h"
#include "google/protobuf/compiler/allowlists/allowlists.h"
namespace google {
namespace protobuf {
namespace compiler {
// NOTE: Allowlists in this file are not accepting new entries unless otherwise
// specified.
static constexpr auto kOpenEnumFiles = internal::MakeAllowlist({
// Intentionally left blank.
});
static constexpr auto kOpenEnumMessages = internal::MakeAllowlist({
// Intentionally left blank.
});
bool IsOpenEnumFile(absl::string_view file) {
return kOpenEnumFiles.Allows(file);
}
bool IsOpenEnumMessage(absl::string_view msg) {
return kOpenEnumMessages.Allows(msg);
}
} // namespace compiler
} // namespace protobuf
} // namespace google

@ -0,0 +1,51 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/allowlists/allowlist.h"
#include "google/protobuf/compiler/allowlists/allowlists.h"
namespace google {
namespace protobuf {
namespace compiler {
// NOTE: Allowlists in this file are not accepting new entries unless otherwise
// specified.
// TODO(b/136084631): Remove when empty.
static constexpr auto kUnusedImports = internal::MakeAllowlist({
// Intentionally left blank.
});
bool IsUnusedImportFile(absl::string_view file) {
return kUnusedImports.Allows(file);
}
} // namespace compiler
} // namespace protobuf
} // namespace google

@ -137,7 +137,8 @@ const GeneratedCodeInfo::Annotation* FindAnnotationOnPath(
bool AtLeastOneAnnotationMatchesSubstring( bool AtLeastOneAnnotationMatchesSubstring(
const std::string& file_content, const std::string& file_content,
const std::vector<const GeneratedCodeInfo::Annotation*>& annotations, const std::vector<const GeneratedCodeInfo::Annotation*>& annotations,
const std::string& expected_text) { const std::string& expected_text,
absl::optional<GeneratedCodeInfo::Annotation::Semantic> semantic) {
for (std::vector<const GeneratedCodeInfo::Annotation*>::const_iterator for (std::vector<const GeneratedCodeInfo::Annotation*>::const_iterator
i = annotations.begin(), i = annotations.begin(),
e = annotations.end(); e = annotations.end();
@ -149,7 +150,7 @@ bool AtLeastOneAnnotationMatchesSubstring(
return false; return false;
} }
if (file_content.substr(begin, end - begin) == expected_text) { if (file_content.substr(begin, end - begin) == expected_text) {
return true; return !semantic || annotation->semantic() == *semantic;
} }
} }
return false; return false;

@ -97,11 +97,13 @@ const GeneratedCodeInfo::Annotation* FindAnnotationOnPath(
const std::vector<int>& path); const std::vector<int>& path);
// Returns true if at least one of the provided annotations covers a given // Returns true if at least one of the provided annotations covers a given
// substring in file_content. // substring with the given semantic in file_content.
bool AtLeastOneAnnotationMatchesSubstring( bool AtLeastOneAnnotationMatchesSubstring(
const std::string& file_content, const std::string& file_content,
const std::vector<const GeneratedCodeInfo::Annotation*>& annotations, const std::vector<const GeneratedCodeInfo::Annotation*>& annotations,
const std::string& expected_text); const std::string& expected_text,
absl::optional<GeneratedCodeInfo::Annotation::Semantic> expected_semantic =
absl::nullopt);
// Returns true if the provided annotation covers a given substring in // Returns true if the provided annotation covers a given substring in
// file_content. // file_content.

@ -36,13 +36,13 @@
#include <utility> #include <utility>
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "absl/log/absl_log.h" #include "absl/log/absl_log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/strings/strip.h" #include "absl/strings/strip.h"
#include "google/protobuf/compiler/plugin.pb.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {

@ -34,8 +34,10 @@
#include "google/protobuf/compiler/command_line_interface.h" #include "google/protobuf/compiler/command_line_interface.h"
#include "absl/algorithm/container.h"
#include "absl/container/btree_set.h" #include "absl/container/btree_set.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/types/span.h"
#include "google/protobuf/compiler/allowlists/allowlists.h" #include "google/protobuf/compiler/allowlists/allowlists.h"
#include "google/protobuf/descriptor_legacy.h" #include "google/protobuf/descriptor_legacy.h"
@ -77,8 +79,6 @@
#include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/common.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/log/absl_log.h" #include "absl/log/absl_log.h"
#include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -88,7 +88,9 @@
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/importer.h" #include "google/protobuf/compiler/importer.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/compiler/retention.h" #include "google/protobuf/compiler/retention.h"
#include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/zip_writer.h" #include "google/protobuf/compiler/zip_writer.h"
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/dynamic_message.h" #include "google/protobuf/dynamic_message.h"
@ -1028,7 +1030,20 @@ struct VisitImpl {
Visitor visitor; Visitor visitor;
void Visit(const FieldDescriptor* descriptor) { visitor(descriptor); } void Visit(const FieldDescriptor* descriptor) { visitor(descriptor); }
void Visit(const EnumDescriptor* descriptor) { visitor(descriptor); } void Visit(const EnumValueDescriptor* descriptor) { visitor(descriptor); }
void Visit(const EnumDescriptor* descriptor) {
visitor(descriptor);
for (int i = 0; i < descriptor->value_count(); i++) {
Visit(descriptor->value(i));
}
}
void Visit(const Descriptor::ExtensionRange* descriptor) {
visitor(descriptor);
}
void Visit(const OneofDescriptor* descriptor) { visitor(descriptor); }
void Visit(const Descriptor* descriptor) { void Visit(const Descriptor* descriptor) {
visitor(descriptor); visitor(descriptor);
@ -1048,10 +1063,27 @@ struct VisitImpl {
for (int i = 0; i < descriptor->extension_count(); i++) { for (int i = 0; i < descriptor->extension_count(); i++) {
Visit(descriptor->extension(i)); Visit(descriptor->extension(i));
} }
for (int i = 0; i < descriptor->extension_range_count(); i++) {
Visit(descriptor->extension_range(i));
}
for (int i = 0; i < descriptor->oneof_decl_count(); i++) {
Visit(descriptor->oneof_decl(i));
}
} }
void Visit(const std::vector<const FileDescriptor*>& descriptors) { void Visit(const MethodDescriptor* method) { visitor(method); }
for (auto* descriptor : descriptors) {
void Visit(const ServiceDescriptor* descriptor) {
visitor(descriptor);
for (int i = 0; i < descriptor->method_count(); i++) {
Visit(descriptor->method(i));
}
}
void Visit(absl::Span<const FileDescriptor*> descriptors) {
for (const FileDescriptor* descriptor : descriptors) {
visitor(descriptor); visitor(descriptor);
for (int i = 0; i < descriptor->message_type_count(); i++) { for (int i = 0; i < descriptor->message_type_count(); i++) {
Visit(descriptor->message_type(i)); Visit(descriptor->message_type(i));
@ -1062,6 +1094,9 @@ struct VisitImpl {
for (int i = 0; i < descriptor->extension_count(); i++) { for (int i = 0; i < descriptor->extension_count(); i++) {
Visit(descriptor->extension(i)); Visit(descriptor->extension(i));
} }
for (int i = 0; i < descriptor->service_count(); i++) {
Visit(descriptor->service(i));
}
} }
} }
}; };
@ -1069,10 +1104,8 @@ struct VisitImpl {
// Visit every node in the descriptors calling `visitor(node)`. // Visit every node in the descriptors calling `visitor(node)`.
// The visitor does not need to handle all possible node types. Types that are // The visitor does not need to handle all possible node types. Types that are
// not visitable via `visitor` will be ignored. // not visitable via `visitor` will be ignored.
// Disclaimer: this is not fully implemented yet to visit _every_ node.
// VisitImpl might need to be updated where needs arise.
template <typename Visitor> template <typename Visitor>
void VisitDescriptors(const std::vector<const FileDescriptor*>& descriptors, void VisitDescriptors(absl::Span<const FileDescriptor*> descriptors,
Visitor visitor) { Visitor visitor) {
// Provide a fallback to ignore all the nodes that are not interesting to the // Provide a fallback to ignore all the nodes that are not interesting to the
// input visitor. // input visitor.
@ -1099,8 +1132,151 @@ bool HasReservedFieldNumber(const FieldDescriptor* field) {
namespace { namespace {
std::unique_ptr<SimpleDescriptorDatabase> std::unique_ptr<SimpleDescriptorDatabase>
PopulateSingleSimpleDescriptorDatabase(const std::string& descriptor_set_name); PopulateSingleSimpleDescriptorDatabase(const std::string& descriptor_set_name);
// Indicates whether the field is compatible with the given target type.
bool IsFieldCompatible(const FieldDescriptor& field,
FieldOptions::OptionTargetType target_type) {
const RepeatedField<int>& allowed_targets = field.options().targets();
return allowed_targets.empty() ||
absl::c_linear_search(allowed_targets, target_type);
}
// Converts the OptionTargetType enum to a string suitable for use in error
// messages.
absl::string_view TargetTypeString(FieldOptions::OptionTargetType target_type) {
switch (target_type) {
case FieldOptions::TARGET_TYPE_FILE:
return "file";
case FieldOptions::TARGET_TYPE_EXTENSION_RANGE:
return "extension range";
case FieldOptions::TARGET_TYPE_MESSAGE:
return "message";
case FieldOptions::TARGET_TYPE_FIELD:
return "field";
case FieldOptions::TARGET_TYPE_ONEOF:
return "oneof";
case FieldOptions::TARGET_TYPE_ENUM:
return "enum";
case FieldOptions::TARGET_TYPE_ENUM_ENTRY:
return "enum entry";
case FieldOptions::TARGET_TYPE_SERVICE:
return "service";
case FieldOptions::TARGET_TYPE_METHOD:
return "method";
default:
return "unknown";
}
}
// Recursively validates that the options message (or subpiece of an options
// message) is compatible with the given target type.
bool ValidateTargetConstraintsRecursive(
const Message& m, DescriptorPool::ErrorCollector& error_collector,
absl::string_view file_name, FieldOptions::OptionTargetType target_type) {
std::vector<const FieldDescriptor*> fields;
const Reflection* reflection = m.GetReflection();
reflection->ListFields(m, &fields);
bool success = true;
for (const auto* field : fields) {
if (!IsFieldCompatible(*field, target_type)) {
success = false;
error_collector.RecordError(
file_name, "", nullptr, DescriptorPool::ErrorCollector::OPTION_NAME,
absl::StrCat("Option ", field->full_name(),
" cannot be set on an entity of type `",
TargetTypeString(target_type), "`."));
}
if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
if (field->is_repeated()) {
int field_size = reflection->FieldSize(m, field);
for (int i = 0; i < field_size; ++i) {
if (!ValidateTargetConstraintsRecursive(
reflection->GetRepeatedMessage(m, field, i), error_collector,
file_name, target_type)) {
success = false;
}
}
} else if (!ValidateTargetConstraintsRecursive(
reflection->GetMessage(m, field), error_collector,
file_name, target_type)) {
success = false;
}
}
}
return success;
}
// Validates that the options message is correct with respect to target
// constraints, returning true if successful. This function converts the
// options message to a DynamicMessage so that we have visibility into custom
// options. We take the element name as a FunctionRef so that we do not have to
// pay the cost of constructing it unless there is an error.
bool ValidateTargetConstraints(const Message& options,
const DescriptorPool& pool,
DescriptorPool::ErrorCollector& error_collector,
absl::string_view file_name,
FieldOptions::OptionTargetType target_type) {
const Descriptor* descriptor =
pool.FindMessageTypeByName(options.GetTypeName());
if (descriptor == nullptr) {
// We were unable to find the options message in the descriptor pool. This
// implies that the proto files we are working with do not depend on
// descriptor.proto, in which case there are no custom options to worry
// about. We can therefore skip the use of DynamicMessage.
return ValidateTargetConstraintsRecursive(options, error_collector,
file_name, target_type);
} else {
DynamicMessageFactory factory;
std::unique_ptr<Message> dynamic_message(
factory.GetPrototype(descriptor)->New());
std::string serialized;
ABSL_CHECK(options.SerializeToString(&serialized));
ABSL_CHECK(dynamic_message->ParseFromString(serialized));
return ValidateTargetConstraintsRecursive(*dynamic_message, error_collector,
file_name, target_type);
}
}
// The overloaded GetTargetType() functions below allow us to map from a
// descriptor type to the associated OptionTargetType enum.
FieldOptions::OptionTargetType GetTargetType(const FileDescriptor*) {
return FieldOptions::TARGET_TYPE_FILE;
}
FieldOptions::OptionTargetType GetTargetType(
const Descriptor::ExtensionRange*) {
return FieldOptions::TARGET_TYPE_EXTENSION_RANGE;
}
FieldOptions::OptionTargetType GetTargetType(const Descriptor*) {
return FieldOptions::TARGET_TYPE_MESSAGE;
}
FieldOptions::OptionTargetType GetTargetType(const FieldDescriptor*) {
return FieldOptions::TARGET_TYPE_FIELD;
}
FieldOptions::OptionTargetType GetTargetType(const OneofDescriptor*) {
return FieldOptions::TARGET_TYPE_ONEOF;
}
FieldOptions::OptionTargetType GetTargetType(const EnumDescriptor*) {
return FieldOptions::TARGET_TYPE_ENUM;
} }
FieldOptions::OptionTargetType GetTargetType(const EnumValueDescriptor*) {
return FieldOptions::TARGET_TYPE_ENUM_ENTRY;
}
FieldOptions::OptionTargetType GetTargetType(const ServiceDescriptor*) {
return FieldOptions::TARGET_TYPE_SERVICE;
}
FieldOptions::OptionTargetType GetTargetType(const MethodDescriptor*) {
return FieldOptions::TARGET_TYPE_METHOD;
}
} // namespace
int CommandLineInterface::Run(int argc, const char* const argv[]) { int CommandLineInterface::Run(int argc, const char* const argv[]) {
Clear(); Clear();
@ -1189,31 +1365,50 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
bool validation_error = false; // Defer exiting so we log more warnings. bool validation_error = false; // Defer exiting so we log more warnings.
VisitDescriptors(parsed_files, [&](const FieldDescriptor* field) { VisitDescriptors(
if (HasReservedFieldNumber(field)) { absl::Span<const FileDescriptor*>(parsed_files.data(),
const char* error_link = nullptr; parsed_files.size()),
validation_error = true; [&](const FieldDescriptor* field) {
std::string error; if (HasReservedFieldNumber(field)) {
if (field->number() >= FieldDescriptor::kFirstReservedNumber && const char* error_link = nullptr;
field->number() <= FieldDescriptor::kLastReservedNumber) { validation_error = true;
error = absl::Substitute( std::string error;
"Field numbers $0 through $1 are reserved " if (field->number() >= FieldDescriptor::kFirstReservedNumber &&
"for the protocol buffer library implementation.", field->number() <= FieldDescriptor::kLastReservedNumber) {
FieldDescriptor::kFirstReservedNumber, error = absl::Substitute(
FieldDescriptor::kLastReservedNumber); "Field numbers $0 through $1 are reserved "
} else { "for the protocol buffer library implementation.",
error = absl::Substitute( FieldDescriptor::kFirstReservedNumber,
"Field number $0 is reserved for specific purposes.", FieldDescriptor::kLastReservedNumber);
field->number()); } else {
} error = absl::Substitute(
if (error_link) { "Field number $0 is reserved for specific purposes.",
absl::StrAppend(&error, "(See ", error_link, ")"); field->number());
} }
static_cast<DescriptorPool::ErrorCollector*>(error_collector.get()) if (error_link) {
->RecordError(field->file()->name(), field->full_name(), nullptr, absl::StrAppend(&error, "(See ", error_link, ")");
DescriptorPool::ErrorCollector::NUMBER, error); }
} static_cast<DescriptorPool::ErrorCollector*>(error_collector.get())
}); ->RecordError(field->file()->name(), field->full_name(), nullptr,
DescriptorPool::ErrorCollector::NUMBER, error);
}
});
// We visit one file at a time because we need to provide the file name for
// error messages. Usually we can get the file name from any descriptor with
// something like descriptor->file()->name(), but ExtensionRange does not
// support this.
for (const google::protobuf::FileDescriptor* file : parsed_files) {
VisitDescriptors(
absl::Span<const FileDescriptor*>(&file, 1),
[&](const auto* descriptor) {
if (!ValidateTargetConstraints(
descriptor->options(), *descriptor_pool, *error_collector,
file->name(), GetTargetType(descriptor))) {
validation_error = true;
}
});
}
if (validation_error) { if (validation_error) {

@ -2696,6 +2696,221 @@ TEST_F(CommandLineInterfaceTest, PrintFreeFieldNumbers) {
#endif #endif
} }
TEST_F(CommandLineInterfaceTest, TargetTypeEnforcement) {
// The target option on a field indicates what kind of entity it may apply to
// when it is used as an option. This test verifies that the enforcement
// works correctly on all entity types.
CreateTempFile("net/proto2/proto/descriptor.proto",
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
CreateTempFile("foo.proto",
R"schema(
syntax = "proto2";
package protobuf_unittest;
import "net/proto2/proto/descriptor.proto";
message MyOptions {
optional string file_option = 1 [targets = TARGET_TYPE_FILE];
optional string extension_range_option = 2 [targets =
TARGET_TYPE_EXTENSION_RANGE];
optional string message_option = 3 [targets = TARGET_TYPE_MESSAGE];
optional string field_option = 4 [targets = TARGET_TYPE_FIELD];
optional string oneof_option = 5 [targets = TARGET_TYPE_ONEOF];
optional string enum_option = 6 [targets = TARGET_TYPE_ENUM];
optional string enum_value_option = 7 [targets =
TARGET_TYPE_ENUM_ENTRY];
optional string service_option = 8 [targets = TARGET_TYPE_SERVICE];
optional string method_option = 9 [targets = TARGET_TYPE_METHOD];
}
extend google.protobuf.FileOptions {
optional MyOptions file_options = 5000;
}
extend google.protobuf.ExtensionRangeOptions {
optional MyOptions extension_range_options = 5000;
}
extend google.protobuf.MessageOptions {
optional MyOptions message_options = 5000;
}
extend google.protobuf.FieldOptions {
optional MyOptions field_options = 5000;
}
extend google.protobuf.OneofOptions {
optional MyOptions oneof_options = 5000;
}
extend google.protobuf.EnumOptions {
optional MyOptions enum_options = 5000;
}
extend google.protobuf.EnumValueOptions {
optional MyOptions enum_value_options = 5000;
}
extend google.protobuf.ServiceOptions {
optional MyOptions service_options = 5000;
}
extend google.protobuf.MethodOptions {
optional MyOptions method_options = 5000;
}
option (file_options).enum_option = "x";
message MyMessage {
option (message_options).enum_option = "x";
optional int32 i = 1 [(field_options).enum_option = "x"];
extensions 2 [(extension_range_options).enum_option = "x"];
oneof o {
option (oneof_options).enum_option = "x";
bool oneof_field = 3;
}
}
enum MyEnum {
option (enum_options).file_option = "x";
UNKNOWN_MY_ENUM = 0 [(enum_value_options).enum_option = "x"];
}
service MyService {
option (service_options).enum_option = "x";
rpc MyMethod(MyMessage) returns (MyMessage) {
option (method_options).enum_option = "x";
}
}
)schema");
Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `file`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `extension range`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `message`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `field`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `oneof`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.file_option "
"cannot be set on an entity of type `enum`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `enum entry`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `service`.");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.enum_option "
"cannot be set on an entity of type `method`.");
}
TEST_F(CommandLineInterfaceTest, TargetTypeEnforcementMultipleTargetsValid) {
CreateTempFile("net/proto2/proto/descriptor.proto",
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
CreateTempFile("foo.proto",
R"schema(
syntax = "proto2";
package protobuf_unittest;
import "net/proto2/proto/descriptor.proto";
message MyOptions {
optional string message_or_file_option = 1 [
targets = TARGET_TYPE_MESSAGE, targets = TARGET_TYPE_FILE];
}
extend google.protobuf.FileOptions {
optional MyOptions file_options = 5000;
}
extend google.protobuf.MessageOptions {
optional MyOptions message_options = 5000;
}
option (file_options).message_or_file_option = "x";
message MyMessage {
option (message_options).message_or_file_option = "y";
}
)schema");
Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
ExpectNoErrors();
}
TEST_F(CommandLineInterfaceTest, TargetTypeEnforcementMultipleTargetsInvalid) {
CreateTempFile("net/proto2/proto/descriptor.proto",
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
CreateTempFile("foo.proto",
R"schema(
syntax = "proto2";
package protobuf_unittest;
import "net/proto2/proto/descriptor.proto";
message MyOptions {
optional string message_or_file_option = 1 [
targets = TARGET_TYPE_MESSAGE, targets = TARGET_TYPE_FILE];
}
extend google.protobuf.EnumOptions {
optional MyOptions enum_options = 5000;
}
enum MyEnum {
MY_ENUM_UNSPECIFIED = 0;
option (enum_options).message_or_file_option = "y";
}
)schema");
Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
ExpectErrorSubstring(
"Option protobuf_unittest.MyOptions.message_or_file_option cannot be set "
"on an entity of type `enum`.");
}
TEST_F(CommandLineInterfaceTest,
TargetTypeEnforcementMultipleEdgesWithConstraintsValid) {
CreateTempFile("net/proto2/proto/descriptor.proto",
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
CreateTempFile("foo.proto",
R"schema(
syntax = "proto2";
package protobuf_unittest;
import "net/proto2/proto/descriptor.proto";
message A {
optional B b = 1 [targets = TARGET_TYPE_FILE,
targets = TARGET_TYPE_ENUM];
}
message B {
optional int32 i = 1 [targets = TARGET_TYPE_ONEOF,
targets = TARGET_TYPE_FILE];
}
extend google.protobuf.FileOptions {
optional A file_options = 5000;
}
option (file_options).b.i = 42;
)schema");
Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
ExpectNoErrors();
}
TEST_F(CommandLineInterfaceTest,
TargetTypeEnforcementMultipleEdgesWithConstraintsInvalid) {
CreateTempFile("net/proto2/proto/descriptor.proto",
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
CreateTempFile("foo.proto",
R"schema(
syntax = "proto2";
package protobuf_unittest;
import "net/proto2/proto/descriptor.proto";
message A {
optional B b = 1 [targets = TARGET_TYPE_ENUM];
}
message B {
optional int32 i = 1 [targets = TARGET_TYPE_ONEOF];
}
extend google.protobuf.FileOptions {
optional A file_options = 5000;
}
option (file_options).b.i = 42;
)schema");
Run("protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto");
// We have target constraint violations at two different edges in the file
// options, so let's make sure both are caught.
ExpectErrorSubstring(
"Option protobuf_unittest.A.b cannot be set on an entity of type `file`.");
ExpectErrorSubstring(
"Option protobuf_unittest.B.i cannot be set on an entity of type `file`.");
}
// =================================================================== // ===================================================================
// Test for --encode and --decode. Note that it would be easier to do this // Test for --encode and --decode. Note that it would be easier to do this

@ -38,12 +38,16 @@
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/memory/memory.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -64,8 +68,8 @@ void SetCordVariables(
(*variables)["default_variable_field"] = MakeDefaultFieldName(descriptor); (*variables)["default_variable_field"] = MakeDefaultFieldName(descriptor);
(*variables)["default_variable"] = (*variables)["default_variable"] =
descriptor->default_value_string().empty() descriptor->default_value_string().empty()
? ProtobufNamespace(options) + ? absl::StrCat(ProtobufNamespace(options),
"::internal::GetEmptyCordAlreadyInited()" "::internal::GetEmptyCordAlreadyInited()")
: absl::StrCat( : absl::StrCat(
QualifiedClassName(descriptor->containing_type(), options), QualifiedClassName(descriptor->containing_type(), options),
"::", MakeDefaultFieldName(descriptor)); "::", MakeDefaultFieldName(descriptor));
@ -285,8 +289,7 @@ void CordFieldGenerator::GenerateAggregateInitializer(
CordOneofFieldGenerator::CordOneofFieldGenerator( CordOneofFieldGenerator::CordOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options) const FieldDescriptor* descriptor, const Options& options)
: CordFieldGenerator(descriptor, options) { : CordFieldGenerator(descriptor, options) {}
}
void CordOneofFieldGenerator::GeneratePrivateMembers( void CordOneofFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const { io::Printer* printer) const {

@ -34,17 +34,18 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -334,8 +335,8 @@ class RepeatedEnum : public FieldGeneratorBase {
}; };
void RepeatedEnum::GenerateAccessorDeclarations(io::Printer* p) const { void RepeatedEnum::GenerateAccessorDeclarations(io::Printer* p) const {
auto v = p->WithVars(AnnotatedAccessors( auto v = p->WithVars(
field_, {"", "_internal_", "_internal_add_", "_internal_mutable_"})); AnnotatedAccessors(field_, {"", "_internal_", "_internal_mutable_"}));
auto vs = auto vs =
p->WithVars(AnnotatedAccessors(field_, {"set_", "add_"}, Semantic::kSet)); p->WithVars(AnnotatedAccessors(field_, {"set_", "add_"}, Semantic::kSet));
auto vm = auto vm =
@ -350,8 +351,6 @@ void RepeatedEnum::GenerateAccessorDeclarations(io::Printer* p) const {
$DEPRECATED$ $pb$::RepeatedField<int>* $mutable_name$(); $DEPRECATED$ $pb$::RepeatedField<int>* $mutable_name$();
private: private:
$Enum$ $_internal_name$(int index) const;
void $_internal_add_name$($Enum$ value);
const $pb$::RepeatedField<int>& $_internal_name$() const; const $pb$::RepeatedField<int>& $_internal_name$() const;
$pb$::RepeatedField<int>* $_internal_mutable_name$(); $pb$::RepeatedField<int>* $_internal_mutable_name$();
@ -364,7 +363,7 @@ void RepeatedEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
inline $Enum$ $Msg$::$name$(int index) const { inline $Enum$ $Msg$::$name$(int index) const {
$annotate_get$; $annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$) // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
return _internal_$name$(index); return static_cast<$Enum$>(_internal_$name$().Get(index));
} }
inline void $Msg$::set_$name$(int index, $Enum$ value) { inline void $Msg$::set_$name$(int index, $Enum$ value) {
$assert_valid$; $assert_valid$;
@ -373,7 +372,8 @@ void RepeatedEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
// @@protoc_insertion_point(field_set:$pkg.Msg.field$) // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
} }
inline void $Msg$::add_$name$($Enum$ value) { inline void $Msg$::add_$name$($Enum$ value) {
_internal_add_$name$(value); $assert_valid$;
_internal_mutable_$name$()->Add(value);
$annotate_add$ $annotate_add$
// @@protoc_insertion_point(field_add:$pkg.Msg.field$) // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
} }
@ -387,13 +387,6 @@ void RepeatedEnum::GenerateInlineAccessorDefinitions(io::Printer* p) const {
// @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$) // @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$)
return _internal_mutable_$name$(); return _internal_mutable_$name$();
} }
inline $Enum$ $Msg$::_internal_$name$(int index) const {
return static_cast<$Enum$>(_internal_$name$().Get(index));
}
inline void $Msg$::_internal_add_$name$($Enum$ value) {
$assert_valid$;
_internal_mutable_$name$()->Add(value);
}
inline const $pb$::RepeatedField<int>& $Msg$::_internal_$name$() const { inline const $pb$::RepeatedField<int>& $Msg$::_internal_$name$() const {
return $field_$; return $field_$;
} }
@ -421,7 +414,8 @@ void RepeatedEnum::GenerateSerializeWithCachedSizesToArray(
for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) { for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
target = stream->EnsureSpace(target); target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteEnumToArray( target = ::_pbi::WireFormatLite::WriteEnumToArray(
$number$, this->_internal_$name$(i), target); $number$, static_cast<$Enum$>(this->_internal_$name$().Get(i)),
target);
} }
)cc"); )cc");
} }
@ -455,7 +449,7 @@ void RepeatedEnum::GenerateByteSize(io::Printer* p) const {
for (std::size_t i = 0; i < count; ++i) { for (std::size_t i = 0; i < count; ++i) {
data_size += ::_pbi::WireFormatLite::EnumSize( data_size += ::_pbi::WireFormatLite::EnumSize(
this->_internal_$name$(static_cast<int>(i))); this->_internal_$name$().Get(static_cast<int>(i)));
} }
total_size += data_size; total_size += data_size;
$add_to_size$; $add_to_size$;

@ -30,339 +30,269 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <tuple> #include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/wire_format.h" #include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
namespace cpp { namespace cpp {
namespace { namespace {
void SetMessageVariables( using Sub = ::google::protobuf::io::Printer::Sub;
const FieldDescriptor* descriptor,
absl::flat_hash_map<absl::string_view, std::string>* variables, std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts,
const Options& options) { bool lite) {
(*variables)["type"] = ClassName(descriptor->message_type(), false); const auto* key = field->message_type()->map_key();
(*variables)["full_name"] = descriptor->full_name(); const auto* val = field->message_type()->map_value();
const FieldDescriptor* key = descriptor->message_type()->map_key(); std::string key_type = PrimitiveTypeName(opts, key->cpp_type());
const FieldDescriptor* val = descriptor->message_type()->map_value(); std::string val_type;
(*variables)["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
switch (val->cpp_type()) { switch (val->cpp_type()) {
case FieldDescriptor::CPPTYPE_MESSAGE: case FieldDescriptor::CPPTYPE_MESSAGE:
(*variables)["val_cpp"] = FieldMessageTypeName(val, options); val_type = FieldMessageTypeName(val, opts);
break; break;
case FieldDescriptor::CPPTYPE_ENUM: case FieldDescriptor::CPPTYPE_ENUM:
(*variables)["val_cpp"] = ClassName(val->enum_type(), true); val_type = ClassName(val->enum_type(), true);
break; break;
default: default:
(*variables)["val_cpp"] = PrimitiveTypeName(options, val->cpp_type()); val_type = PrimitiveTypeName(opts, val->cpp_type());
} break;
(*variables)["key_wire_type"] = absl::StrCat(
"TYPE_", absl::AsciiStrToUpper(DeclaredTypeMethodName(key->type())));
(*variables)["val_wire_type"] = absl::StrCat(
"TYPE_", absl::AsciiStrToUpper(DeclaredTypeMethodName(val->type())));
(*variables)["map_classname"] = ClassName(descriptor->message_type(), false);
(*variables)["number"] = absl::StrCat(descriptor->number());
(*variables)["tag"] = absl::StrCat(internal::WireFormat::MakeTag(descriptor));
if (HasDescriptorMethods(descriptor->file(), options)) {
(*variables)["lite"] = "";
} else {
(*variables)["lite"] = "Lite";
} }
}
class MapFieldGenerator : public FieldGeneratorBase {
public:
MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
~MapFieldGenerator() override = default;
// implements FieldGeneratorBase ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
void GenerateAccessorDeclarations(io::Printer* printer) const override;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
void GenerateClearingCode(io::Printer* printer) const override;
void GenerateMergingCode(io::Printer* printer) const override;
void GenerateSwappingCode(io::Printer* printer) const override;
void GenerateConstructorCode(io::Printer* printer) const override {}
void GenerateCopyConstructorCode(io::Printer* printer) const override;
void GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const override;
void GenerateByteSize(io::Printer* printer) const override;
void GenerateIsInitialized(io::Printer* printer) const override;
void GenerateConstexprAggregateInitializer(
io::Printer* printer) const override;
void GenerateCopyAggregateInitializer(io::Printer* printer) const override;
void GenerateAggregateInitializer(io::Printer* printer) const override;
void GenerateDestructorCode(io::Printer* printer) const override;
void GenerateArenaDestructorCode(io::Printer* printer) const override;
ArenaDtorNeeds NeedsArenaDestructor() const override;
private: return {
bool has_required_fields_; {"Map", absl::Substitute("::google::protobuf::Map<$0, $1>", key_type, val_type)},
}; {"Entry", ClassName(field->message_type(), false)},
{"Key", PrimitiveTypeName(opts, key->cpp_type())},
MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor, {"Val", val_type},
const Options& options, {"MapField", lite ? "MapFieldLite" : "MapField"},
MessageSCCAnalyzer* scc_analyzer) };
: FieldGeneratorBase(descriptor, options),
has_required_fields_(
scc_analyzer->HasRequiredFields(descriptor->message_type())) {
SetMessageVariables(descriptor, &variables_, options);
} }
void MapFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { class Map : public FieldGeneratorBase {
Formatter format(printer, variables_); public:
format( Map(const FieldDescriptor* field, const Options& opts,
"::$proto_ns$::internal::MapField$lite$<\n" MessageSCCAnalyzer* scc)
" $map_classname$,\n" : FieldGeneratorBase(field, opts),
" $key_cpp$, $val_cpp$,\n" field_(field),
" ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n" key_(field->message_type()->map_key()),
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> " val_(field->message_type()->map_value()),
"$name$_;\n"); opts_(&opts),
} has_required_(scc->HasRequiredFields(field->message_type())),
lite_(!HasDescriptorMethods(field->file(), opts)) {}
~Map() override = default;
std::vector<Sub> MakeVars() const override {
return Vars(field_, *opts_, lite_);
}
void MapFieldGenerator::GenerateAccessorDeclarations( void GenerateClearingCode(io::Printer* p) const override {
io::Printer* printer) const { p->Emit(R"cc(
Formatter format(printer, variables_); $field_$.Clear();
format( )cc");
"private:\n" }
"const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
" ${1$_internal_$name$$}$() const;\n"
"::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
" ${1$_internal_mutable_$name$$}$();\n"
"public:\n"
"$deprecated_attr$const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
" ${1$$name$$}$() const;\n",
descriptor_);
format(
"$deprecated_attr$::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
" ${1$mutable_$name$$}$();\n",
std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::ALIAS));
}
void MapFieldGenerator::GenerateInlineAccessorDefinitions( void GenerateMergingCode(io::Printer* p) const override {
io::Printer* printer) const { p->Emit(R"cc(
Formatter format(printer, variables_); _this->$field_$.MergeFrom(from.$field_$);
format( )cc");
"inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n" }
"$classname$::_internal_$name$() const {\n"
" return $field$.GetMap();\n"
"}\n"
"inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
"$classname$::$name$() const {\n"
"$annotate_get$"
" // @@protoc_insertion_point(field_map:$full_name$)\n"
" return _internal_$name$();\n"
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::_internal_mutable_$name$() {\n"
"$PrepareSplitMessageForWrite$"
" return $field$.MutableMap();\n"
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::mutable_$name$() {\n"
"$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable_map:$full_name$)\n"
" return _internal_mutable_$name$();\n"
"}\n");
}
void MapFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void GenerateSwappingCode(io::Printer* p) const override {
Formatter format(printer, variables_); p->Emit(R"cc(
format("$field$.Clear();\n"); $field_$.InternalSwap(&other->$field_$);
} )cc");
}
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) const { void GenerateCopyConstructorCode(io::Printer* p) const override {
Formatter format(printer, variables_); GenerateConstructorCode(p);
format("_this->$field$.MergeFrom(from.$field$);\n"); GenerateMergingCode(p);
} }
void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void GenerateIsInitialized(io::Printer* p) const override {
Formatter format(printer, variables_); if (!has_required_) return;
format("$field$.InternalSwap(&other->$field$);\n");
}
void MapFieldGenerator::GenerateCopyConstructorCode( p->Emit(R"cc(
io::Printer* printer) const { if (!$pbi$::AllAreInitialized($field_$)) {
GenerateConstructorCode(printer); return false;
GenerateMergingCode(printer); }
} )cc");
}
static void GenerateSerializationLoop(Formatter& format, bool string_key, void GenerateConstexprAggregateInitializer(io::Printer* p) const override {
bool string_value, p->Emit(R"cc(/* decltype($field_$) */ {})cc");
bool is_deterministic) {
if (is_deterministic) {
format(
"for (const auto& entry : "
"::_pbi::MapSorter$1$<MapType>(map_field)) {\n",
(string_key ? "Ptr" : "Flat"));
} else {
format("for (const auto& entry : map_field) {\n");
} }
{
auto loop_scope = format.ScopedIndent(); void GenerateCopyAggregateInitializer(io::Printer* p) const override {
format( // MapField has no move constructor, which prevents explicit aggregate
"target = WireHelper::InternalSerialize($number$, " // initialization pre-C++17.
"entry.first, entry.second, target, stream);\n"); p->Emit(R"cc(/* decltype($field_$) */ {})cc");
if (string_key || string_value) {
format("check_utf8(entry);\n");
}
} }
format("}\n");
}
void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray( void GenerateAggregateInitializer(io::Printer* p) const override {
io::Printer* printer) const { if (ShouldSplit(field_, *opts_)) {
Formatter format(printer, variables_); p->Emit(R"cc(
format("if (!this->_internal_$name$().empty()) {\n"); /* decltype($Msg$::Split::$name$_) */ {
format.Indent(); $pbi$::ArenaInitialized(), arena
const FieldDescriptor* key_field = descriptor_->message_type()->map_key(); }
const FieldDescriptor* value_field = descriptor_->message_type()->map_value(); )cc");
const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING; return;
const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING;
format(
"using MapType = ::_pb::Map<$key_cpp$, $val_cpp$>;\n"
"using WireHelper = $map_classname$::Funcs;\n"
"const auto& map_field = this->_internal_$name$();\n");
bool utf8_check = string_key || string_value;
if (utf8_check) {
format("auto check_utf8 = [](const MapType::value_type& entry) {\n");
{
auto check_scope = format.ScopedIndent();
// p may be unused when GetUtf8CheckMode evaluates to kNone,
// thus disabling the validation.
format("(void)entry;\n");
if (string_key) {
GenerateUtf8CheckCodeForString(
key_field, options_, false,
"entry.first.data(), static_cast<int>(entry.first.length()),\n",
format);
}
if (string_value) {
GenerateUtf8CheckCodeForString(
value_field, options_, false,
"entry.second.data(), static_cast<int>(entry.second.length()),\n",
format);
}
} }
format("};\n");
}
format( p->Emit(R"cc(
"\n" /* decltype($field_$) */ { $pbi$::ArenaInitialized(), arena }
"if (stream->IsSerializationDeterministic() && " )cc");
"map_field.size() > 1) {\n");
{
auto deterministic_scope = format.ScopedIndent();
GenerateSerializationLoop(format, string_key, string_value, true);
}
format("} else {\n");
{
auto map_order_scope = format.ScopedIndent();
GenerateSerializationLoop(format, string_key, string_value, false);
} }
format("}\n");
format.Outdent();
format("}\n");
}
void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const { void GenerateConstructorCode(io::Printer* p) const override {}
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ *\n"
" "
"::$proto_ns$::internal::FromIntSize(this->_internal_$name$_size());\n"
"for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
" it = this->_internal_$name$().begin();\n"
" it != this->_internal_$name$().end(); ++it) {\n"
" total_size += $map_classname$::Funcs::ByteSizeLong(it->first, "
"it->second);\n"
"}\n");
}
void MapFieldGenerator::GenerateIsInitialized(io::Printer* printer) const {
if (!has_required_fields_) return;
Formatter format(printer, variables_); void GenerateDestructorCode(io::Printer* p) const override {
format( if (ShouldSplit(field_, *opts_)) {
"if (!::$proto_ns$::internal::AllAreInitialized($field$)) return " p->Emit(R"cc(
"false;\n"); $cached_split_ptr$->$name$_.~$MapField$();
} )cc");
return;
}
void MapFieldGenerator::GenerateConstexprAggregateInitializer( p->Emit(R"cc(
io::Printer* printer) const { $field_$.~$MapField$();
Formatter format(printer, variables_); )cc");
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format("/*decltype($field$)*/{::_pbi::ConstantInitialized()}");
} else {
format("/*decltype($field$)*/{}");
} }
}
void MapFieldGenerator::GenerateCopyAggregateInitializer( void GeneratePrivateMembers(io::Printer* p) const override;
io::Printer* printer) const { void GenerateAccessorDeclarations(io::Printer* p) const override;
Formatter format(printer, variables_); void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
// MapField has no move constructor, which prevents explicit aggregate void GenerateSerializeWithCachedSizesToArray(io::Printer* p) const override;
// initialization pre-C++17. void GenerateByteSize(io::Printer* p) const override;
format("/*decltype($field$)*/{}");
}
void MapFieldGenerator::GenerateAggregateInitializer( private:
io::Printer* printer) const { const FieldDescriptor* field_;
Formatter format(printer, variables_); const FieldDescriptor* key_;
if (ShouldSplit(descriptor_, options_)) { const FieldDescriptor* val_;
format( const Options* opts_;
"/*decltype($classname$::Split::$name$_)*/" bool has_required_;
"{::_pbi::ArenaInitialized(), arena}"); bool lite_;
return; };
}
// MapField has no move constructor. void Map::GeneratePrivateMembers(io::Printer* p) const {
format("/*decltype($field$)*/{::_pbi::ArenaInitialized(), arena}"); p->Emit({{"kKeyType",
absl::AsciiStrToUpper(DeclaredTypeMethodName(key_->type()))},
{"kValType",
absl::AsciiStrToUpper(DeclaredTypeMethodName(val_->type()))}},
R"cc(
$pbi$::$MapField$<$Entry$, $Key$, $Val$,
$pbi$::WireFormatLite::TYPE_$kKeyType$,
$pbi$::WireFormatLite::TYPE_$kValType$>
$name$_;
)cc");
} }
void MapFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void Map::GenerateAccessorDeclarations(io::Printer* p) const {
Formatter format(printer, variables_); auto v1 = p->WithVars(
if (ShouldSplit(descriptor_, options_)) { AnnotatedAccessors(field_, {"", "_internal_", "_internal_mutable_"}));
format("$cached_split_ptr$->$name$_.~MapField$lite$();\n"); auto v2 = p->WithVars(AnnotatedAccessors(field_, {"mutable_"},
return; io::AnnotationCollector::kAlias));
} p->Emit(R"cc(
format("$field$.~MapField$lite$();\n"); $DEPRECATED$ const $Map$& $name$() const;
$DEPRECATED$ $Map$* $mutable_name$();
private:
const $Map$& $_internal_name$() const;
$Map$* $_internal_mutable_name$();
public:
)cc");
} }
void MapFieldGenerator::GenerateArenaDestructorCode( void Map::GenerateInlineAccessorDefinitions(io::Printer* p) const {
io::Printer* printer) const { p->Emit(R"cc(
if (NeedsArenaDestructor() == ArenaDtorNeeds::kNone) { inline const $Map$& $Msg$::_internal_$name$() const {
return; return $field_$.GetMap();
} }
inline const $Map$& $Msg$::$name$() const {
$annotate_get$;
// @@protoc_insertion_point(field_map:$pkg.Msg.field$)
return _internal_$name$();
}
inline $Map$* $Msg$::_internal_mutable_$name$() {
$PrepareSplitMessageForWrite$;
return $field_$.MutableMap();
}
inline $Map$* $Msg$::mutable_$name$() {
$annotate_mutable$;
// @@protoc_insertion_point(field_mutable_map:$pkg.Msg.field$)
return _internal_mutable_$name$();
}
)cc");
}
Formatter format(printer, variables_); void Map::GenerateSerializeWithCachedSizesToArray(io::Printer* p) const {
// _this is the object being destructed (we are inside a static method here). bool string_key = key_->type() == FieldDescriptor::TYPE_STRING;
format("_this->$field$.ArenaDestruct();\n"); bool string_val = val_->type() == FieldDescriptor::TYPE_STRING;
p->Emit(
{
{"Sorter", string_key ? "MapSorterPtr" : "MapSorterFlat"},
{"CheckUtf8",
[&] {
if (string_key) {
GenerateUtf8CheckCodeForString(
p, key_, *opts_, /*for_parse=*/false,
"entry.first.data(), "
"static_cast<int>(entry.first.length()),\n");
}
if (string_val) {
GenerateUtf8CheckCodeForString(
p, val_, *opts_, /*for_parse=*/false,
"entry.second.data(), "
"static_cast<int>(entry.second.length()),\n");
}
}},
},
R"cc(
if (!_internal_$name$().empty()) {
using MapType = $Map$;
using WireHelper = $Entry$::Funcs;
const auto& field = _internal_$name$();
if (stream->IsSerializationDeterministic() && field.size() > 1) {
for (const auto& entry : $pbi$::$Sorter$<MapType>(field)) {
target = WireHelper::InternalSerialize(
$number$, entry.first, entry.second, target, stream);
$CheckUtf8$;
}
} else {
for (const auto& entry : field) {
target = WireHelper::InternalSerialize(
$number$, entry.first, entry.second, target, stream);
$CheckUtf8$;
}
}
}
)cc");
} }
ArenaDtorNeeds MapFieldGenerator::NeedsArenaDestructor() const { void Map::GenerateByteSize(io::Printer* p) const {
return HasDescriptorMethods(descriptor_->file(), options_) p->Emit(R"cc(
? ArenaDtorNeeds::kRequired total_size += $kTagBytes$ * $pbi$::FromIntSize(_internal_$name$_size());
: ArenaDtorNeeds::kNone; for (const auto& entry : _internal_$name$()) {
total_size += $Entry$::Funcs::ByteSizeLong(entry.first, entry.second);
}
)cc");
} }
} // namespace } // namespace
std::unique_ptr<FieldGeneratorBase> MakeMapGenerator( std::unique_ptr<FieldGeneratorBase> MakeMapGenerator(
const FieldDescriptor* desc, const Options& options, const FieldDescriptor* desc, const Options& options,
MessageSCCAnalyzer* scc) { MessageSCCAnalyzer* scc) {
return std::make_unique<MapFieldGenerator>(desc, options, scc); return std::make_unique<Map>(desc, options, scc);
} }
} // namespace cpp } // namespace cpp

@ -38,6 +38,7 @@
#include <vector> #include <vector>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h" #include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h"
@ -54,37 +55,41 @@ namespace cpp {
namespace { namespace {
using ::google::protobuf::internal::cpp::HasHasbit; using ::google::protobuf::internal::cpp::HasHasbit;
using Sub = ::google::protobuf::io::Printer::Sub; using Sub = ::google::protobuf::io::Printer::Sub;
using ::google::protobuf::io::AnnotationCollector;
std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts, std::vector<Sub> Vars(const FieldDescriptor* field, const Options& opts,
bool weak) { bool weak) {
bool split = ShouldSplit(field, opts); bool split = ShouldSplit(field, opts);
bool is_foreign = IsCrossFileMessage(field);
std::string field_name = FieldMemberName(field, split); std::string field_name = FieldMemberName(field, split);
std::string type = FieldMessageTypeName(field, opts); std::string type = FieldMessageTypeName(field, opts);
std::string default_ref = std::string default_ref =
QualifiedDefaultInstanceName(field->message_type(), opts); QualifiedDefaultInstanceName(field->message_type(), opts);
std::string default_ptr = std::string default_ptr =
QualifiedDefaultInstancePtr(field->message_type(), opts); QualifiedDefaultInstancePtr(field->message_type(), opts);
absl::string_view base = "::google::protobuf::MessageLite";
return { return {
{"Submsg", type}, {"Submsg", type},
{"MemberType", !weak ? type : base},
{"CompleteType", !is_foreign ? type : base},
{"kDefault", default_ref},
{"kDefaultPtr", !weak
? default_ptr
: absl::Substitute("reinterpret_cast<const $0*>($1)",
base, default_ptr)},
{"base_cast", absl::Substitute("reinterpret_cast<$0*>",
!is_foreign && !weak ? type : base)},
{"cast_field_", {"cast_field_",
!weak ? field_name !weak ? field_name
: absl::Substitute("reinterpret_cast<$0*>($1)", type, field_name)}, : absl::Substitute("reinterpret_cast<$0*>($1)", type, field_name)},
{"kDefault", default_ref},
{"kDefaultPtr",
!weak ? default_ptr
: absl::Substitute("reinterpret_cast<const "
"::PROTOBUF_NAMESPACE_ID::MessageLite*>($0)",
default_ptr)},
{"Weak", weak ? "Weak" : ""}, {"Weak", weak ? "Weak" : ""},
{".weak", weak ? ".weak" : ""}, {".weak", weak ? ".weak" : ""},
Sub("StrongRef", Sub("StrongRef",
!weak ? "" !weak ? ""
: absl::Substitute( : absl::Substitute("::google::protobuf::internal::StrongReference("
" ::PROTOBUF_NAMESPACE_ID::internal::StrongReference(" "reinterpret_cast<const $0&>($1));\n",
"reinterpret_cast<const $0&>($1));\n", type, default_ref))
type, default_ref))
.WithSuffix(";"), .WithSuffix(";"),
}; };
} }
@ -108,10 +113,16 @@ class SingularMessage : public FieldGeneratorBase {
return Vars(field_, *opts_, weak_); return Vars(field_, *opts_, weak_);
} }
void GeneratePrivateMembers(io::Printer* p) const override; void GeneratePrivateMembers(io::Printer* p) const override {
p->Emit(R"cc(
$MemberType$* $name$_;
)cc");
}
void GenerateNonInlineAccessorDefinitions(io::Printer* p) const override {}
void GenerateAccessorDeclarations(io::Printer* p) const override; void GenerateAccessorDeclarations(io::Printer* p) const override;
void GenerateInlineAccessorDefinitions(io::Printer* p) const override; void GenerateInlineAccessorDefinitions(io::Printer* p) const override;
void GenerateNonInlineAccessorDefinitions(io::Printer* p) const override;
void GenerateInternalAccessorDeclarations(io::Printer* p) const override; void GenerateInternalAccessorDeclarations(io::Printer* p) const override;
void GenerateInternalAccessorDefinitions(io::Printer* p) const override; void GenerateInternalAccessorDefinitions(io::Printer* p) const override;
void GenerateClearingCode(io::Printer* p) const override; void GenerateClearingCode(io::Printer* p) const override;
@ -140,208 +151,169 @@ class SingularMessage : public FieldGeneratorBase {
bool is_foreign_; bool is_foreign_;
}; };
void SingularMessage::GeneratePrivateMembers(io::Printer* p) const {
if (weak_) {
p->Emit("$pb$::MessageLite* $name$_;\n");
} else {
p->Emit("$Submsg$* $name$_;\n");
}
}
void SingularMessage::GenerateAccessorDeclarations(io::Printer* p) const { void SingularMessage::GenerateAccessorDeclarations(io::Printer* p) const {
auto v = auto vars = AnnotatedAccessors(
p->WithVars({{"release_name", SafeFunctionName(field_->containing_type(), field_, {"", "set_allocated_", "unsafe_arena_set_allocated_",
field_, "release_")}}); "unsafe_arena_release_"});
Formatter format(p); vars.push_back(Sub{
format( "release_name",
"$DEPRECATED$ const $Submsg$& ${1$$name$$}$() const;\n" SafeFunctionName(field_->containing_type(), field_, "release_"),
"$DEPRECATED$ PROTOBUF_NODISCARD $Submsg$* " }
"${1$$release_name$$}$();\n", .AnnotatedAs(field_));
field_); auto v1 = p->WithVars(vars);
format("$DEPRECATED$ $Submsg$* ${1$mutable_$name$$}$();\n", auto v2 = p->WithVars(
std::make_tuple(field_, GeneratedCodeInfo::Annotation::ALIAS)); AnnotatedAccessors(field_, {"mutable_"}, AnnotationCollector::kAlias));
format(
"$DEPRECATED$ void ${1$set_allocated_$name$$}$" p->Emit(R"cc(
"($Submsg$* $name$);\n" $DEPRECATED$ const $Submsg$& $name$() const;
"private:\n" $DEPRECATED$ PROTOBUF_NODISCARD $Submsg$* $release_name$();
"const $Submsg$& ${1$_internal_$name$$}$() const;\n" $DEPRECATED$ $Submsg$* $mutable_name$();
"$Submsg$* ${1$_internal_mutable_$name$$}$();\n" $DEPRECATED$ void $set_allocated_name$($Submsg$* value);
"public:\n", $DEPRECATED$ void $unsafe_arena_set_allocated_name$($Submsg$* value);
field_); $DEPRECATED$ $Submsg$* $unsafe_arena_release_name$();
format(
"$DEPRECATED$ void " private:
"${1$unsafe_arena_set_allocated_$name$$}$(\n" const $Submsg$& _internal_$name$() const;
" $Submsg$* $name$);\n" $Submsg$* _internal_mutable_$name$();
"$DEPRECATED$ $Submsg$* ${1$unsafe_arena_release_$name$$}$();\n",
field_); public:
)cc");
} }
void SingularMessage::GenerateNonInlineAccessorDefinitions(
io::Printer* p) const {}
void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const { void SingularMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
auto v = auto v =
p->WithVars({{"release_name", SafeFunctionName(field_->containing_type(), p->WithVars({{"release_name", SafeFunctionName(field_->containing_type(),
field_, "release_")}}); field_, "release_")}});
p->Emit(
"inline const $Submsg$& $Msg$::_internal_$name$() const {\n"
"$StrongRef$;"
" const $Submsg$* p = $cast_field_$;\n"
" return p != nullptr ? *p : reinterpret_cast<const $Submsg$&>(\n"
" $kDefault$);\n"
"}\n"
"inline const $Submsg$& $Msg$::$name$() const {\n"
"$annotate_get$"
" // @@protoc_insertion_point(field_get:$pkg.Msg.field$)\n"
" return _internal_$name$();\n"
"}\n");
p->Emit(
"inline void $Msg$::unsafe_arena_set_allocated_$name$(\n"
" $Submsg$* $name$) {\n"
"$PrepareSplitMessageForWrite$"
// If we're not on an arena, free whatever we were holding before.
// (If we are on arena, we can just forget the earlier pointer.)
" if (GetArenaForAllocation() == nullptr) {\n"
" delete reinterpret_cast<$pb$::MessageLite*>($field_$);\n"
" }\n");
if (weak_) {
p->Emit(" $field_$ = reinterpret_cast<$pb$::MessageLite*>($name$);\n");
} else {
p->Emit(" $field_$ = $name$;\n");
}
if (has_hasbit_) {
p->Emit(
" if ($name$) {\n"
" $set_hasbit$\n"
" } else {\n"
" $clear_hasbit$\n"
" }\n");
}
p->Emit(
"$annotate_set$"
" // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
":$pkg.Msg.field$)\n"
"}\n");
p->Emit(
"inline $Submsg$* $Msg$::$release_name$() {\n"
"$StrongRef$;"
"$annotate_release$"
"$PrepareSplitMessageForWrite$"
" $clear_hasbit$\n"
" $Submsg$* temp = $cast_field_$;\n"
" $field_$ = nullptr;\n"
"#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" auto* old = reinterpret_cast<$pb$::MessageLite*>(temp);\n"
" temp = $pbi$::DuplicateIfNonNull(temp);\n"
" if (GetArenaForAllocation() == nullptr) { delete old; }\n"
"#else // PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" if (GetArenaForAllocation() != nullptr) {\n"
" temp = $pbi$::DuplicateIfNonNull(temp);\n"
" }\n"
"#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" return temp;\n"
"}\n"
"inline $Submsg$* $Msg$::unsafe_arena_release_$name$() {\n"
"$annotate_release$"
" // @@protoc_insertion_point(field_release:$pkg.Msg.field$)\n"
"$StrongRef$;"
"$PrepareSplitMessageForWrite$"
" $clear_hasbit$\n"
" $Submsg$* temp = $cast_field_$;\n"
" $field_$ = nullptr;\n"
" return temp;\n"
"}\n");
p->Emit(
"inline $Submsg$* $Msg$::_internal_mutable_$name$() {\n"
"$StrongRef$;"
" $set_hasbit$\n"
" if ($field_$ == nullptr) {\n"
" auto* p = CreateMaybeMessage<$Submsg$>(GetArenaForAllocation());\n");
if (weak_) {
p->Emit(" $field_$ = reinterpret_cast<$pb$::MessageLite*>(p);\n");
} else {
p->Emit(" $field_$ = p;\n");
}
p->Emit(
" }\n"
" return $cast_field_$;\n"
"}\n"
"inline $Submsg$* $Msg$::mutable_$name$() {\n"
// TODO(b/122856539): add tests to make sure all write accessors are able
// to prepare split message allocation.
"$PrepareSplitMessageForWrite$"
" $Submsg$* _msg = _internal_mutable_$name$();\n"
"$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable:$pkg.Msg.field$)\n"
" return _msg;\n"
"}\n");
// We handle the most common case inline, and delegate less common cases to
// the slow fallback function.
p->Emit(
"inline void $Msg$::set_allocated_$name$($Submsg$* $name$) {\n"
" $pb$::Arena* message_arena = GetArenaForAllocation();\n");
p->Emit(
"$PrepareSplitMessageForWrite$"
" if (message_arena == nullptr) {\n");
if (is_foreign_) {
p->Emit(
" delete reinterpret_cast< "
"$pb$::MessageLite*>($field_$);\n");
} else {
p->Emit(" delete $field_$;\n");
}
p->Emit( p->Emit(
" }\n" {
" if ($name$) {\n"); {"update_hasbit",
if (is_foreign_) { [&] {
// We have to read the arena through the virtual method, because the type if (!has_hasbit_) return;
// isn't defined in this file. p->Emit(R"cc(
p->Emit( if (value != nullptr) {
" $pb$::Arena* submessage_arena =\n" $set_hasbit$
" $pb$::Arena::InternalGetOwningArena(\n" } else {
" reinterpret_cast<$pb$::MessageLite*>(" $clear_hasbit$
"$name$));\n"); }
} else { )cc");
p->Emit( }},
" $pb$::Arena* submessage_arena =\n" },
" $pb$::Arena::InternalGetOwningArena(" R"cc(
"$name$);\n"); inline const $Submsg$& $Msg$::_internal_$name$() const {
} $StrongRef$;
p->Emit( const $Submsg$* p = $cast_field_$;
" if (message_arena != submessage_arena) {\n" return p != nullptr ? *p : reinterpret_cast<const $Submsg$&>($kDefault$);
" $name$ = $pbi$::GetOwnedMessage(\n" }
" message_arena, $name$, submessage_arena);\n" inline const $Submsg$& $Msg$::$name$() const {
" }\n" $annotate_get$;
" $set_hasbit$\n" // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
" } else {\n" return _internal_$name$();
" $clear_hasbit$\n" }
" }\n"); inline void $Msg$::unsafe_arena_set_allocated_$name$($Submsg$* value) {
if (weak_) { $PrepareSplitMessageForWrite$;
p->Emit(" $field_$ = reinterpret_cast<MessageLite*>($name$);\n"); //~ If we're not on an arena, free whatever we were holding before.
} else { //~ (If we are on arena, we can just forget the earlier pointer.)
p->Emit(" $field_$ = $name$;\n"); if (GetArenaForAllocation() == nullptr) {
} delete reinterpret_cast<$pb$::MessageLite*>($field_$);
p->Emit( }
"$annotate_set$" $field_$ = reinterpret_cast<$MemberType$*>(value);
" // @@protoc_insertion_point(field_set_allocated:$pkg.Msg.field$)\n" $update_hasbit$;
"}\n"); $annotate_set$;
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:$pkg.Msg.field$)
}
inline $Submsg$* $Msg$::$release_name$() {
$StrongRef$;
$annotate_release$;
$PrepareSplitMessageForWrite$;
$clear_hasbit$;
$Submsg$* released = $cast_field_$;
$field_$ = nullptr;
#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
auto* old = reinterpret_cast<$pb$::MessageLite*>(released);
released = $pbi$::DuplicateIfNonNull(released);
if (GetArenaForAllocation() == nullptr) {
delete old;
}
#else // PROTOBUF_FORCE_COPY_IN_RELEASE
if (GetArenaForAllocation() != nullptr) {
released = $pbi$::DuplicateIfNonNull(released);
}
#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE
return released;
}
inline $Submsg$* $Msg$::unsafe_arena_release_$name$() {
$annotate_release$;
// @@protoc_insertion_point(field_release:$pkg.Msg.field$)
$StrongRef$;
$PrepareSplitMessageForWrite$;
$clear_hasbit$;
$Submsg$* temp = $cast_field_$;
$field_$ = nullptr;
return temp;
}
inline $Submsg$* $Msg$::_internal_mutable_$name$() {
$StrongRef$;
$set_hasbit$;
if ($field_$ == nullptr) {
auto* p = CreateMaybeMessage<$Submsg$>(GetArenaForAllocation());
$field_$ = reinterpret_cast<$MemberType$*>(p);
}
return $cast_field_$;
}
inline $Submsg$* $Msg$::mutable_$name$() {
//~ TODO(b/122856539): add tests to make sure all write accessors are
//~ able to prepare split message allocation.
$PrepareSplitMessageForWrite$;
$Submsg$* _msg = _internal_mutable_$name$();
$annotate_mutable$;
// @@protoc_insertion_point(field_mutable:$pkg.Msg.field$)
return _msg;
}
//~ We handle the most common case inline, and delegate less common
//~ cases to the slow fallback function.
inline void $Msg$::set_allocated_$name$($Submsg$* value) {
$pb$::Arena* message_arena = GetArenaForAllocation();
$PrepareSplitMessageForWrite$;
if (message_arena == nullptr) {
delete $base_cast$($field_$);
}
if (value != nullptr) {
//~ When $Submsg$ is a cross-file type, have to read the arena
//~ through the virtual method, because the type isn't defined in
//~ this file, only forward-declated.
$pb$::Arena* submessage_arena =
$pb$::Arena::InternalGetOwningArena($base_cast$(value));
if (message_arena != submessage_arena) {
value = $pbi$::GetOwnedMessage(message_arena, value, submessage_arena);
}
$set_hasbit$;
} else {
$clear_hasbit$;
}
$field_$ = reinterpret_cast<$MemberType$*>(value);
$annotate_set$;
// @@protoc_insertion_point(field_set_allocated:$pkg.Msg.field$)
}
)cc");
} }
void SingularMessage::GenerateInternalAccessorDeclarations( void SingularMessage::GenerateInternalAccessorDeclarations(
io::Printer* p) const { io::Printer* p) const {
if (weak_) { if (!weak_) {
p->Emit( p->Emit(R"cc(
"static const $pb$::MessageLite& $name$(" static const $Submsg$& $name$(const $Msg$* msg);
"const $Msg$* msg);\n" )cc");
"static $pb$::MessageLite* mutable_$name$(" return;
"$Msg$* msg);\n");
} else {
p->Emit("static const $Submsg$& $name$(const $Msg$* msg);\n");
} }
p->Emit(R"cc(
static const $pb$::MessageLite& $name$(const $Msg$* msg);
static $pb$::MessageLite* mutable_$name$($Msg$* msg);
)cc");
} }
void SingularMessage::GenerateInternalAccessorDefinitions( void SingularMessage::GenerateInternalAccessorDefinitions(
@ -349,49 +321,65 @@ void SingularMessage::GenerateInternalAccessorDefinitions(
// In theory, these accessors could be inline in _Internal. However, in // In theory, these accessors could be inline in _Internal. However, in
// practice, the linker is then not able to throw them out making implicit // practice, the linker is then not able to throw them out making implicit
// weak dependencies not work at all. // weak dependencies not work at all.
if (weak_) {
// These private accessors are used by MergeFrom and if (!weak_) {
// MergePartialFromCodedStream, and their purpose is to provide access to
// the field without creating a strong dependency on the message type.
p->Emit(
"const $pb$::MessageLite& $Msg$::_Internal::$name$(\n"
" const $Msg$* msg) {\n"
" if (msg->$field_$ != nullptr) {\n"
" return *msg->$field_$;\n"
" } else {\n"
" return *$kDefaultPtr$;\n"
" }\n"
"}\n");
p->Emit(
"$pb$::MessageLite*\n"
"$Msg$::_Internal::mutable_$name$($Msg$* msg) {\n");
if (has_hasbit_) {
p->Emit(" msg->$set_hasbit$\n");
}
if (!is_oneof_) {
p->Emit(" if (msg->$field_$ == nullptr) {\n");
} else {
p->Emit(
" if (msg->$not_has_field$) {\n"
" msg->clear_$oneof_name$();\n"
" msg->set_has_$name$();\n");
}
p->Emit(
" msg->$field_$ = $kDefaultPtr$->New(\n"
" msg->GetArenaForAllocation());\n"
" }\n"
" return msg->$field_$;\n"
"}\n");
} else {
// This inline accessor directly returns member field and is used in // This inline accessor directly returns member field and is used in
// Serialize such that AFDO profile correctly captures access information to // Serialize such that AFDO profile correctly captures access information to
// message fields under serialize. // message fields under serialize.
p->Emit( p->Emit(R"cc(
"const $Submsg$&\n" const $Submsg$& $Msg$::_Internal::$name$(const $Msg$* msg) {
"$Msg$::_Internal::$name$(const $Msg$* msg) {\n" return *msg->$field_$;
" return *msg->$field_$;\n" }
"}\n"); )cc");
return;
} }
// These private accessors are used by MergeFrom and
// MergePartialFromCodedStream, and their purpose is to provide access to
// the field without creating a strong dependency on the message type.
p->Emit(
{
{"update_hasbit",
[&] {
if (!has_hasbit_) return;
p->Emit(R"cc(
msg->$set_hasbit$;
)cc");
}},
{"is_already_set",
[&] {
if (!is_oneof_) {
p->Emit("msg->$field_$ == nullptr");
} else {
p->Emit("msg->$not_has_field$");
}
}},
{"clear_oneof",
[&] {
if (!is_oneof_) return;
p->Emit(R"cc(
msg->clear_$oneof_name$();
msg->set_has_$name$();
)cc");
}},
},
R"cc(
const $pb$::MessageLite& $Msg$::_Internal::$name$(const $Msg$* msg) {
if (msg->$field_$ != nullptr) {
return *msg->$field_$;
} else {
return *$kDefaultPtr$;
}
}
$pb$::MessageLite* $Msg$::_Internal::mutable_$name$($Msg$* msg) {
$update_hasbit$;
if ($is_already_set$) {
$clear_oneof$;
msg->$field_$ = $kDefaultPtr$->New(msg->GetArenaForAllocation());
}
return msg->$field_$;
}
)cc");
} }
void SingularMessage::GenerateClearingCode(io::Printer* p) const { void SingularMessage::GenerateClearingCode(io::Printer* p) const {
@ -746,11 +734,7 @@ class RepeatedMessage : public FieldGeneratorBase {
}; };
void RepeatedMessage::GeneratePrivateMembers(io::Printer* p) const { void RepeatedMessage::GeneratePrivateMembers(io::Printer* p) const {
if (weak_) { p->Emit("$pb$::$Weak$RepeatedPtrField< $Submsg$ > $name$_;\n");
p->Emit("$pb$::WeakRepeatedPtrField< $Submsg$ > $name$_;\n");
} else {
p->Emit("$pb$::RepeatedPtrField< $Submsg$ > $name$_;\n");
}
} }
void RepeatedMessage::GenerateAccessorDeclarations(io::Printer* p) const { void RepeatedMessage::GenerateAccessorDeclarations(io::Printer* p) const {
@ -763,14 +747,19 @@ void RepeatedMessage::GenerateAccessorDeclarations(io::Printer* p) const {
std::make_tuple(field_, GeneratedCodeInfo::Annotation::ALIAS)); std::make_tuple(field_, GeneratedCodeInfo::Annotation::ALIAS));
format( format(
"private:\n" "private:\n"
"const $Submsg$& ${1$_internal_$name$$}$(int index) const;\n"
"$Submsg$* ${1$_internal_add_$name$$}$();\n"
"const $pb$::RepeatedPtrField<$Submsg$>& _internal_$name$() const;\n" "const $pb$::RepeatedPtrField<$Submsg$>& _internal_$name$() const;\n"
"$pb$::RepeatedPtrField<$Submsg$>* _internal_mutable_$name$();\n" "$pb$::RepeatedPtrField<$Submsg$>* _internal_mutable_$name$();\n");
"public:\n", if (weak_) {
format(
"const $pb$::WeakRepeatedPtrField<$Submsg$>& _internal_weak_$name$() "
"const;\n"
"$pb$::WeakRepeatedPtrField<$Submsg$>* "
"_internal_mutable_weak_$name$();\n");
}
format(
"public:\n"
"$DEPRECATED$ const $Submsg$& ${1$$name$$}$(int index) const;\n",
field_); field_);
format("$DEPRECATED$ const $Submsg$& ${1$$name$$}$(int index) const;\n",
field_);
format("$DEPRECATED$ $Submsg$* ${1$add_$name$$}$();\n", format("$DEPRECATED$ $Submsg$* ${1$add_$name$$}$();\n",
std::make_tuple(field_, GeneratedCodeInfo::Annotation::SET)); std::make_tuple(field_, GeneratedCodeInfo::Annotation::SET));
format( format(
@ -796,37 +785,25 @@ void RepeatedMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
" return _internal_mutable_$name$();\n" " return _internal_mutable_$name$();\n"
"}\n"); "}\n");
if (opts_->safe_boundary_check) { p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
p->Emit( {"GetExtraArg",
"inline const $Submsg$& $Msg$::_internal_$name$(int index) const " [&] {
"{\n" p->Emit(opts_->safe_boundary_check
" return _internal_$name$().InternalCheckedGet(index,\n" ? ", reinterpret_cast<const $Submsg$&>($kDefault$)"
" reinterpret_cast<const $Submsg$&>($kDefault$));\n" : "");
"}\n"); }}},
} else { "inline const $Submsg$& $Msg$::$name$(int index) const {\n"
p->Emit( "$annotate_get$"
"inline const $Submsg$& $Msg$::_internal_$name$(int index) const " " // @@protoc_insertion_point(field_get:$pkg.Msg.field$)\n"
"{\n" " $StrongRef$;"
"$StrongRef$;" " return _internal_$name$().$Get$(index$GetExtraArg$);\n"
" return _internal_$name$().Get(index);\n" "}\n"
"}\n"); "inline $Submsg$* $Msg$::add_$name$() {\n"
} " $Submsg$* _add = _internal_mutable_$name$()->Add();\n"
"$annotate_add_mutable$"
p->Emit( " // @@protoc_insertion_point(field_add:$pkg.Msg.field$)\n"
"inline const $Submsg$& $Msg$::$name$(int index) const {\n" " return _add;\n"
"$annotate_get$" "}\n");
" // @@protoc_insertion_point(field_get:$pkg.Msg.field$)\n"
" return _internal_$name$(index);\n"
"}\n"
"inline $Submsg$* $Msg$::_internal_add_$name$() {\n"
" return _internal_mutable_$name$()->Add();\n"
"}\n"
"inline $Submsg$* $Msg$::add_$name$() {\n"
" $Submsg$* _add = _internal_add_$name$();\n"
"$annotate_add_mutable$"
" // @@protoc_insertion_point(field_add:$pkg.Msg.field$)\n"
" return _add;\n"
"}\n");
p->Emit( p->Emit(
"inline const $pb$::RepeatedPtrField< $Submsg$ >&\n" "inline const $pb$::RepeatedPtrField< $Submsg$ >&\n"
@ -837,15 +814,28 @@ void RepeatedMessage::GenerateInlineAccessorDefinitions(io::Printer* p) const {
" return _internal_$name$();\n" " return _internal_$name$();\n"
"}\n"); "}\n");
p->Emit( p->Emit(R"cc(
"inline const $pb$::RepeatedPtrField<$Submsg$>&\n" inline const $pb$::RepeatedPtrField<$Submsg$>&
"$classname$::_internal_$name$() const {\n" $classname$::_internal_$name$() const {
" return $field$$.weak$;\n" return $field$$.weak$;
"}\n" }
"inline $pb$::RepeatedPtrField<$Submsg$>*\n" inline $pb$::RepeatedPtrField<$Submsg$>*
"$classname$::_internal_mutable_$name$() {\n" $classname$::_internal_mutable_$name$() {
" return &$field$$.weak$;\n" return &$field$$.weak$;
"}\n"); }
)cc");
if (weak_) {
p->Emit(R"cc(
inline const $pb$::WeakRepeatedPtrField<$Submsg$>&
$Msg$::_internal_weak_$name$() const {
return $field$;
}
inline $pb$::WeakRepeatedPtrField<$Submsg$>*
$Msg$::_internal_mutable_weak_$name$() {
return &$field$;
}
)cc");
}
} }
void RepeatedMessage::GenerateClearingCode(io::Printer* p) const { void RepeatedMessage::GenerateClearingCode(io::Printer* p) const {
@ -858,7 +848,9 @@ void RepeatedMessage::GenerateClearingCode(io::Printer* p) const {
void RepeatedMessage::GenerateMergingCode(io::Printer* p) const { void RepeatedMessage::GenerateMergingCode(io::Printer* p) const {
if (weak_) { if (weak_) {
p->Emit("_this->$field_$.MergeFrom(from.$field_$);\n"); p->Emit(
"_this->_internal_mutable_weak_$name$()->MergeFrom(from._internal_weak_"
"$name$());\n");
} else { } else {
p->Emit( p->Emit(
"_this->_internal_mutable_$name$()->MergeFrom(" "_this->_internal_mutable_$name$()->MergeFrom("
@ -868,7 +860,9 @@ void RepeatedMessage::GenerateMergingCode(io::Printer* p) const {
void RepeatedMessage::GenerateSwappingCode(io::Printer* p) const { void RepeatedMessage::GenerateSwappingCode(io::Printer* p) const {
if (weak_) { if (weak_) {
p->Emit("$field_$.InternalSwap(&other->$field_$);\n"); p->Emit(
"_internal_mutable_weak_$name$()->InternalSwap(other->_internal_"
"mutable_weak_$name$());\n");
} else { } else {
p->Emit( p->Emit(
"_internal_mutable_$name$()->InternalSwap(other->_internal_mutable_" "_internal_mutable_$name$()->InternalSwap(other->_internal_mutable_"
@ -881,11 +875,7 @@ void RepeatedMessage::GenerateConstructorCode(io::Printer* p) const {
} }
void RepeatedMessage::GenerateDestructorCode(io::Printer* p) const { void RepeatedMessage::GenerateDestructorCode(io::Printer* p) const {
if (weak_) { p->Emit("$field_$.~$Weak$RepeatedPtrField();\n");
p->Emit("$field_$.~WeakRepeatedPtrField();\n");
} else {
p->Emit("_internal_mutable_$name$()->~RepeatedPtrField();\n");
}
} }
void RepeatedMessage::GenerateSerializeWithCachedSizesToArray( void RepeatedMessage::GenerateSerializeWithCachedSizesToArray(
@ -914,7 +904,7 @@ void RepeatedMessage::GenerateSerializeWithCachedSizesToArray(
" i < n; i++) {\n"); " i < n; i++) {\n");
if (field_->type() == FieldDescriptor::TYPE_MESSAGE) { if (field_->type() == FieldDescriptor::TYPE_MESSAGE) {
p->Emit( p->Emit(
" const auto& repfield = this->_internal_$name$(i);\n" " const auto& repfield = this->_internal_$name$().Get(i);\n"
" target = $pbi$::WireFormatLite::\n" " target = $pbi$::WireFormatLite::\n"
" InternalWrite$declared_type$($number$, " " InternalWrite$declared_type$($number$, "
"repfield, repfield.GetCachedSize(), target, stream);\n" "repfield, repfield.GetCachedSize(), target, stream);\n"
@ -924,7 +914,7 @@ void RepeatedMessage::GenerateSerializeWithCachedSizesToArray(
" target = stream->EnsureSpace(target);\n" " target = stream->EnsureSpace(target);\n"
" target = $pbi$::WireFormatLite::\n" " target = $pbi$::WireFormatLite::\n"
" InternalWrite$declared_type$($number$, " " InternalWrite$declared_type$($number$, "
"this->_internal_$name$(i), target, stream);\n" "this->_internal_$name$().Get(i), target, stream);\n"
"}\n"); "}\n");
} }
} }

@ -32,19 +32,20 @@
// Based on original Protocol Buffers design by // Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others. // Sanjay Ghemawat, Jeff Dean, and others.
#include <cstddef>
#include <memory> #include <memory>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/log/absl_log.h" #include "absl/log/absl_log.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h" #include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
#include "google/protobuf/wire_format.h" #include "google/protobuf/wire_format.h"
@ -197,17 +198,16 @@ void SingularPrimitive::GenerateAccessorDeclarations(io::Printer* p) const {
auto v = p->WithVars( auto v = p->WithVars(
AnnotatedAccessors(field_, {"", "_internal_", "_internal_set_"})); AnnotatedAccessors(field_, {"", "_internal_", "_internal_set_"}));
auto vs = p->WithVars(AnnotatedAccessors(field_, {"set_"}, Semantic::kSet)); auto vs = p->WithVars(AnnotatedAccessors(field_, {"set_"}, Semantic::kSet));
p->Emit( p->Emit(R"cc(
R"cc( $DEPRECATED$ $Type$ $name$() const;
$DEPRECATED$ $Type$ $name$() const; $DEPRECATED$ void $set_name$($Type$ value);
$DEPRECATED$ void $set_name$($Type$ value);
private: private:
$Type$ $_internal_name$() const; $Type$ $_internal_name$() const;
void $_internal_set_name$($Type$ value); void $_internal_set_name$($Type$ value);
public: public:
)cc"); )cc");
} }
void SingularPrimitive::GenerateInlineAccessorDefinitions( void SingularPrimitive::GenerateInlineAccessorDefinitions(
@ -257,11 +257,25 @@ void SingularPrimitive::GenerateInlineAccessorDefinitions(
void SingularPrimitive::GenerateSerializeWithCachedSizesToArray( void SingularPrimitive::GenerateSerializeWithCachedSizesToArray(
io::Printer* p) const { io::Printer* p) const {
p->Emit(R"cc( if ((descriptor_->number() < 16) &&
target = stream->EnsureSpace(target); (descriptor_->type() == FieldDescriptor::TYPE_INT32 ||
target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray( descriptor_->type() == FieldDescriptor::TYPE_INT64 ||
$number$, this->_internal_$name$(), target); descriptor_->type() == FieldDescriptor::TYPE_ENUM)) {
)cc"); // Call special non-inlined routine with tag number hardcoded as a
// template parameter that handles the EnsureSpace and the writing
// of the tag+value to the array
p->Emit(R"cc(
target = ::$proto_ns$::internal::WireFormatLite::
Write$declared_type$ToArrayWithField<$number$>(
stream, this->_internal_$name$(), target);
)cc");
} else {
p->Emit(R"cc(
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray(
$number$, this->_internal_$name$(), target);
)cc");
}
} }
void SingularPrimitive::GenerateByteSize(io::Printer* p) const { void SingularPrimitive::GenerateByteSize(io::Printer* p) const {
@ -390,8 +404,8 @@ void RepeatedPrimitive::GeneratePrivateMembers(io::Printer* p) const {
} }
void RepeatedPrimitive::GenerateAccessorDeclarations(io::Printer* p) const { void RepeatedPrimitive::GenerateAccessorDeclarations(io::Printer* p) const {
auto v = p->WithVars(AnnotatedAccessors( auto v = p->WithVars(
field_, {"", "_internal_", "_internal_add_", "_internal_mutable_"})); AnnotatedAccessors(field_, {"", "_internal_", "_internal_mutable_"}));
auto vs = auto vs =
p->WithVars(AnnotatedAccessors(field_, {"set_", "add_"}, Semantic::kSet)); p->WithVars(AnnotatedAccessors(field_, {"set_", "add_"}, Semantic::kSet));
auto va = auto va =
@ -404,8 +418,6 @@ void RepeatedPrimitive::GenerateAccessorDeclarations(io::Printer* p) const {
$DEPRECATED$ $pb$::RepeatedField<$Type$>* $mutable_name$(); $DEPRECATED$ $pb$::RepeatedField<$Type$>* $mutable_name$();
private: private:
$Type$ $_internal_name$(int index) const;
void $_internal_add_name$($Type$ value);
const $pb$::RepeatedField<$Type$>& $_internal_name$() const; const $pb$::RepeatedField<$Type$>& $_internal_name$() const;
$pb$::RepeatedField<$Type$>* $_internal_mutable_name$(); $pb$::RepeatedField<$Type$>* $_internal_mutable_name$();
@ -419,7 +431,7 @@ void RepeatedPrimitive::GenerateInlineAccessorDefinitions(
inline $Type$ $Msg$::$name$(int index) const { inline $Type$ $Msg$::$name$(int index) const {
$annotate_get$; $annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$) // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
return _internal_$name$(index); return _internal_$name$().Get(index);
} }
inline void $Msg$::set_$name$(int index, $Type$ value) { inline void $Msg$::set_$name$(int index, $Type$ value) {
$annotate_set$; $annotate_set$;
@ -427,7 +439,7 @@ void RepeatedPrimitive::GenerateInlineAccessorDefinitions(
// @@protoc_insertion_point(field_set:$pkg.Msg.field$) // @@protoc_insertion_point(field_set:$pkg.Msg.field$)
} }
inline void $Msg$::add_$name$($Type$ value) { inline void $Msg$::add_$name$($Type$ value) {
_internal_add_$name$(value); _internal_mutable_$name$()->Add(value);
$annotate_add$; $annotate_add$;
// @@protoc_insertion_point(field_add:$pkg.Msg.field$) // @@protoc_insertion_point(field_add:$pkg.Msg.field$)
} }
@ -442,12 +454,6 @@ void RepeatedPrimitive::GenerateInlineAccessorDefinitions(
return _internal_mutable_$name$(); return _internal_mutable_$name$();
} }
inline $Type$ $Msg$::_internal_$name$(int index) const {
return _internal_$name$().Get(index);
}
inline void $Msg$::_internal_add_$name$($Type$ value) {
_internal_mutable_$name$()->Add(value);
}
inline const $pb$::RepeatedField<$Type$>& $Msg$::_internal_$name$() const { inline const $pb$::RepeatedField<$Type$>& $Msg$::_internal_$name$() const {
return $field_$; return $field_$;
} }
@ -464,7 +470,7 @@ void RepeatedPrimitive::GenerateSerializeWithCachedSizesToArray(
for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) { for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
target = stream->EnsureSpace(target); target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray( target = ::_pbi::WireFormatLite::Write$DeclaredType$ToArray(
$number$, this->_internal_$name$(i), target); $number$, this->_internal_$name$().Get(i), target);
} }
)cc"); )cc");
return; return;

@ -36,12 +36,14 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/field_generators/generators.h" #include "google/protobuf/compiler/cpp/field_generators/generators.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
@ -769,8 +771,7 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const {
)cc"); )cc");
} }
auto v1 = p->WithVars( auto v1 = p->WithVars(AnnotatedAccessors(field_, {"", "_internal_"}));
AnnotatedAccessors(field_, {"", "_internal_", "_internal_add_"}));
auto v2 = p->WithVars( auto v2 = p->WithVars(
AnnotatedAccessors(field_, {"set_", "add_"}, AnnotationCollector::kSet)); AnnotatedAccessors(field_, {"set_", "add_"}, AnnotationCollector::kSet));
auto v3 = p->WithVars( auto v3 = p->WithVars(
@ -794,8 +795,6 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const {
$DEPRECATED$ $pb$::RepeatedPtrField<std::string>* $mutable_name$(); $DEPRECATED$ $pb$::RepeatedPtrField<std::string>* $mutable_name$();
private: private:
const std::string& $_internal_name$(int index) const;
std::string* $_internal_add_name$();
const $pb$::RepeatedPtrField<std::string>& _internal_$name$() const; const $pb$::RepeatedPtrField<std::string>& _internal_$name$() const;
$pb$::RepeatedPtrField<std::string>* _internal_mutable_$name$(); $pb$::RepeatedPtrField<std::string>* _internal_mutable_$name$();
@ -805,18 +804,15 @@ void RepeatedString::GenerateAccessorDeclarations(io::Printer* p) const {
void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const { void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"}, p->Emit({{"Get", opts_->safe_boundary_check ? "InternalCheckedGet" : "Get"},
{"get_args", {"GetExtraArg",
[&] { [&] {
if (!opts_->safe_boundary_check) { p->Emit(opts_->safe_boundary_check
p->Emit("index"); ? ", $pbi$::GetEmptyStringAlreadyInited()"
return; : "");
}
p->Emit(R"cc(index, $pbi$::GetEmptyStringAlreadyInited())cc");
}}}, }}},
R"cc( R"cc(
inline std::string* $Msg$::add_$name$() { inline std::string* $Msg$::add_$name$() {
std::string* _s = _internal_add_$name$(); std::string* _s = _internal_mutable_$name$()->Add();
$annotate_add_mutable$; $annotate_add_mutable$;
// @@protoc_insertion_point(field_add_mutable:$pkg.Msg.field$) // @@protoc_insertion_point(field_add_mutable:$pkg.Msg.field$)
return _s; return _s;
@ -824,7 +820,7 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
inline const std::string& $Msg$::$name$(int index) const { inline const std::string& $Msg$::$name$(int index) const {
$annotate_get$; $annotate_get$;
// @@protoc_insertion_point(field_get:$pkg.Msg.field$) // @@protoc_insertion_point(field_get:$pkg.Msg.field$)
return _internal_$name$(index); return _internal_$name$().$Get$(index$GetExtraArg$);
} }
inline std::string* $Msg$::mutable_$name$(int index) { inline std::string* $Msg$::mutable_$name$(int index) {
$annotate_mutable$; $annotate_mutable$;
@ -898,12 +894,6 @@ void RepeatedString::GenerateInlineAccessorDefinitions(io::Printer* p) const {
// @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$) // @@protoc_insertion_point(field_mutable_list:$pkg.Msg.field$)
return _internal_mutable_$name$(); return _internal_mutable_$name$();
} }
inline const std::string& $Msg$::_internal_$name$(int index) const {
return _internal_$name$().$Get$($get_args$);
}
inline std::string* $Msg$::_internal_add_$name$() {
return _internal_mutable_$name$()->Add();
}
inline const ::$proto_ns$::RepeatedPtrField<std::string>& inline const ::$proto_ns$::RepeatedPtrField<std::string>&
$Msg$::_internal_$name$() const { $Msg$::_internal_$name$() const {
return $field_$; return $field_$;
@ -925,7 +915,7 @@ void RepeatedString::GenerateSerializeWithCachedSizesToArray(
}}}, }}},
R"cc( R"cc(
for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) { for (int i = 0, n = this->_internal_$name$_size(); i < n; ++i) {
const auto& s = this->_internal_$name$(i); const auto& s = this->_internal_$name$().Get(i);
$utf8_check$; $utf8_check$;
target = stream->Write$DeclaredType$($number$, s, target); target = stream->Write$DeclaredType$($number$, s, target);
} }

@ -34,6 +34,7 @@
#include "google/protobuf/compiler/cpp/file.h" #include "google/protobuf/compiler/cpp/file.h"
#include <functional>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <string> #include <string>
@ -169,7 +170,7 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* p) {
// Only do this for protobuf's own types. There are some google3 protos using // 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 // macros as field names and the generated code compiles after the macro
// expansion. Undefing these macros actually breaks such code. // expansion. Undefing these macros actually breaks such code.
if (file_->name() != "net/proto2/compiler/proto/plugin.proto" && if (file_->name() != "third_party/protobuf/compiler/plugin.proto" &&
file_->name() != "google/protobuf/compiler/plugin.proto") { file_->name() != "google/protobuf/compiler/plugin.proto") {
return; return;
} }
@ -207,6 +208,15 @@ void FileGenerator::GenerateSharedHeaderCode(io::Printer* p) {
{"undefs", [&] { GenerateMacroUndefs(p); }}, {"undefs", [&] { GenerateMacroUndefs(p); }},
{"global_state_decls", {"global_state_decls",
[&] { GenerateGlobalStateFunctionDeclarations(p); }}, [&] { GenerateGlobalStateFunctionDeclarations(p); }},
{"any_metadata",
[&] {
NamespaceOpener ns(ProtobufNamespace(options_), p);
p->Emit(R"cc(
namespace internal {
class AnyMetadata;
} // namespace internal
)cc");
}},
{"fwd_decls", [&] { GenerateForwardDeclarations(p); }}, {"fwd_decls", [&] { GenerateForwardDeclarations(p); }},
{"proto2_ns_enums", {"proto2_ns_enums",
[&] { GenerateProto2NamespaceEnumSpecializations(p); }}, [&] { GenerateProto2NamespaceEnumSpecializations(p); }},
@ -250,11 +260,7 @@ void FileGenerator::GenerateSharedHeaderCode(io::Printer* p) {
#define $dllexport_macro$$ dllexport_decl$ #define $dllexport_macro$$ dllexport_decl$
$undefs$ $undefs$
PROTOBUF_NAMESPACE_OPEN $any_metadata$;
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
$global_state_decls$; $global_state_decls$;
$fwd_decls$ $fwd_decls$
@ -523,6 +529,17 @@ void FileGenerator::GenerateSourcePrelude(io::Printer* p) {
} }
} }
bool FileGenerator::IsFileDescriptorProto() const {
if (Namespace(file_, options_) !=
absl::StrCat("::", ProtobufNamespace(options_))) {
return false;
}
for (int i = 0; i < file_->message_type_count(); ++i) {
if (file_->message_type(i)->name() == "FileDescriptorProto") return true;
}
return false;
}
void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) { void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
MessageGenerator* generator = message_generators_[idx].get(); MessageGenerator* generator = message_generators_[idx].get();
@ -563,25 +580,50 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
generator->GenerateConstexprConstructor(p); generator->GenerateConstexprConstructor(p);
p->Emit( if (IsFileDescriptorProto()) {
{ p->Emit(
{"type", DefaultInstanceType(generator->descriptor(), options_)}, {
{"name", DefaultInstanceName(generator->descriptor(), options_)}, {"type", DefaultInstanceType(generator->descriptor(), options_)},
{"default", [&] { generator->GenerateInitDefaultSplitInstance(p); }}, {"name", DefaultInstanceName(generator->descriptor(), options_)},
{"class", ClassName(generator->descriptor())}, {"class", ClassName(generator->descriptor())},
}, },
R"cc( R"cc(
struct $type$ { struct $type$ {
PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {} #if defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
~$type$() {} constexpr $type$() : _instance(::_pbi::ConstantInitialized{}) {}
union { #else // defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
$class$ _instance; $type$() {}
void Init() { ::new (&_instance) $class$(); };
#endif // defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
~$type$() {}
union {
$class$ _instance;
};
}; };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $type$ $name$; PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $type$ $name$;
)cc"); )cc");
} else {
p->Emit(
{
{"type", DefaultInstanceType(generator->descriptor(), options_)},
{"name", DefaultInstanceName(generator->descriptor(), options_)},
{"class", ClassName(generator->descriptor())},
},
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) { for (int i = 0; i < generator->descriptor()->field_count(); ++i) {
const FieldDescriptor* field = generator->descriptor()->field(i); const FieldDescriptor* field = generator->descriptor()->field(i);
@ -1104,15 +1146,43 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) {
// because in some situations that would otherwise pull in a lot of // because in some situations that would otherwise pull in a lot of
// unnecessary code that can't be stripped by --gc-sections. Descriptor // unnecessary code that can't be stripped by --gc-sections. Descriptor
// initialization will still be performed lazily when it's needed. // initialization will still be performed lazily when it's needed.
if (file_->name() == "net/proto2/proto/descriptor.proto") { 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");
} }
p->Emit({{"dummy", UniqueName("dynamic_init_dummy", file_, options_)}}, R"cc( // However, we must provide a way to force initialize the default instances
// Force running AddDescriptors() at dynamic initialization time. // of FileDescriptorProto which will be used during registration of other
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 // files.
static ::_pbi::AddDescriptorsRunner $dummy$(&$desc_table$); if (IsFileDescriptorProto()) {
)cc"); NamespaceOpener ns(p);
ns.ChangeTo(absl::StrCat(ProtobufNamespace(options_), "::internal"));
p->Emit(
{{"dummy", UniqueName("dynamic_init_dummy", file_, options_)},
{"initializers", absl::StrJoin(message_generators_, "\n",
[&](std::string* out, const auto& gen) {
absl::StrAppend(
out,
DefaultInstanceName(
gen->descriptor(), options_),
".Init();");
})}},
R"cc(
//~ Emit wants an indented line, so give it a comment to strip.
#if !defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
PROTOBUF_EXPORT void InitializeFileDescriptorDefaultInstancesSlow() {
$initializers$;
}
PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
static std::true_type $dummy${
(InitializeFileDescriptorDefaultInstances(), std::true_type{})};
#endif // !defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
)cc");
}
} }
class FileGenerator::ForwardDeclarations { class FileGenerator::ForwardDeclarations {
@ -1231,10 +1301,20 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* p) {
decl.second.Print(p, options_); decl.second.Print(p, options_);
} }
ns.ChangeTo("PROTOBUF_NAMESPACE_ID"); ns.ChangeTo(ProtobufNamespace(options_));
for (const auto& decl : decls) { for (const auto& decl : decls) {
decl.second.PrintTopLevelDecl(p, options_); decl.second.PrintTopLevelDecl(p, options_);
} }
if (IsFileDescriptorProto()) {
ns.ChangeTo(absl::StrCat(ProtobufNamespace(options_), "::internal"));
p->Emit(R"cc(
//~ Emit wants an indented line, so give it a comment to strip.
#if !defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
PROTOBUF_EXPORT void InitializeFileDescriptorDefaultInstancesSlow();
#endif // !defined(PROTOBUF_CONSTINIT_DEFAULT_INSTANCES)
)cc");
}
} }
void FileGenerator::GenerateLibraryIncludes(io::Printer* p) { void FileGenerator::GenerateLibraryIncludes(io::Printer* p) {

@ -168,6 +168,8 @@ class FileGenerator {
void GenerateProto2NamespaceEnumSpecializations(io::Printer* p); void GenerateProto2NamespaceEnumSpecializations(io::Printer* p);
bool IsFileDescriptorProto() const;
// Sometimes the names we use in a .proto file happen to be defined as // 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 // macros on some platforms (e.g., macro/minor used in plugin.proto are
// defined as macros in sys/types.h on FreeBSD and a few other platforms). // defined as macros in sys/types.h on FreeBSD and a few other platforms).

@ -61,7 +61,7 @@ absl::flat_hash_map<absl::string_view, std::string> CommonVars(
const Options& options) { const Options& options) {
bool is_oss = options.opensource_runtime; bool is_oss = options.opensource_runtime;
return { return {
{"proto_ns", ProtobufNamespace(options)}, {"proto_ns", std::string(ProtobufNamespace(options))},
{"pb", absl::StrCat("::", ProtobufNamespace(options))}, {"pb", absl::StrCat("::", ProtobufNamespace(options))},
{"pbi", absl::StrCat("::", ProtobufNamespace(options), "::internal")}, {"pbi", absl::StrCat("::", ProtobufNamespace(options), "::internal")},

@ -76,11 +76,9 @@ namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
namespace cpp { namespace cpp {
namespace { namespace {
constexpr absl::string_view kAnyMessageName = "Any";
static const char kAnyMessageName[] = "Any"; constexpr absl::string_view kAnyProtoFile = "google/protobuf/any.proto";
static const char kAnyProtoFile[] = "google/protobuf/any.proto";
std::string DotsToColons(absl::string_view name) { std::string DotsToColons(absl::string_view name) {
return absl::StrReplaceAll(name, {{".", "::"}}); return absl::StrReplaceAll(name, {{".", "::"}});
@ -257,18 +255,17 @@ void SetCommonMessageDataVariables(
absl::flat_hash_map<absl::string_view, std::string> UnknownFieldsVars( absl::flat_hash_map<absl::string_view, std::string> UnknownFieldsVars(
const Descriptor* desc, const Options& opts) { const Descriptor* desc, const Options& opts) {
std::string proto_ns = ProtobufNamespace(opts);
std::string unknown_fields_type; std::string unknown_fields_type;
std::string default_instance; std::string default_instance;
if (UseUnknownFieldSet(desc->file(), opts)) { if (UseUnknownFieldSet(desc->file(), opts)) {
unknown_fields_type = absl::StrCat("::", proto_ns, "::UnknownFieldSet"); unknown_fields_type =
absl::StrCat("::", ProtobufNamespace(opts), "::UnknownFieldSet");
default_instance = absl::StrCat(unknown_fields_type, "::default_instance"); default_instance = absl::StrCat(unknown_fields_type, "::default_instance");
} else { } else {
unknown_fields_type = unknown_fields_type =
PrimitiveTypeName(opts, FieldDescriptor::CPPTYPE_STRING); PrimitiveTypeName(opts, FieldDescriptor::CPPTYPE_STRING);
default_instance = default_instance = absl::StrCat("::", ProtobufNamespace(opts),
absl::StrCat("::", proto_ns, "::internal::GetEmptyString"); "::internal::GetEmptyString");
} }
return { return {
@ -457,18 +454,7 @@ std::string Namespace(absl::string_view package) {
std::string Namespace(const FileDescriptor* d) { return Namespace(d, {}); } std::string Namespace(const FileDescriptor* d) { return Namespace(d, {}); }
std::string Namespace(const FileDescriptor* d, const Options& options) { std::string Namespace(const FileDescriptor* d, const Options& options) {
std::string ns = Namespace(d->package()); return Namespace(d->package());
if (IsWellKnownMessage(d) && options.opensource_runtime) {
// Written with string concatenation to prevent rewriting of
// ::google::protobuf.
constexpr absl::string_view prefix =
"::google::" // prevent clang-format reflowing
"protobuf";
absl::string_view new_ns(ns);
absl::ConsumePrefix(&new_ns, prefix);
return absl::StrCat("::PROTOBUF_NAMESPACE_ID", new_ns);
}
return ns;
} }
std::string Namespace(const Descriptor* d) { return Namespace(d, {}); } std::string Namespace(const Descriptor* d) { return Namespace(d, {}); }
@ -1161,28 +1147,14 @@ void NamespaceOpener::ChangeTo(absl::string_view name) {
} }
for (size_t i = name_stack_.size(); i > common_idx; i--) { for (size_t i = name_stack_.size(); i > common_idx; i--) {
const auto& ns = name_stack_[i - 1]; p_->Emit({{"ns", name_stack_[i - 1]}}, R"(
if (ns == "PROTOBUF_NAMESPACE_ID") { } // namespace $ns$
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) { for (size_t i = common_idx; i < new_stack.size(); ++i) {
const auto& ns = new_stack[i]; p_->Emit({{"ns", new_stack[i]}}, R"(
if (ns == "PROTOBUF_NAMESPACE_ID") { namespace $ns$ {
p_->Emit(R"cc( )");
PROTOBUF_NAMESPACE_OPEN
)cc");
} else {
p_->Emit({{"ns", ns}}, R"(
namespace $ns$ {
)");
}
} }
name_stack_ = std::move(new_stack); name_stack_ = std::move(new_stack);
@ -1424,8 +1396,8 @@ bool GetBootstrapBasename(const Options& options, absl::string_view basename,
new absl::flat_hash_map<absl::string_view, std::string>{ new absl::flat_hash_map<absl::string_view, std::string>{
{"net/proto2/proto/descriptor", {"net/proto2/proto/descriptor",
"third_party/protobuf/descriptor"}, "third_party/protobuf/descriptor"},
{"net/proto2/compiler/proto/plugin", {"third_party/protobuf/compiler/plugin",
"net/proto2/compiler/proto/plugin"}, "third_party/protobuf/compiler/plugin"},
{"net/proto2/compiler/proto/profile", {"net/proto2/compiler/proto/profile",
"net/proto2/compiler/proto/profile_bootstrap"}, "net/proto2/compiler/proto/profile_bootstrap"},
}; };

@ -41,21 +41,20 @@
#include <string> #include <string>
#include <tuple> #include <tuple>
#include "google/protobuf/compiler/scc.h"
#include "google/protobuf/compiler/code_generator.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "absl/strings/match.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/names.h"
#include "google/protobuf/compiler/cpp/options.h" #include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/compiler/scc.h"
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/port.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
#include "google/protobuf/port.h"
// Must be included last. // Must be included last.
#include "google/protobuf/port_def.inc" #include "google/protobuf/port_def.inc"
@ -64,23 +63,27 @@ namespace google {
namespace protobuf { namespace protobuf {
namespace compiler { namespace compiler {
namespace cpp { namespace cpp {
enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 }; enum class ArenaDtorNeeds { kNone = 0, kOnDemand = 1, kRequired = 2 };
inline std::string ProtobufNamespace(const Options& /* options */) { inline absl::string_view ProtobufNamespace(const Options& opts) {
return "PROTOBUF_NAMESPACE_ID"; // This won't be transformed by copybara, since copybara looks for google::protobuf::.
constexpr absl::string_view kGoogle3Ns = "proto2";
constexpr absl::string_view kOssNs = "google::protobuf";
return opts.opensource_runtime ? kOssNs : kGoogle3Ns;
} }
inline std::string MacroPrefix(const Options& /* options */) { inline std::string MacroPrefix(const Options& options) {
return "GOOGLE_PROTOBUF"; // Constants are different in the internal and external version.
return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF";
} }
inline std::string DeprecatedAttribute(const Options& /* options */, inline std::string DeprecatedAttribute(const Options&,
const FieldDescriptor* d) { const FieldDescriptor* d) {
return d->options().deprecated() ? "[[deprecated]] " : ""; return d->options().deprecated() ? "[[deprecated]] " : "";
} }
inline std::string DeprecatedAttribute(const Options& /* options */, inline std::string DeprecatedAttribute(const Options&,
const EnumValueDescriptor* d) { const EnumValueDescriptor* d) {
return d->options().deprecated() ? "[[deprecated]] " : ""; return d->options().deprecated() ? "[[deprecated]] " : "";
} }
@ -119,10 +122,10 @@ std::string Namespace(const FileDescriptor* d, const Options& options);
std::string Namespace(const Descriptor* d, const Options& options); std::string Namespace(const Descriptor* d, const Options& options);
std::string Namespace(const FieldDescriptor* d, const Options& options); std::string Namespace(const FieldDescriptor* d, const Options& options);
std::string Namespace(const EnumDescriptor* d, const Options& options); std::string Namespace(const EnumDescriptor* d, const Options& options);
std::string Namespace(const FileDescriptor* d); PROTOC_EXPORT std::string Namespace(const FileDescriptor* d);
std::string Namespace(const Descriptor* d); PROTOC_EXPORT std::string Namespace(const Descriptor* d);
std::string Namespace(const FieldDescriptor* d); PROTOC_EXPORT std::string Namespace(const FieldDescriptor* d);
std::string Namespace(const EnumDescriptor* d); PROTOC_EXPORT std::string Namespace(const EnumDescriptor* d);
class MessageSCCAnalyzer; class MessageSCCAnalyzer;
@ -136,14 +139,14 @@ bool CanClearByZeroing(const FieldDescriptor* field);
bool HasTrivialSwap(const FieldDescriptor* field, const Options& options, bool HasTrivialSwap(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer); MessageSCCAnalyzer* scc_analyzer);
std::string ClassName(const Descriptor* descriptor); PROTOC_EXPORT std::string ClassName(const Descriptor* descriptor);
std::string ClassName(const EnumDescriptor* enum_descriptor); PROTOC_EXPORT std::string ClassName(const EnumDescriptor* enum_descriptor);
std::string QualifiedClassName(const Descriptor* d, const Options& options); std::string QualifiedClassName(const Descriptor* d, const Options& options);
std::string QualifiedClassName(const EnumDescriptor* d, const Options& options); std::string QualifiedClassName(const EnumDescriptor* d, const Options& options);
std::string QualifiedClassName(const Descriptor* d); PROTOC_EXPORT std::string QualifiedClassName(const Descriptor* d);
std::string QualifiedClassName(const EnumDescriptor* d); PROTOC_EXPORT std::string QualifiedClassName(const EnumDescriptor* d);
// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very // DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
// unreadable at the callsite. // unreadable at the callsite.
@ -215,7 +218,7 @@ std::string ResolveKeyword(absl::string_view name);
// The name is coerced to lower-case to emulate proto1 behavior. People // The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names // should be using lowercase-with-underscores style for proto field names
// anyway, so normally this just returns field->name(). // anyway, so normally this just returns field->name().
std::string FieldName(const FieldDescriptor* field); PROTOC_EXPORT std::string FieldName(const FieldDescriptor* field);
// Returns the (unqualified) private member name for this field in C++ code. // Returns the (unqualified) private member name for this field in C++ code.
std::string FieldMemberName(const FieldDescriptor* field, bool split); std::string FieldMemberName(const FieldDescriptor* field, bool split);
@ -393,8 +396,7 @@ bool ShouldSplit(const FieldDescriptor* field, const Options& options);
bool ShouldForceAllocationOnConstruction(const Descriptor* desc, bool ShouldForceAllocationOnConstruction(const Descriptor* desc,
const Options& options); const Options& options);
inline bool IsFieldUsed(const FieldDescriptor* /* field */, inline bool IsFieldUsed(const FieldDescriptor* /* field */, const Options&) {
const Options& /* options */) {
return true; return true;
} }
@ -703,13 +705,23 @@ bool UsingImplicitWeakFields(const FileDescriptor* file,
bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer); MessageSCCAnalyzer* scc_analyzer);
inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) { inline std::string SimpleBaseClass(const Descriptor* desc,
if (!HasDescriptorMethods(desc->file(), options)) return false; const Options& options) {
if (desc->extension_range_count() != 0) return false; if (!HasDescriptorMethods(desc->file(), options)) return "";
if (desc->field_count() == 0) return true; if (desc->extension_range_count() != 0) return "";
// Don't use a simple base class if the field tracking is enabled. This
// ensures generating all methods to track.
if (options.field_listener_options.inject_field_listener_events) return "";
if (desc->field_count() == 0) {
return "ZeroFieldsBase";
}
// TODO(jorg): Support additional common message types with only one // TODO(jorg): Support additional common message types with only one
// or two fields // or two fields
return false; return "";
}
inline bool HasSimpleBaseClass(const Descriptor* desc, const Options& options) {
return !SimpleBaseClass(desc, options).empty();
} }
inline bool HasSimpleBaseClasses(const FileDescriptor* file, inline bool HasSimpleBaseClasses(const FileDescriptor* file,
@ -721,18 +733,6 @@ inline bool HasSimpleBaseClasses(const FileDescriptor* file,
return v; return v;
} }
inline std::string SimpleBaseClass(const Descriptor* desc,
const Options& options) {
if (!HasDescriptorMethods(desc->file(), options)) return "";
if (desc->extension_range_count() != 0) return "";
if (desc->field_count() == 0) {
return "ZeroFieldsBase";
}
// TODO(jorg): Support additional common message types with only one
// or two fields
return "";
}
// Returns true if this message has a _tracker_ field. // Returns true if this message has a _tracker_ field.
inline bool HasTracker(const Descriptor* desc, const Options& options) { inline bool HasTracker(const Descriptor* desc, const Options& options) {
return options.field_listener_options.inject_field_listener_events && return options.field_listener_options.inject_field_listener_events &&

@ -45,10 +45,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/map_entry_lite.h"
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h" #include "absl/container/flat_hash_set.h"
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
@ -59,7 +55,6 @@
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/enum.h" #include "google/protobuf/compiler/cpp/enum.h"
#include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/extension.h"
#include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/field.h"
@ -117,20 +112,24 @@ std::string ConditionalToCheckBitmasks(
void PrintPresenceCheck(const FieldDescriptor* field, void PrintPresenceCheck(const FieldDescriptor* field,
const std::vector<int>& has_bit_indices, io::Printer* p, const std::vector<int>& has_bit_indices, io::Printer* p,
int* cached_has_word_index) { int* cached_has_word_index) {
Formatter format(p);
if (!field->options().weak()) { if (!field->options().weak()) {
int has_bit_index = has_bit_indices[field->index()]; int has_bit_index = has_bit_indices[field->index()];
if (*cached_has_word_index != (has_bit_index / 32)) { if (*cached_has_word_index != (has_bit_index / 32)) {
*cached_has_word_index = (has_bit_index / 32); *cached_has_word_index = (has_bit_index / 32);
format("cached_has_bits = $has_bits$[$1$];\n", *cached_has_word_index); p->Emit({{"index", *cached_has_word_index}},
R"cc(
cached_has_bits = $has_bits$[$index$];
)cc");
} }
const std::string mask = p->Emit({{"mask", absl::StrFormat("0x%08xu", 1u << (has_bit_index % 32))}},
absl::StrCat(absl::Hex(1u << (has_bit_index % 32), absl::kZeroPad8)); R"cc(
format("if (cached_has_bits & 0x$1$u) {\n", mask); if (cached_has_bits & $mask$) {
)cc");
} else { } else {
format("if (has_$1$()) {\n", FieldName(field)); p->Emit(R"cc(
if (has_$name$()) {
)cc");
} }
format.Indent();
} }
struct FieldOrderingByNumber { struct FieldOrderingByNumber {
@ -210,7 +209,6 @@ RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields,
bool EmitFieldNonDefaultCondition(io::Printer* p, const std::string& prefix, bool EmitFieldNonDefaultCondition(io::Printer* p, const std::string& prefix,
const FieldDescriptor* field) { const FieldDescriptor* field) {
ABSL_CHECK(!HasHasbit(field)); ABSL_CHECK(!HasHasbit(field));
Formatter format(p);
auto v = p->WithVars({{ auto v = p->WithVars({{
{"prefix", prefix}, {"prefix", prefix},
{"name", FieldName(field)}, {"name", FieldName(field)},
@ -219,34 +217,42 @@ bool EmitFieldNonDefaultCondition(io::Printer* p, const std::string& prefix,
// if non-zero (numeric) or non-empty (string). // if non-zero (numeric) or non-empty (string).
if (!field->is_repeated() && !field->containing_oneof()) { if (!field->is_repeated() && !field->containing_oneof()) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) { if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
format("if (!$prefix$_internal_$name$().empty()) {\n"); p->Emit(R"cc(
if (!$prefix$_internal_$name$().empty()) {
)cc");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields still have has_$name$() methods. // Message fields still have has_$name$() methods.
format("if ($prefix$_internal_has_$name$()) {\n"); p->Emit(R"cc(
if ($prefix$_internal_has_$name$()) {
)cc");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
format( p->Emit(R"cc(
"static_assert(sizeof(::uint32_t) == sizeof(float), \"Code assumes " static_assert(sizeof(::uint32_t) == sizeof(float),
"::uint32_t and float are the same size.\");\n" "Code assumes ::uint32_t and float are the same size.");
"float tmp_$name$ = $prefix$_internal_$name$();\n" float tmp_$name$ = $prefix$_internal_$name$();
"::uint32_t raw_$name$;\n" ::uint32_t raw_$name$;
"memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n" memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));
"if (raw_$name$ != 0) {\n"); if (raw_$name$ != 0) {
)cc");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) {
format( p->Emit(R"cc(
"static_assert(sizeof(::uint64_t) == sizeof(double), \"Code assumes " static_assert(sizeof(::uint64_t) == sizeof(double),
"::uint64_t and double are the same size.\");\n" "Code assumes ::uint64_t and double are the same size.");
"double tmp_$name$ = $prefix$_internal_$name$();\n" double tmp_$name$ = $prefix$_internal_$name$();
"::uint64_t raw_$name$;\n" ::uint64_t raw_$name$;
"memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));\n" memcpy(&raw_$name$, &tmp_$name$, sizeof(tmp_$name$));
"if (raw_$name$ != 0) {\n"); if (raw_$name$ != 0) {
)cc");
} else { } else {
format("if ($prefix$_internal_$name$() != 0) {\n"); p->Emit(R"cc(
if ($prefix$_internal_$name$() != 0) {
)cc");
} }
format.Indent();
return true; return true;
} else if (field->real_containing_oneof()) { } else if (field->real_containing_oneof()) {
format("if ($has_field$) {\n"); p->Emit(R"cc(
format.Indent(); if ($has_field$) {
)cc");
return true; return true;
} }
return false; return false;
@ -419,7 +425,6 @@ bool ColdChunkSkipper::IsColdChunk(int chunk) {
void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index, void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
const std::string& from, io::Printer* p) { const std::string& from, io::Printer* p) {
Formatter format(p);
if (!access_info_map_) { if (!access_info_map_) {
return; return;
} else if (chunk < limit_chunk_) { } else if (chunk < limit_chunk_) {
@ -443,42 +448,52 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
} }
// Emit has_bit check for each has_bit_dword index. // Emit has_bit check for each has_bit_dword index.
format("if (PROTOBUF_PREDICT_FALSE("); p->Emit(
int first_word = HasbitWord(chunk, 0); {{"cond",
while (chunk < limit_chunk_) { [&] {
uint32_t mask = 0; int first_word = HasbitWord(chunk, 0);
int this_word = HasbitWord(chunk, 0); while (chunk < limit_chunk_) {
// Generate mask for chunks on the same word. uint32_t mask = 0;
for (; chunk < limit_chunk_ && HasbitWord(chunk, 0) == this_word; chunk++) { int this_word = HasbitWord(chunk, 0);
for (auto field : chunks_[chunk]) { // Generate mask for chunks on the same word.
int hasbit_index = has_bit_indices_[field->index()]; for (; chunk < limit_chunk_ && HasbitWord(chunk, 0) == this_word;
// Fields on a chunk must be in the same word. chunk++) {
ABSL_CHECK_EQ(this_word, hasbit_index / 32); for (auto field : chunks_[chunk]) {
mask |= 1 << (hasbit_index % 32); int hasbit_index = has_bit_indices_[field->index()];
} // Fields on a chunk must be in the same word.
} ABSL_CHECK_EQ(this_word, hasbit_index / 32);
mask |= 1 << (hasbit_index % 32);
}
}
if (this_word != first_word) { if (this_word != first_word) {
format(" ||\n "); p->Emit(R"cc(
} ||
auto v = p->WithVars({{"mask", absl::Hex(mask, absl::kZeroPad8)}}); )cc");
if (this_word == cached_has_word_index) { }
format("(cached_has_bits & 0x$mask$u) != 0"); auto v = p->WithVars({{"mask", absl::StrFormat("0x%08xu", mask)}});
} else { if (this_word == cached_has_word_index) {
format("($1$_impl_._has_bits_[$2$] & 0x$mask$u) != 0", from, this_word); p->Emit("(cached_has_bits & $mask$) != 0");
} } else {
} p->Emit({{"from", from}, {"word", this_word}},
format(")) {\n"); "($from$_impl_._has_bits_[$word$] & $mask$) != 0");
format.Indent(); }
}
}}},
R"cc(
if (PROTOBUF_PREDICT_FALSE($cond$)) {
)cc");
p->Indent();
} }
bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* p) { bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* p) {
Formatter format(p);
if (chunk != limit_chunk_ - 1) { if (chunk != limit_chunk_ - 1) {
return false; return false;
} }
format.Outdent(); p->Outdent();
format("}\n"); p->Emit(R"cc(
}
)cc");
return true; return true;
} }
@ -509,9 +524,7 @@ absl::flat_hash_map<absl::string_view, std::string> HasbitVars(
int has_bit_index) { int has_bit_index) {
return { return {
{"has_array_index", absl::StrCat(has_bit_index / 32)}, {"has_array_index", absl::StrCat(has_bit_index / 32)},
{"has_mask", {"has_mask", absl::StrFormat("0x%08xu", 1u << (has_bit_index % 32))},
absl::StrCat(
"0x", absl::Hex(1u << (has_bit_index % 32), absl::kZeroPad8), "u")},
}; };
} }
@ -623,7 +636,6 @@ void MessageGenerator::AddGenerators(
void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) { void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) {
auto v = p->WithVars(MessageVars(descriptor_)); auto v = p->WithVars(MessageVars(descriptor_));
Formatter format(p);
// optimized_fields_ does not contain fields where // optimized_fields_ does not contain fields where
// field->real_containing_oneof() // field->real_containing_oneof()
@ -935,28 +947,28 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) {
} }
for (auto oneof : OneOfRange(descriptor_)) { for (auto oneof : OneOfRange(descriptor_)) {
Formatter::SaveState saver(&format); p->Emit({{"oneof_name", oneof->name()},
auto v = p->WithVars({ Sub{"clear_oneof_name", absl::StrCat("clear_", oneof->name())}
{"oneof_name", oneof->name()}, .AnnotatedAs(oneof),
{"camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true)}, {"OneOfName", UnderscoresToCamelCase(oneof->name(), true)}},
}); R"cc(
format( void $clear_oneof_name$();
"void ${1$clear_$oneof_name$$}$();\n" $OneOfName$Case $oneof_name$_case() const;
"$camel_oneof_name$Case $oneof_name$_case() const;\n", )cc");
oneof);
} }
} }
void MessageGenerator::GenerateSingularFieldHasBits( void MessageGenerator::GenerateSingularFieldHasBits(
const FieldDescriptor* field, io::Printer* p) { const FieldDescriptor* field, io::Printer* p) {
auto t = p->WithVars(MakeTrackerCalls(field, options_)); auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p);
if (field->options().weak()) { if (field->options().weak()) {
format( p->Emit(
"inline bool $classname$::has_$name$() const {\n" R"cc(
"$annotate_has$" inline bool $classname$::has_$name$() const {
" return $weak_field_map$.Has($number$);\n" $annotate_has$;
"}\n"); return $weak_field_map$.Has($number$);
}
)cc");
return; return;
} }
if (HasHasbit(field)) { if (HasHasbit(field)) {
@ -964,157 +976,172 @@ void MessageGenerator::GenerateSingularFieldHasBits(
ABSL_CHECK_NE(has_bit_index, kNoHasbit); ABSL_CHECK_NE(has_bit_index, kNoHasbit);
auto v = p->WithVars(HasbitVars(has_bit_index)); auto v = p->WithVars(HasbitVars(has_bit_index));
format( p->Emit(
"inline bool $classname$::has_$name$() const {\n" {Sub{"ASSUME",
"$annotate_has$" [&] {
" bool value = ($has_bits$[$has_array_index$] & $has_mask$) != 0;\n"); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!IsLazy(field, options_, scc_analyzer_)) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && // We maintain the invariant that for a submessage x, has_x()
!IsLazy(field, options_, scc_analyzer_)) { // returning true implies that x_ is not null. By giving this
// We maintain the invariant that for a submessage x, has_x() returning // information to the compiler, we allow it to eliminate
// true implies that x_ is not null. By giving this information to the // unnecessary null checks later on.
// compiler, we allow it to eliminate unnecessary null checks later on. p->Emit(
format(" PROTOBUF_ASSUME(!value || $field$ != nullptr);\n"); R"cc(PROTOBUF_ASSUME(!value || $field$ != nullptr);)cc");
} }
}}
format( .WithSuffix(";")},
" return value;\n" R"cc(
"}\n"); inline bool $classname$::has_$name$() const {
$annotate_has$;
bool value = ($has_bits$[$has_array_index$] & $has_mask$) != 0;
$ASSUME$;
return value;
}
)cc");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields have a has_$name$() method. // Message fields have a has_$name$() method.
if (IsLazy(field, options_, scc_analyzer_)) { if (IsLazy(field, options_, scc_analyzer_)) {
format( p->Emit(R"cc(
"inline bool $classname$::_internal_has_$name$() const {\n" inline bool $classname$::_internal_has_$name$() const {
" return !$field$.IsCleared();\n" return !$field$.IsCleared();
"}\n"); }
)cc");
} else { } else {
format( p->Emit(R"cc(
"inline bool $classname$::_internal_has_$name$() const {\n" inline bool $classname$::_internal_has_$name$() const {
" return this != internal_default_instance() " return this != internal_default_instance() && $field$ != nullptr;
"&& $field$ != nullptr;\n" }
"}\n"); )cc");
} }
format( p->Emit(R"cc(
"inline bool $classname$::has_$name$() const {\n" inline bool $classname$::has_$name$() const {
"$annotate_has$" $annotate_has$;
" return _internal_has_$name$();\n" return _internal_has_$name$();
"}\n"); }
)cc");
} }
} }
void MessageGenerator::GenerateOneofHasBits(io::Printer* p) { void MessageGenerator::GenerateOneofHasBits(io::Printer* p) {
Formatter format(p);
for (const auto* oneof : OneOfRange(descriptor_)) { for (const auto* oneof : OneOfRange(descriptor_)) {
auto v = p->WithVars({ p->Emit(
{"oneof_index", oneof->index()}, {
{"oneof_name", oneof->name()}, {"oneof_index", oneof->index()},
{"cap_oneof_name", absl::AsciiStrToUpper(oneof->name())}, {"oneof_name", oneof->name()},
}); {"cap_oneof_name", absl::AsciiStrToUpper(oneof->name())},
format( },
"inline bool $classname$::has_$oneof_name$() const {\n" R"cc(
" return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n" inline bool $classname$::has_$oneof_name$() const {
"}\n" return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;
"inline void $classname$::clear_has_$oneof_name$() {\n" }
" $oneof_case$[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n" inline void $classname$::clear_has_$oneof_name$() {
"}\n"); $oneof_case$[$oneof_index$] = $cap_oneof_name$_NOT_SET;
}
)cc");
} }
} }
void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field, void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
io::Printer* p) { io::Printer* p) {
auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p);
// Singular field in a oneof // Singular field in a oneof
// N.B.: Without field presence, we do not use has-bits or generate // N.B.: Without field presence, we do not use has-bits or generate
// has_$name$() methods, but oneofs still have set_has_$name$(). // has_$name$() methods, but oneofs still have set_has_$name$().
// Oneofs also have private _internal_has_$name$() a helper method. // Oneofs also have private _internal_has_$name$() a helper method.
if (field->has_presence()) { if (field->has_presence()) {
format( auto t = p->WithVars(MakeTrackerCalls(field, options_));
"inline bool $classname$::has_$name$() const {\n" p->Emit(R"cc(
"$annotate_has$" inline bool $classname$::has_$name$() const {
" return $has_field$;\n" $annotate_has$;
"}\n"); return $has_field$;
}
)cc");
} }
if (HasInternalHasMethod(field)) { if (HasInternalHasMethod(field)) {
format( p->Emit(R"cc(
"inline bool $classname$::_internal_has_$name$() const {\n" inline bool $classname$::_internal_has_$name$() const {
" return $has_field$;\n" return $has_field$;
"}\n"); }
)cc");
} }
// set_has_$name$() for oneof fields is always private; hence should not be // set_has_$name$() for oneof fields is always private; hence should not be
// annotated. // annotated.
format( p->Emit(R"cc(
"inline void $classname$::set_has_$name$() {\n" inline void $classname$::set_has_$name$() {
" $oneof_case$[$oneof_index$] = k$field_name$;\n" $oneof_case$[$oneof_index$] = k$field_name$;
"}\n"); }
)cc");
} }
void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field, void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
bool is_inline, io::Printer* p) { bool is_inline, io::Printer* p) {
auto t = p->WithVars(MakeTrackerCalls(field, options_)); auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p); p->Emit({{"inline", is_inline ? "inline" : ""},
{"body",
// Generate clear_$name$(). [&] {
if (is_inline) { if (field->real_containing_oneof()) {
format("inline "); // Clear this field only if it is the active field in this
} // oneof, otherwise ignore
format("void $classname$::clear_$name$() {\n"); p->Emit(
{{"clearing_code",
format.Indent(); [&] {
field_generators_.get(field).GenerateClearingCode(p);
if (field->real_containing_oneof()) { }}},
// Clear this field only if it is the active field in this oneof, R"cc(
// otherwise ignore if ($has_field$) {
auto t = p->WithVars(MakeTrackerCalls(field, options_)); $clearing_code$;
format("if ($has_field$) {\n"); clear_has_$oneof_name$();
format.Indent(); }
field_generators_.get(field).GenerateClearingCode(p); )cc");
format("clear_has_$oneof_name$();\n"); } else {
format.Outdent(); // TODO(b/281513105): figure out if early return breaks tracking
format("}\n"); if (ShouldSplit(field, options_)) {
} else { p->Emit(R"cc(
if (ShouldSplit(field, options_)) { if (IsSplitMessageDefault()) return;
format("if (IsSplitMessageDefault()) return;\n"); )cc");
} }
field_generators_.get(field).GenerateClearingCode(p); field_generators_.get(field).GenerateClearingCode(p);
if (HasHasbit(field)) { if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(field); int has_bit_index = HasBitIndex(field);
auto v = p->WithVars(HasbitVars(has_bit_index)); auto v = p->WithVars(HasbitVars(has_bit_index));
format("$has_bits$[$has_array_index$] &= ~$has_mask$;\n"); p->Emit(R"cc(
} $has_bits$[$has_array_index$] &= ~$has_mask$;
} )cc");
format("$annotate_clear$"); }
format.Outdent(); }
format("}\n"); }}},
R"cc(
$inline $void $classname$::clear_$name$() {
$body$;
$annotate_clear$;
}
)cc");
} }
void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) { void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) {
Formatter format(p); p->Emit("// $classname$\n\n");
format("// $classname$\n\n");
for (auto field : FieldRange(descriptor_)) { for (auto field : FieldRange(descriptor_)) {
PrintFieldComment(format, field); PrintFieldComment(Formatter{p}, field);
auto v = p->WithVars(FieldVars(field, options_)); auto v = p->WithVars(FieldVars(field, options_));
auto t = p->WithVars(MakeTrackerCalls(field, options_)); auto t = p->WithVars(MakeTrackerCalls(field, options_));
// Generate has_$name$() or $name$_size().
if (field->is_repeated()) { if (field->is_repeated()) {
format( p->Emit({{"weak", IsImplicitWeakField(field, options_, scc_analyzer_) &&
"inline int $classname$::_internal_$name$_size() const {\n" field->message_type()
" return $field$$1$.size();\n" ? ".weak"
"}\n" : ""}},
"inline int $classname$::$name$_size() const {\n" R"cc(
"$annotate_size$" inline int $classname$::_internal_$name$_size() const {
" return _internal_$name$_size();\n" return $field$$weak$.size();
"}\n", }
IsImplicitWeakField(field, options_, scc_analyzer_) && inline int $classname$::$name$_size() const {
field->message_type() $annotate_size$;
? ".weak" return _internal_$name$_size();
: ""); }
)cc");
} else if (field->real_containing_oneof()) { } else if (field->real_containing_oneof()) {
GenerateOneofMemberHasBits(field, p); GenerateOneofMemberHasBits(field, p);
} else { } else {
// Singular field.
GenerateSingularFieldHasBits(field, p); GenerateSingularFieldHasBits(field, p);
} }
@ -1124,10 +1151,9 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) {
// Generate type-specific accessors. // Generate type-specific accessors.
field_generators_.get(field).GenerateInlineAccessorDefinitions(p); field_generators_.get(field).GenerateInlineAccessorDefinitions(p);
format("\n"); p->Emit("\n");
} }
// Generate has_$name$() and clear_has_$name$() functions for oneofs.
GenerateOneofHasBits(p); GenerateOneofHasBits(p);
} }
@ -1426,7 +1452,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
"#endif // !PROTOBUF_FORCE_COPY_IN_SWAP\n" "#endif // !PROTOBUF_FORCE_COPY_IN_SWAP\n"
" InternalSwap(other);\n" " InternalSwap(other);\n"
" } else {\n" " } else {\n"
" ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);\n" " $pbi$::GenericSwap(this, other);\n"
" }\n" " }\n"
"}\n" "}\n"
"void UnsafeArenaSwap($classname$* other) {\n" "void UnsafeArenaSwap($classname$* other) {\n"
@ -1834,27 +1860,24 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* p) {
// Generate oneof_case() functions. // Generate oneof_case() functions.
for (auto oneof : OneOfRange(descriptor_)) { for (auto oneof : OneOfRange(descriptor_)) {
Formatter format(p); p->Emit(
auto v = p->WithVars({ {
{"camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true)}, Sub{"oneof_name", absl::StrCat(oneof->name(), "_case")}.AnnotatedAs(
{"oneof_name", oneof->name()}, oneof),
{"oneof_index", oneof->index()}, {"OneofName",
}); absl::StrCat(UnderscoresToCamelCase(oneof->name(), true), "Case")},
format( {"oneof_index", oneof->index()},
"inline $classname$::$camel_oneof_name$Case $classname$::" },
"${1$$oneof_name$_case$}$() const {\n" R"cc(
" return $classname$::$camel_oneof_name$Case(" inline $classname$::$OneofName$ $classname$::$oneof_name$() const {
"$oneof_case$[$oneof_index$]);\n" return $classname$::$OneofName$($oneof_case$[$oneof_index$]);
"}\n", }
oneof); )cc");
} }
} }
void MessageGenerator::GenerateSchema(io::Printer* p, int offset, void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
int has_offset) { int has_offset) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_) has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)
? offset + has_offset ? offset + has_offset
: -1; : -1;
@ -1866,8 +1889,17 @@ void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
ABSL_DCHECK(!IsMapEntryMessage(descriptor_)); ABSL_DCHECK(!IsMapEntryMessage(descriptor_));
inlined_string_indices_offset = has_offset + has_bit_indices_.size(); inlined_string_indices_offset = has_offset + has_bit_indices_.size();
} }
format("{ $1$, $2$, $3$, sizeof($classtype$)},\n", offset, has_offset,
inlined_string_indices_offset); auto v = p->WithVars(ClassVars(descriptor_, options_));
p->Emit(
{
{"offset", offset},
{"has_offset", has_offset},
{"string_offsets", inlined_string_indices_offset},
},
R"cc(
{$offset$, $has_offset$, $string_offsets$, sizeof($classtype$)},
)cc");
} }
void MessageGenerator::GenerateClassMethods(io::Printer* p) { void MessageGenerator::GenerateClassMethods(io::Printer* p) {
@ -2022,8 +2054,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
format( format(
"void $classname$::PrepareSplitMessageForWrite() {\n" "void $classname$::PrepareSplitMessageForWrite() {\n"
" if (IsSplitMessageDefault()) {\n" " if (IsSplitMessageDefault()) {\n"
" void* chunk = " " void* chunk = $pbi$::CreateSplitMessageGeneric("
"::PROTOBUF_NAMESPACE_ID::internal::CreateSplitMessageGeneric("
"GetArenaForAllocation(), &$1$, sizeof(Impl_::Split), this, &$2$);\n" "GetArenaForAllocation(), &$1$, sizeof(Impl_::Split), this, &$2$);\n"
" $split$ = reinterpret_cast<Impl_::Split*>(chunk);\n" " $split$ = reinterpret_cast<Impl_::Split*>(chunk);\n"
" }\n" " }\n"
@ -2385,9 +2416,7 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* p) {
} }
format.Outdent(); format.Outdent();
format( format("}\n\n");
"}\n"
"\n");
} }
ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const { ArenaDtorNeeds MessageGenerator::NeedsArenaDestructor() const {
@ -2852,7 +2881,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
const int kMaxUnconditionalPrimitiveBytesClear = 4; const int kMaxUnconditionalPrimitiveBytesClear = 4;
format( format(
"void $classname$::Clear() {\n" "PROTOBUF_NOINLINE void $classname$::Clear() {\n"
"// @@protoc_insertion_point(message_clear_start:$full_name$)\n"); "// @@protoc_insertion_point(message_clear_start:$full_name$)\n");
format.Indent(); format.Indent();
@ -2986,6 +3015,7 @@ void MessageGenerator::GenerateClear(io::Printer* p) {
if (have_enclosing_if) { if (have_enclosing_if) {
PrintPresenceCheck(field, has_bit_indices_, p, &cached_has_word_index); PrintPresenceCheck(field, has_bit_indices_, p, &cached_has_word_index);
format.Indent();
} }
field_generators_.get(field).GenerateMessageClearingCode(p); field_generators_.get(field).GenerateMessageClearingCode(p);
@ -3139,7 +3169,7 @@ void MessageGenerator::GenerateSwap(io::Printer* p) {
}); });
format( format(
"::PROTOBUF_NAMESPACE_ID::internal::memswap<\n" "$pbi$::memswap<\n"
" PROTOBUF_FIELD_OFFSET($classname$, $last$)\n" " PROTOBUF_FIELD_OFFSET($classname$, $last$)\n"
" + sizeof($classname$::$last$)\n" " + sizeof($classname$::$last$)\n"
" - PROTOBUF_FIELD_OFFSET($classname$, $first$)>(\n" " - PROTOBUF_FIELD_OFFSET($classname$, $first$)>(\n"
@ -3324,6 +3354,7 @@ void MessageGenerator::GenerateClassSpecificMergeImpl(io::Printer* p) {
// merged only if non-zero (numeric) or non-empty (string). // merged only if non-zero (numeric) or non-empty (string).
bool have_enclosing_if = bool have_enclosing_if =
EmitFieldNonDefaultCondition(p, "from.", field); EmitFieldNonDefaultCondition(p, "from.", field);
if (have_enclosing_if) format.Indent();
generator.GenerateMergingCode(p); generator.GenerateMergingCode(p);
if (have_enclosing_if) { if (have_enclosing_if) {
format.Outdent(); format.Outdent();
@ -3538,14 +3569,13 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* p,
field_generators_.get(field).GenerateIfHasField(p); field_generators_.get(field).GenerateIfHasField(p);
} }
format.Indent();
have_enclosing_if = true; have_enclosing_if = true;
} else if (field->is_optional() && !HasHasbit(field)) { } else if (field->is_optional() && !HasHasbit(field)) {
have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field); have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field);
} }
if (have_enclosing_if) format.Indent();
field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(p); field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(p);
if (have_enclosing_if) { if (have_enclosing_if) {
format.Outdent(); format.Outdent();
format("}\n"); format("}\n");
@ -3939,7 +3969,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) {
if (descriptor_->options().message_set_wire_format()) { if (descriptor_->options().message_set_wire_format()) {
// Special-case MessageSet. // Special-case MessageSet.
format( format(
"::size_t $classname$::ByteSizeLong() const {\n" "PROTOBUF_NOINLINE ::size_t $classname$::ByteSizeLong() const {\n"
"$annotate_bytesize$" "$annotate_bytesize$"
"// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n" "// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\n"
" ::size_t total_size = $extensions$.MessageSetByteSize();\n" " ::size_t total_size = $extensions$.MessageSetByteSize();\n"
@ -4098,6 +4128,8 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) {
have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field); have_enclosing_if = EmitFieldNonDefaultCondition(p, "this->", field);
} }
if (have_enclosing_if) format.Indent();
field_generators_.get(field).GenerateByteSize(p); field_generators_.get(field).GenerateByteSize(p);
if (have_enclosing_if) { if (have_enclosing_if) {
@ -4182,7 +4214,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* p) {
void MessageGenerator::GenerateIsInitialized(io::Printer* p) { void MessageGenerator::GenerateIsInitialized(io::Printer* p) {
if (HasSimpleBaseClass(descriptor_, options_)) return; if (HasSimpleBaseClass(descriptor_, options_)) return;
Formatter format(p); Formatter format(p);
format("bool $classname$::IsInitialized() const {\n"); format("PROTOBUF_NOINLINE bool $classname$::IsInitialized() const {\n");
format.Indent(); format.Indent();
if (descriptor_->extension_range_count() > 0) { if (descriptor_->extension_range_count() > 0) {

@ -57,10 +57,10 @@ namespace cpp {
// message Baz { message Moo {} } // message Baz { message Moo {} }
// Then the qualified namespace for Moo would be: // Then the qualified namespace for Moo would be:
// ::foo::bar // ::foo::bar
std::string Namespace(const FileDescriptor* d); PROTOC_EXPORT std::string Namespace(const FileDescriptor* d);
std::string Namespace(const Descriptor* d); PROTOC_EXPORT std::string Namespace(const Descriptor* d);
std::string Namespace(const FieldDescriptor* d); PROTOC_EXPORT std::string Namespace(const FieldDescriptor* d);
std::string Namespace(const EnumDescriptor* d); PROTOC_EXPORT std::string Namespace(const EnumDescriptor* d);
// Returns the unqualified C++ name. // Returns the unqualified C++ name.
// //
@ -69,8 +69,8 @@ std::string Namespace(const EnumDescriptor* d);
// message Baz { message Moo {} } // message Baz { message Moo {} }
// Then the non-qualified version would be: // Then the non-qualified version would be:
// Baz_Moo // Baz_Moo
std::string ClassName(const Descriptor* descriptor); PROTOC_EXPORT std::string ClassName(const Descriptor* descriptor);
std::string ClassName(const EnumDescriptor* enum_descriptor); PROTOC_EXPORT std::string ClassName(const EnumDescriptor* enum_descriptor);
// Returns the fully qualified C++ name. // Returns the fully qualified C++ name.
// //
@ -79,25 +79,26 @@ std::string ClassName(const EnumDescriptor* enum_descriptor);
// message Baz { message Moo {} } // message Baz { message Moo {} }
// Then the qualified ClassName for Moo would be: // Then the qualified ClassName for Moo would be:
// ::foo::bar::Baz_Moo // ::foo::bar::Baz_Moo
std::string QualifiedClassName(const Descriptor* d); PROTOC_EXPORT std::string QualifiedClassName(const Descriptor* d);
std::string QualifiedClassName(const EnumDescriptor* d); PROTOC_EXPORT std::string QualifiedClassName(const EnumDescriptor* d);
std::string QualifiedExtensionName(const FieldDescriptor* d); PROTOC_EXPORT std::string QualifiedExtensionName(const FieldDescriptor* d);
// Get the (unqualified) name that should be used for this field in C++ code. // Get the (unqualified) name that should be used for this field in C++ code.
// The name is coerced to lower-case to emulate proto1 behavior. People // The name is coerced to lower-case to emulate proto1 behavior. People
// should be using lowercase-with-underscores style for proto field names // should be using lowercase-with-underscores style for proto field names
// anyway, so normally this just returns field->name(). // anyway, so normally this just returns field->name().
std::string FieldName(const FieldDescriptor* field); PROTOC_EXPORT std::string FieldName(const FieldDescriptor* field);
// Requires that this field is in a oneof. Returns the (unqualified) case // Requires that this field is in a oneof. Returns the (unqualified) case
// constant for this field. // constant for this field.
std::string OneofCaseConstantName(const FieldDescriptor* field); PROTOC_EXPORT std::string OneofCaseConstantName(const FieldDescriptor* field);
// Returns the quafilied case constant for this field. // Returns the quafilied case constant for this field.
std::string QualifiedOneofCaseConstantName(const FieldDescriptor* field); PROTOC_EXPORT std::string QualifiedOneofCaseConstantName(
const FieldDescriptor* field);
// Get the (unqualified) name that should be used for this enum value in C++ // Get the (unqualified) name that should be used for this enum value in C++
// code. // code.
std::string EnumValueName(const EnumValueDescriptor* enum_value); PROTOC_EXPORT std::string EnumValueName(const EnumValueDescriptor* enum_value);
// Strips ".proto" or ".protodevel" from the end of a filename. // Strips ".proto" or ".protodevel" from the end of a filename.
PROTOC_EXPORT std::string StripProto(absl::string_view filename); PROTOC_EXPORT std::string StripProto(absl::string_view filename);

@ -31,18 +31,25 @@
#include "google/protobuf/compiler/cpp/parse_function_generator.h" #include "google/protobuf/compiler/cpp/parse_function_generator.h"
#include <algorithm> #include <algorithm>
#include <limits> #include <cstdint>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h" #include "absl/log/absl_log.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_tctable_gen.h" #include "google/protobuf/generated_message_tctable_gen.h"
#include "google/protobuf/generated_message_tctable_impl.h" #include "google/protobuf/generated_message_tctable_impl.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/wire_format.h" #include "google/protobuf/wire_format.h"
#include "google/protobuf/wire_format_lite.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
@ -257,7 +264,7 @@ void ParseFunctionGenerator::GenerateDataDecls(io::Printer* printer) {
auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_); auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format( format(
"friend class ::$proto_ns$::internal::TcParser;\n" "friend class ::$proto_ns$::internal::TcParser;\n"
"static const ::$proto_ns$::internal::" "PROTOBUF_EXPORT static const ::$proto_ns$::internal::"
"TcParseTable<$1$, $2$, $3$, $4$, $5$> _table_;\n", "TcParseTable<$1$, $2$, $3$, $4$, $5$> _table_;\n",
tc_table_info_->table_size_log2, ordered_fields_.size(), tc_table_info_->table_size_log2, ordered_fields_.size(),
tc_table_info_->aux_entries.size(), tc_table_info_->aux_entries.size(),
@ -399,8 +406,7 @@ void ParseFunctionGenerator::GenerateTailCallTable(Formatter& format) {
// unknown fields and potentially an extension range. // unknown fields and potentially an extension range.
auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_); auto field_num_to_entry_table = MakeNumToEntryTable(ordered_fields_);
format( format(
"PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1\n" "PROTOBUF_EXPORT constexpr ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> "
"const ::_pbi::TcParseTable<$1$, $2$, $3$, $4$, $5$> "
"$classname$::_table_ = " "$classname$::_table_ = "
"{\n", "{\n",
tc_table_info_->table_size_log2, ordered_fields_.size(), tc_table_info_->table_size_log2, ordered_fields_.size(),
@ -908,12 +914,17 @@ void ParseFunctionGenerator::GenerateStrings(Formatter& format,
parser_name = "StringPieceParser"; parser_name = "StringPieceParser";
break; break;
} }
format( // Repeated cord doesn't have _internal_mutable_$name$(), unlike other
"auto str = $msg$$1$$2$_$name$();\n" // repeated fields.
"ptr = ::_pbi::Inline$3$(str, ptr, ctx);\n", if (field->options().ctype() == FieldOptions::CORD &&
HasInternalAccessors(ctype) ? "_internal_" : "", field->is_repeated() && !field->is_packable()) {
field->is_repeated() && !field->is_packable() ? "add" : "mutable", format("auto str = $msg$$field$.Add();\n");
parser_name); } else {
format("auto str = $msg$$1$mutable_$name$()$2$;\n",
HasInternalAccessors(ctype) ? "_internal_" : "",
field->is_repeated() && !field->is_packable() ? "->Add()" : "");
}
format("ptr = ::_pbi::Inline$1$(str, ptr, ctx);\n", parser_name);
} }
// It is intentionally placed before VerifyUTF8 because it doesn't make sense // It is intentionally placed before VerifyUTF8 because it doesn't make sense
// to verify UTF8 when we already know parsing failed. // to verify UTF8 when we already know parsing failed.
@ -1094,8 +1105,9 @@ void ParseFunctionGenerator::GenerateFieldBody(
{{"name", FieldName(field)}, {{"name", FieldName(field)},
{"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}}); {"primitive_type", PrimitiveTypeName(options_, field->cpp_type())}});
if (field->is_repeated()) { if (field->is_repeated()) {
format.AddMap({{"put_field", absl::StrCat("add_", FieldName(field))}, const std::string add_field =
{"mutable_field", absl::StrCat("add_", FieldName(field))}}); absl::StrCat("mutable_", FieldName(field), "()->Add");
format.AddMap({{"put_field", add_field}, {"mutable_field", add_field}});
} else { } else {
format.AddMap( format.AddMap(
{{"put_field", absl::StrCat("set_", FieldName(field))}, {{"put_field", absl::StrCat("set_", FieldName(field))},

@ -8,8 +8,8 @@ load("//build_defs:cpp_opts.bzl", "COPTS")
cc_library( cc_library(
name = "names", name = "names",
hdrs = ["names.h"],
srcs = ["names.cc"], srcs = ["names.cc"],
hdrs = ["names.h"],
copts = COPTS, copts = COPTS,
include_prefix = "google/protobuf/compiler/csharp", include_prefix = "google/protobuf/compiler/csharp",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
@ -71,6 +71,7 @@ cc_library(
":names", ":names",
"//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator", "//src/google/protobuf/compiler:code_generator",
"//src/google/protobuf/compiler:retention",
"@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
], ],
@ -125,9 +126,12 @@ pkg_files(
filegroup( filegroup(
name = "test_srcs", name = "test_srcs",
srcs = glob([ srcs = glob(
"*_test.cc", [
"*unittest.cc", "*_test.cc",
], allow_empty = True), "*unittest.cc",
],
allow_empty = True,
),
visibility = ["//src/google/protobuf/compiler:__pkg__"], visibility = ["//src/google/protobuf/compiler:__pkg__"],
) )

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save