Merge branch 'protocolbuffers:main' into phpGHA

pull/10839/head
deannagarcia 2 years ago committed by GitHub
commit 5635586e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      .github/mergeable.yml
  2. 8
      .github/workflows/generate_files.yml
  3. 24
      .github/workflows/php-ext.yml
  4. 1
      BUILD.bazel
  5. 19
      CMakeLists.txt
  6. 66
      cmake/abseil-cpp.cmake
  7. 2
      cmake/conformance.cmake
  8. 7
      cmake/libprotobuf-lite.cmake
  9. 7
      cmake/libprotobuf.cmake
  10. 7
      cmake/libprotoc.cmake
  11. 41
      cmake/push_auto_update.sh
  12. 39
      cmake/tests.cmake
  13. 8
      cmake/update_file_lists.sh
  14. 2
      conformance/binary_json_conformance_suite.cc
  15. 3
      conformance/conformance_python.py
  16. 2
      conformance/conformance_test.h
  17. 22
      csharp/Google.Protobuf.Tools.targets
  18. 30
      csharp/compatibility_tests/v3.0.0/protos/csharp/protos/unittest_issues.proto
  19. 30
      csharp/compatibility_tests/v3.0.0/protos/src/google/protobuf/unittest_well_known_types.proto
  20. 32
      csharp/protos/unittest_issue6936_a.proto
  21. 32
      csharp/protos/unittest_issue6936_b.proto
  22. 32
      csharp/protos/unittest_issue6936_c.proto
  23. 30
      csharp/protos/unittest_issues.proto
  24. 10
      csharp/src/Google.Protobuf.Conformance/Conformance.cs
  25. 108
      csharp/src/Google.Protobuf.sln
  26. 456
      java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java
  27. 96
      java/core/src/test/java/com/google/protobuf/AnyTest.java
  28. 2
      objectivec/DevTools/full_mac_build.sh
  29. 4
      objectivec/GPBAny.pbobjc.h
  30. 2
      objectivec/GPBMessage.m
  31. 2
      objectivec/GPBRootObject.m
  32. 30
      objectivec/Tests/UnitTests-Bridging-Header.h
  33. 1
      objectivec/Tests/unittest_cycle.proto
  34. 1
      objectivec/Tests/unittest_deprecated.proto
  35. 1
      objectivec/Tests/unittest_deprecated_file.proto
  36. 1
      objectivec/Tests/unittest_extension_chain_a.proto
  37. 1
      objectivec/Tests/unittest_extension_chain_b.proto
  38. 1
      objectivec/Tests/unittest_extension_chain_c.proto
  39. 1
      objectivec/Tests/unittest_extension_chain_d.proto
  40. 1
      objectivec/Tests/unittest_extension_chain_e.proto
  41. 1
      objectivec/Tests/unittest_extension_chain_f.proto
  42. 1
      objectivec/Tests/unittest_extension_chain_g.proto
  43. 1
      objectivec/Tests/unittest_objc.proto
  44. 1
      objectivec/Tests/unittest_runtime_proto2.proto
  45. 1
      objectivec/Tests/unittest_runtime_proto3.proto
  46. 2
      objectivec/generate_well_known_types.sh
  47. 83
      php/BUILD.bazel
  48. 41
      php/ext/google/protobuf/generate_package_xml.sh
  49. 1468
      php/ext/google/protobuf/package.xml
  50. 3644
      php/ext/google/protobuf/php-upb.c
  51. 1640
      php/ext/google/protobuf/php-upb.h
  52. 42
      php/ext/google/protobuf/template_package.xml
  53. 64
      pkg/BUILD.bazel
  54. 5
      pkg/build_systems.bzl
  55. 100
      pkg/cc_dist_library.bzl
  56. 4
      protobuf_deps.bzl
  57. 1
      protobuf_version.bzl
  58. 46
      push_auto_update.sh
  59. 70
      python/docs/make.bat
  60. 43
      python/google/protobuf/descriptor.py
  61. 2
      python/google/protobuf/internal/descriptor_test.py
  62. 2
      python/google/protobuf/internal/field_mask_test.py
  63. 4
      python/google/protobuf/internal/generator_test.py
  64. 2
      python/google/protobuf/internal/json_format_test.py
  65. 12
      python/google/protobuf/internal/message_test.py
  66. 45
      python/google/protobuf/internal/python_message.py
  67. 2
      python/google/protobuf/internal/reflection_test.py
  68. 8
      python/google/protobuf/internal/text_format_test.py
  69. 10
      python/google/protobuf/internal/type_checkers.py
  70. 4
      python/google/protobuf/internal/unknown_fields_test.py
  71. 2
      python/google/protobuf/internal/wire_format.py
  72. 15
      python/google/protobuf/json_format.py
  73. 6
      python/google/protobuf/pyext/descriptor.cc
  74. 10
      python/google/protobuf/text_format.py
  75. 2
      ruby/ext/google/protobuf_c/message.c
  76. 2671
      ruby/ext/google/protobuf_c/ruby-upb.c
  77. 590
      ruby/ext/google/protobuf_c/ruby-upb.h
  78. 3
      ruby/internal.bzl
  79. 6
      src/file_lists.cmake
  80. 29
      src/google/protobuf/BUILD.bazel
  81. 30
      src/google/protobuf/any.pb.cc
  82. 8
      src/google/protobuf/any.pb.h
  83. 4
      src/google/protobuf/any.proto
  84. 2
      src/google/protobuf/any_lite.cc
  85. 3
      src/google/protobuf/any_test.cc
  86. 144
      src/google/protobuf/api.pb.cc
  87. 20
      src/google/protobuf/api.pb.h
  88. 32
      src/google/protobuf/arena.h
  89. 2
      src/google/protobuf/arena_unittest.cc
  90. 2
      src/google/protobuf/arenastring.cc
  91. 4
      src/google/protobuf/arenastring_unittest.cc
  92. 4
      src/google/protobuf/compiler/BUILD.bazel
  93. 6
      src/google/protobuf/compiler/annotation_test_util.cc
  94. 187
      src/google/protobuf/compiler/command_line_interface.cc
  95. 12
      src/google/protobuf/compiler/command_line_interface.h
  96. 6
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  97. 1
      src/google/protobuf/compiler/cpp/BUILD.bazel
  98. 5
      src/google/protobuf/compiler/cpp/bootstrap_unittest.cc
  99. 1
      src/google/protobuf/compiler/cpp/enum.h
  100. 2
      src/google/protobuf/compiler/cpp/enum_field.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,18 +0,0 @@
mergeable:
pull_requests:
label:
and:
- must_exclude:
regex: '^disposition/DO NOT MERGE'
message: 'Pull request marked not mergeable'
- or:
- and:
- must_include:
regex: 'release notes: yes'
message: 'Include release notes: yes'
- must_include:
regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby|kotlin)'
message: 'at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.'
- must_include:
regex: 'release notes: no'
message: 'Include release notes: no'

@ -1,12 +1,12 @@
name: Generate CMake File Lists
name: Auto-generate checked-in files
on:
push:
branches:
- main
- '[0-9]+.x'
# The 21.x branch predates support for auto-generation of the CMake file
# lists, so we make sure to exclude it.
# The 21.x branch predates support for auto-generation, so we make sure
# to exclude it.
- '!21.x'
jobs:
@ -26,4 +26,4 @@ jobs:
- name: Configure name and email address in Git
run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com"
- name: Commit and push update
run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh
run: cd ${{ github.workspace }} && ./push_auto_update.sh

@ -15,28 +15,32 @@ jobs:
- php:7.4-cli
- php:8.1-cli
steps:
- name: Install git
- name: Install python3
run: |
apt-get update -q
apt-get install -qy python3
- name: Install bazel
run: |
apt-get install -qy wget
mkdir $HOME/bin
wget -O $HOME/bin/bazel https://github.com/bazelbuild/bazel/releases/download/5.3.2/bazel-5.3.2-linux-x86_64
chmod a+x $HOME/bin/bazel
- name: Install git
run: |
apt-get install -qy --no-install-recommends git
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare source code
run: |
rm -rf "$GITHUB_WORKSPACE/php/ext/google/protobuf/third_party"
cp -r "$GITHUB_WORKSPACE/third_party" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
cp "$GITHUB_WORKSPACE/LICENSE" "$GITHUB_WORKSPACE/php/ext/google/protobuf"
- name: Create package
run: |
cd /tmp
rm -rf protobuf-*.tgz
pecl package "$GITHUB_WORKSPACE/php/ext/google/protobuf/package.xml"
cd $GITHUB_WORKSPACE
rm -rf bazel-bin/php/protobuf-*.tgz
$HOME/bin/bazel build php:release
- name: Compile extension
run: |
cd /tmp
MAKE="make -j$(nproc)" pecl install protobuf-*.tgz
MAKE="make -j$(nproc)" pecl install $GITHUB_WORKSPACE/bazel-bin/php/protobuf-*.tgz
- name: Enable extension
run: docker-php-ext-enable protobuf
- name: Inspect extension

@ -551,7 +551,6 @@ pkg_files(
"WORKSPACE",
"cmake/CMakeLists.txt",
"cmake/README.md",
"cmake/update_file_lists.sh",
"generate_descriptor_proto.sh",
"maven_install.json",
"//third_party:BUILD.bazel",

@ -61,11 +61,6 @@ else()
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
# For -fvisibility=hidden and -fvisibility-inlines-hidden
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
# The Intel compiler isn't able to deal with noinline member functions of
# template classes defined in headers. As such it spams the output with
# warning #2196: routine is both "inline" and "noinline"
@ -107,6 +102,20 @@ include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)
if (protobuf_BUILD_SHARED_LIBS)
# This is necessary for linking in Abseil.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Build Abseil as shared libraries to avoid ODR violations.
set(BUILD_SHARED_LIBS ON)
# Output directory is correct by default for most build setups. However, when
# building Protobuf as a DLL, it is important to have the DLL in the same
# directory as the executable using it. Thus, we put all binaries in a single
# /bin directory.
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif ()
endif ()
# Version metadata

@ -29,30 +29,42 @@ elseif(protobuf_ABSL_PROVIDER STREQUAL "package")
endif()
set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()")
set(protobuf_ABSL_USED_TARGETS
absl::algorithm
absl::base
absl::bind_front
absl::bits
absl::cleanup
absl::cord
absl::core_headers
absl::debugging
absl::dynamic_annotations
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::function_ref
absl::hash
absl::layout
absl::memory
absl::optional
absl::span
absl::status
absl::statusor
absl::strings
absl::synchronization
absl::time
absl::utility
absl::variant
)
if (BUILD_SHARED_LIBS AND MSVC)
# On MSVC Abseil is bundled into a single DLL.
set(protobuf_ABSL_USED_TARGETS abseil_dll)
# As a workaround for https://github.com/abseil/abseil-cpp/issues/1118,
# make sure ABSL_CONSUME_DLL gets set for all subsequent builds.
add_definitions(-DABSL_CONSUME_DLL)
else()
set(protobuf_ABSL_USED_TARGETS
absl::algorithm
absl::base
absl::bind_front
absl::bits
absl::btree
absl::cleanup
absl::cord
absl::core_headers
absl::debugging
absl::dynamic_annotations
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::function_ref
absl::hash
absl::layout
absl::memory
absl::node_hash_map
absl::node_hash_set
absl::optional
absl::span
absl::status
absl::statusor
absl::strings
absl::synchronization
absl::time
absl::utility
absl::variant
)
endif ()

@ -76,7 +76,7 @@ target_link_libraries(conformance_cpp ${protobuf_LIB_PROTOBUF})
target_link_libraries(conformance_cpp ${protobuf_ABSL_USED_TARGETS})
add_test(NAME conformance_cpp_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/conformance_test_runner
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/conformance_test_runner
--failure_list ${protobuf_SOURCE_DIR}/conformance/failure_list_cpp.txt
--text_format_failure_list ${protobuf_SOURCE_DIR}/conformance/text_format_failure_list_cpp.txt
--output_dir ${protobuf_TEST_XML_OUTDIR}

@ -32,7 +32,12 @@ endif()
set_target_properties(libprotobuf-lite PROPERTIES
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}"
# For -fvisibility=hidden and -fvisibility-inlines-hidden
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
target_include_directories(libprotobuf-lite PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)

@ -35,7 +35,12 @@ endif()
set_target_properties(libprotobuf PROPERTIES
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}"
# For -fvisibility=hidden and -fvisibility-inlines-hidden
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
add_library(protobuf::libprotobuf ALIAS libprotobuf)
target_include_directories(libprotobuf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)

@ -26,5 +26,10 @@ set_target_properties(libprotoc PROPERTIES
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
VERSION ${protobuf_VERSION}
OUTPUT_NAME ${LIB_PREFIX}protoc
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}"
# For -fvisibility=hidden and -fvisibility-inlines-hidden
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
add_library(protobuf::libprotoc ALIAS libprotoc)

@ -1,41 +0,0 @@
#!/bin/bash
# This script updates the CMake file lists (i.e. src/file_lists.cmake), commits
# the resulting change, and pushes it. This does not do anything useful when
# run manually, but should be run by our GitHub action instead.
set -ex
# Exit early if the previous commit was made by the bot. This reduces the risk
# of a bug causing an infinite loop of auto-generated commits.
if (git log -1 --pretty=format:'%an' | grep -q "Protobuf Team Bot"); then
echo "Previous commit was authored by bot"
exit 0
fi
$(dirname -- "$0")/update_file_lists.sh
# Try to determine the most recent pull request number.
title=$(git log -1 --pretty='%s')
pr_from_merge=$(echo "$title" | sed -n 's/^Merge pull request #\([0-9]\+\).*/\1/p')
pr_from_squash=$(echo "$title" | sed -n 's/^.*(#\([0-9]\+\))$/\1/p')
pr=""
if [ ! -z "$pr_from_merge" ]; then
pr="$pr_from_merge"
elif [ ! -z "$pr_from_squash" ]; then
pr="$pr_from_squash"
fi
if [ ! -z "$pr" ]; then
commit_message="Auto-generate CMake file lists after PR #$pr"
else
# If we are unable to determine the pull request number, we fall back on this
# default commit message. Typically this should not occur, but could happen
# if a pull request was merged via a rebase.
commit_message="Auto-generate CMake file lists"
fi
git add -A
git diff --staged --quiet || git commit -am "$commit_message"
git push

@ -50,6 +50,7 @@ set(tests_protos
${protobuf_test_protos_files}
${compiler_test_protos_files}
${util_test_protos_files}
${lite_test_protos}
)
macro(compile_proto_file filename)
@ -77,25 +78,14 @@ foreach(proto_file ${tests_protos})
set(tests_proto_files ${tests_proto_files} ${pb_src} ${pb_hdr})
endforeach(proto_file)
add_library(protobuf-lite-test-common STATIC
${lite_test_util_srcs} ${lite_test_proto_files})
target_include_directories(protobuf-lite-test-common PRIVATE ${ABSL_ROOT_DIR})
target_link_libraries(protobuf-lite-test-common
${protobuf_LIB_PROTOBUF_LITE} ${protobuf_ABSL_USED_TARGETS} GTest::gmock)
set(common_test_files
${test_util_hdrs}
${lite_test_util_srcs}
${test_util_srcs}
${common_test_hdrs}
${common_test_srcs}
)
add_library(protobuf-test-common STATIC
${common_test_files} ${tests_proto_files})
target_include_directories(protobuf-test-common PRIVATE ${ABSL_ROOT_DIR})
target_link_libraries(protobuf-test-common
${protobuf_LIB_PROTOBUF} ${protobuf_ABSL_USED_TARGETS} GTest::gmock)
set(tests_files
${protobuf_test_files}
${compiler_test_files}
@ -129,13 +119,22 @@ else()
set(protobuf_GTEST_ARGS)
endif()
add_executable(tests ${tests_files})
add_executable(tests
${tests_files}
${common_test_files}
${tests_proto_files}
)
if (MSVC)
target_compile_options(tests PRIVATE
/wd4146 # unary minus operator applied to unsigned type, result still unsigned
)
endif()
target_link_libraries(tests protobuf-lite-test-common protobuf-test-common ${protobuf_LIB_PROTOC} ${protobuf_LIB_PROTOBUF} GTest::gmock_main)
target_link_libraries(tests
${protobuf_LIB_PROTOC}
${protobuf_LIB_PROTOBUF}
${protobuf_ABSL_USED_TARGETS}
GTest::gmock_main
)
set(test_plugin_files
${test_plugin_files}
@ -152,8 +151,16 @@ target_link_libraries(test_plugin
GTest::gmock
)
add_executable(lite-test ${protobuf_lite_test_files})
target_link_libraries(lite-test protobuf-lite-test-common ${protobuf_LIB_PROTOBUF_LITE} GTest::gmock_main)
add_executable(lite-test
${protobuf_lite_test_files}
${lite_test_util_srcs}
${lite_test_proto_files}
)
target_link_libraries(lite-test
${protobuf_LIB_PROTOBUF_LITE}
${protobuf_ABSL_USED_TARGETS}
GTest::gmock_main
)
add_test(NAME lite-test
COMMAND lite-test ${protobuf_GTEST_ARGS})

@ -1,8 +0,0 @@
#!/bin/bash -u
# This script generates file lists from Bazel for CMake.
set -e
bazel build //pkg:gen_src_file_lists
cp -v bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake

@ -31,7 +31,6 @@
#include "binary_json_conformance_suite.h"
#include "google/protobuf/text_format.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/util/json_util.h"
#include "google/protobuf/util/type_resolver_util.h"
#include "absl/status/status.h"
@ -41,6 +40,7 @@
#include "conformance_test.h"
#include "google/protobuf/test_messages_proto2.pb.h"
#include "google/protobuf/test_messages_proto3.pb.h"
#include "google/protobuf/wire_format_lite.h"
namespace proto2_messages = protobuf_test_messages::proto2;

@ -178,9 +178,6 @@ def do_test_io():
elif len(length_bytes) != 4:
raise IOError("I/O error")
# "I" is "unsigned int", so this depends on running on a platform with
# 32-bit "unsigned int" type. The Python struct module unfortunately
# has no format specifier for uint32_t.
length = struct.unpack("<I", length_bytes)[0]
serialized_request = sys.stdin.read(length)
if len(serialized_request) != length:

@ -43,9 +43,9 @@
#include <vector>
#include "google/protobuf/descriptor.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/util/type_resolver.h"
#include "conformance/conformance.pb.h"
#include "google/protobuf/wire_format_lite.h"
namespace conformance {
class ConformanceRequest;

@ -1,11 +1,11 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<protoc_tools>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/../tools/'))</protoc_tools>
<protoc_linux64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/linux_x64/protoc'))</protoc_linux64>
<protoc_linux86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/linux_x86/protoc'))</protoc_linux86>
<protoc_macosx64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/macosx_x64/protoc'))</protoc_macosx64>
<protoc_macosx86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/macosx_x86/protoc'))</protoc_macosx86>
<protoc_windows64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/windows_x64/protoc.exe'))</protoc_windows64>
<protoc_windows86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/windows_x86/protoc.exe'))</protoc_windows86>
</PropertyGroup>
</Project>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<protoc_tools>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)/../tools/'))</protoc_tools>
<protoc_linux64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/linux_x64/protoc'))</protoc_linux64>
<protoc_linux86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/linux_x86/protoc'))</protoc_linux86>
<protoc_macosx64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/macosx_x64/protoc'))</protoc_macosx64>
<protoc_macosx86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/macosx_x86/protoc'))</protoc_macosx86>
<protoc_windows64>$([System.IO.Path]::GetFullPath('$(protoc_tools)/windows_x64/protoc.exe'))</protoc_windows64>
<protoc_windows86>$([System.IO.Path]::GetFullPath('$(protoc_tools)/windows_x86/protoc.exe'))</protoc_windows86>
</PropertyGroup>
</Project>

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
// These proto descriptors have at one time been reported as an issue or defect.

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
package protobuf_unittest;

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
package unittest_issues;
@ -12,4 +42,4 @@ import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions {
string opt = 50000;
}
}

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
import "unittest_issue6936_a.proto";
@ -11,4 +41,4 @@ option csharp_namespace = "UnitTest.Issues.TestProtos";
message Foo {
option (opt) = "foo";
}
}

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
import "unittest_issue6936_a.proto";
@ -13,4 +43,4 @@ option csharp_namespace = "UnitTest.Issues.TestProtos";
message Bar {
option (opt) = "bar";
Foo foo = 1;
}
}

@ -1,3 +1,33 @@
// 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.
syntax = "proto3";
// These proto descriptors have at one time been reported as an issue or defect.

@ -64,7 +64,7 @@ namespace Conformance {
[pbr::OriginalName("PROTOBUF")] Protobuf = 1,
[pbr::OriginalName("JSON")] Json = 2,
/// <summary>
/// Google internal only. Opensource testees just skip it.
/// Only used inside Google. Opensource testees just skip it.
/// </summary>
[pbr::OriginalName("JSPB")] Jspb = 3,
[pbr::OriginalName("TEXT_FORMAT")] TextFormat = 4,
@ -89,7 +89,7 @@ namespace Conformance {
/// </summary>
[pbr::OriginalName("JSON_IGNORE_UNKNOWN_PARSING_TEST")] JsonIgnoreUnknownParsingTest = 3,
/// <summary>
/// Test jspb wire format. Google internal only. Opensource testees just skip it.
/// Test jspb wire format. Only used inside Google. Opensource testees just skip it.
/// </summary>
[pbr::OriginalName("JSPB_TEST")] JspbTest = 4,
/// <summary>
@ -382,7 +382,7 @@ namespace Conformance {
/// <summary>Field number for the "jspb_payload" field.</summary>
public const int JspbPayloadFieldNumber = 7;
/// <summary>
/// Google internal only. Opensource testees just skip it.
/// Only used inside google. Opensource testees just skip it.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
@ -1026,8 +1026,8 @@ namespace Conformance {
public const int JspbPayloadFieldNumber = 7;
/// <summary>
/// If the input was successfully parsed and the requested output was JSPB,
/// serialize to JSPB and set it in this field. JSPB is google internal only
/// format. Opensource testees can just skip it.
/// serialize to JSPB and set it in this field. JSPB is only used inside
/// Google. Opensource testees can just skip it.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]

@ -1,54 +1,54 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AddressBook", "AddressBook\AddressBook.csproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{9B576380-726D-4142-8238-60A43AB0E35A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{9695E08F-9829-497D-B95C-B38F28D48690}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test.TestProtos", "Google.Protobuf.Test.TestProtos\Google.Protobuf.Test.TestProtos.csproj", "{ADF24BEB-A318-4530-8448-356B72B820EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.Build.0 = Release|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.Build.0 = Release|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.Build.0 = Debug|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.ActiveCfg = Release|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.Build.0 = Release|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.Build.0 = Release|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.Build.0 = Release|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B06C87B-83E1-4F5F-A0DD-6E9AFAC03DAC}
EndGlobalSection
EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26114.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AddressBook", "AddressBook\AddressBook.csproj", "{AFB63919-1E05-43B4-802A-8FB8C9B2F463}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf", "Google.Protobuf\Google.Protobuf.csproj", "{9B576380-726D-4142-8238-60A43AB0E35A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.Test", "Google.Protobuf.Test\Google.Protobuf.Test.csproj", "{580EB013-D3C7-4578-B845-015F4A3B0591}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.Conformance", "Google.Protobuf.Conformance\Google.Protobuf.Conformance.csproj", "{DDDC055B-E185-4181-BAB0-072F0F984569}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Google.Protobuf.JsonDump", "Google.Protobuf.JsonDump\Google.Protobuf.JsonDump.csproj", "{9695E08F-9829-497D-B95C-B38F28D48690}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Google.Protobuf.Test.TestProtos", "Google.Protobuf.Test.TestProtos\Google.Protobuf.Test.TestProtos.csproj", "{ADF24BEB-A318-4530-8448-356B72B820EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFB63919-1E05-43B4-802A-8FB8C9B2F463}.Release|Any CPU.Build.0 = Release|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B576380-726D-4142-8238-60A43AB0E35A}.Release|Any CPU.Build.0 = Release|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Debug|Any CPU.Build.0 = Debug|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.ActiveCfg = Release|Any CPU
{580EB013-D3C7-4578-B845-015F4A3B0591}.Release|Any CPU.Build.0 = Release|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDDC055B-E185-4181-BAB0-072F0F984569}.Release|Any CPU.Build.0 = Release|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9695E08F-9829-497D-B95C-B38F28D48690}.Release|Any CPU.Build.0 = Release|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADF24BEB-A318-4530-8448-356B72B820EA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B06C87B-83E1-4F5F-A0DD-6E9AFAC03DAC}
EndGlobalSection
EndGlobal

@ -136,8 +136,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
protected void mergeFromAndMakeImmutableInternal(
CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException {
Schema<GeneratedMessageV3> schema =
(Schema<GeneratedMessageV3>) Protobuf.getInstance().schemaFor(this);
Schema<GeneratedMessageV3> schema = Protobuf.getInstance().schemaFor(this);
try {
schema.mergeFrom(this, CodedInputStreamReader.forCodedInput(input), extensionRegistry);
} catch (InvalidProtocolBufferException e) {
@ -156,7 +155,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
* @param getBytesForString whether to generate ByteString for string fields
*/
private Map<FieldDescriptor, Object> getAllFieldsMutable(boolean getBytesForString) {
final TreeMap<FieldDescriptor, Object> result = new TreeMap<FieldDescriptor, Object>();
final TreeMap<FieldDescriptor, Object> result = new TreeMap<>();
final Descriptor descriptor = internalGetFieldAccessorTable().descriptor;
final List<FieldDescriptor> fields = descriptor.getFields();
@ -520,8 +519,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Builder class for {@link GeneratedMessageV3}. */
@SuppressWarnings("unchecked")
public abstract static class Builder<BuilderType extends Builder<BuilderType>>
extends AbstractMessage.Builder<BuilderType> {
public abstract static class Builder<BuilderT extends Builder<BuilderT>>
extends AbstractMessage.Builder<BuilderT> {
private BuilderParent builderParent;
@ -583,8 +582,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public BuilderType clone() {
BuilderType builder = (BuilderType) getDefaultInstanceForType().newBuilderForType();
public BuilderT clone() {
BuilderT builder = (BuilderT) getDefaultInstanceForType().newBuilderForType();
builder.mergeFrom(buildPartial());
return builder;
}
@ -594,10 +593,10 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
* builtin fields back to the initial values.
*/
@Override
public BuilderType clear() {
public BuilderT clear() {
unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance();
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
/**
@ -618,7 +617,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Internal helper which returns a mutable map. */
private Map<FieldDescriptor, Object> getAllFieldsMutable() {
final TreeMap<FieldDescriptor, Object> result = new TreeMap<FieldDescriptor, Object>();
final TreeMap<FieldDescriptor, Object> result = new TreeMap<>();
final Descriptor descriptor = internalGetFieldAccessorTable().descriptor;
final List<FieldDescriptor> fields = descriptor.getFields();
@ -701,21 +700,21 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public BuilderType setField(final FieldDescriptor field, final Object value) {
public BuilderT setField(final FieldDescriptor field, final Object value) {
internalGetFieldAccessorTable().getField(field).set(this, value);
return (BuilderType) this;
return (BuilderT) this;
}
@Override
public BuilderType clearField(final FieldDescriptor field) {
public BuilderT clearField(final FieldDescriptor field) {
internalGetFieldAccessorTable().getField(field).clear(this);
return (BuilderType) this;
return (BuilderT) this;
}
@Override
public BuilderType clearOneof(final OneofDescriptor oneof) {
public BuilderT clearOneof(final OneofDescriptor oneof) {
internalGetFieldAccessorTable().getOneof(oneof).clear(this);
return (BuilderType) this;
return (BuilderT) this;
}
@Override
@ -729,51 +728,51 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public BuilderType setRepeatedField(
public BuilderT setRepeatedField(
final FieldDescriptor field, final int index, final Object value) {
internalGetFieldAccessorTable().getField(field).setRepeated(this, index, value);
return (BuilderType) this;
return (BuilderT) this;
}
@Override
public BuilderType addRepeatedField(final FieldDescriptor field, final Object value) {
public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) {
internalGetFieldAccessorTable().getField(field).addRepeated(this, value);
return (BuilderType) this;
return (BuilderT) this;
}
private BuilderType setUnknownFieldsInternal(final UnknownFieldSet unknownFields) {
private BuilderT setUnknownFieldsInternal(final UnknownFieldSet unknownFields) {
unknownFieldsOrBuilder = unknownFields;
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
@Override
public BuilderType setUnknownFields(final UnknownFieldSet unknownFields) {
public BuilderT setUnknownFields(final UnknownFieldSet unknownFields) {
return setUnknownFieldsInternal(unknownFields);
}
/**
* This method is obsolete, but we must retain it for compatibility with older generated code.
*/
protected BuilderType setUnknownFieldsProto3(final UnknownFieldSet unknownFields) {
protected BuilderT setUnknownFieldsProto3(final UnknownFieldSet unknownFields) {
return setUnknownFieldsInternal(unknownFields);
}
@Override
public BuilderType mergeUnknownFields(final UnknownFieldSet unknownFields) {
public BuilderT mergeUnknownFields(final UnknownFieldSet unknownFields) {
if (UnknownFieldSet.getDefaultInstance().equals(unknownFields)) {
return (BuilderType) this;
return (BuilderT) this;
}
if (UnknownFieldSet.getDefaultInstance().equals(unknownFieldsOrBuilder)) {
unknownFieldsOrBuilder = unknownFields;
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
getUnknownFieldSetBuilder().mergeFrom(unknownFields);
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
@Override
@ -919,49 +918,49 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
// Extensions-related stuff
/** Extends {@link MessageOrBuilder} with extension-related functions. */
public interface ExtendableMessageOrBuilder<MessageType extends ExtendableMessage>
public interface ExtendableMessageOrBuilder<MessageT extends ExtendableMessage>
extends MessageOrBuilder {
// Re-define for return type covariance.
@Override
Message getDefaultInstanceForType();
/** Check if a singular extension is present. */
<Type> boolean hasExtension(ExtensionLite<MessageType, Type> extension);
<T> boolean hasExtension(ExtensionLite<MessageT, T> extension);
/** Get the number of elements in a repeated extension. */
<Type> int getExtensionCount(ExtensionLite<MessageType, List<Type>> extension);
<T> int getExtensionCount(ExtensionLite<MessageT, List<T>> extension);
/** Get the value of an extension. */
<Type> Type getExtension(ExtensionLite<MessageType, Type> extension);
<T> T getExtension(ExtensionLite<MessageT, T> extension);
/** Get one element of a repeated extension. */
<Type> Type getExtension(ExtensionLite<MessageType, List<Type>> extension, int index);
<T> T getExtension(ExtensionLite<MessageT, List<T>> extension, int index);
/** Check if a singular extension is present. */
<Type> boolean hasExtension(
Extension<MessageType, Type> extension);
<T> boolean hasExtension(
Extension<MessageT, T> extension);
/** Check if a singular extension is present. */
<Type> boolean hasExtension(
GeneratedExtension<MessageType, Type> extension);
<T> boolean hasExtension(
GeneratedExtension<MessageT, T> extension);
/** Get the number of elements in a repeated extension. */
<Type> int getExtensionCount(
Extension<MessageType, List<Type>> extension);
<T> int getExtensionCount(
Extension<MessageT, List<T>> extension);
/** Get the number of elements in a repeated extension. */
<Type> int getExtensionCount(
GeneratedExtension<MessageType, List<Type>> extension);
<T> int getExtensionCount(
GeneratedExtension<MessageT, List<T>> extension);
/** Get the value of an extension. */
<Type> Type getExtension(
Extension<MessageType, Type> extension);
<T> T getExtension(
Extension<MessageT, T> extension);
/** Get the value of an extension. */
<Type> Type getExtension(
GeneratedExtension<MessageType, Type> extension);
<T> T getExtension(
GeneratedExtension<MessageT, T> extension);
/** Get one element of a repeated extension. */
<Type> Type getExtension(
Extension<MessageType, List<Type>> extension,
<T> T getExtension(
Extension<MessageT, List<T>> extension,
int index);
/** Get one element of a repeated extension. */
<Type> Type getExtension(
GeneratedExtension<MessageType, List<Type>> extension,
<T> T getExtension(
GeneratedExtension<MessageT, List<T>> extension,
int index);
}
@ -997,8 +996,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
*
* <p>See also {@link ExtendableBuilder}.
*/
public abstract static class ExtendableMessage<MessageType extends ExtendableMessage>
extends GeneratedMessageV3 implements ExtendableMessageOrBuilder<MessageType> {
public abstract static class ExtendableMessage<MessageT extends ExtendableMessage>
extends GeneratedMessageV3 implements ExtendableMessageOrBuilder<MessageT> {
private static final long serialVersionUID = 1L;
@ -1008,12 +1007,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
this.extensions = FieldSet.newFieldSet();
}
protected ExtendableMessage(ExtendableBuilder<MessageType, ?> builder) {
protected ExtendableMessage(ExtendableBuilder<MessageT, ?> builder) {
super(builder);
this.extensions = builder.buildExtensions();
}
private void verifyExtensionContainingType(final Extension<MessageType, ?> extension) {
private void verifyExtensionContainingType(final Extension<MessageT, ?> extension) {
if (extension.getDescriptor().getContainingType() != getDescriptorForType()) {
// This can only happen if someone uses unchecked operations.
throw new IllegalArgumentException(
@ -1028,8 +1027,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Check if a singular extension is present. */
@Override
@SuppressWarnings("unchecked")
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
public final <T> boolean hasExtension(final ExtensionLite<MessageT, T> extensionLite) {
Extension<MessageT, T> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
return extensions.hasField(extension.getDescriptor());
@ -1038,9 +1037,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Get the number of elements in a repeated extension. */
@Override
@SuppressWarnings("unchecked")
public final <Type> int getExtensionCount(
final ExtensionLite<MessageType, List<Type>> extensionLite) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> int getExtensionCount(final ExtensionLite<MessageT, List<T>> extensionLite) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
final FieldDescriptor descriptor = extension.getDescriptor();
@ -1050,83 +1048,83 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Get the value of an extension. */
@Override
@SuppressWarnings("unchecked")
public final <Type> Type getExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
public final <T> T getExtension(final ExtensionLite<MessageT, T> extensionLite) {
Extension<MessageT, T> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor();
final Object value = extensions.getField(descriptor);
if (value == null) {
if (descriptor.isRepeated()) {
return (Type) Collections.emptyList();
return (T) Collections.emptyList();
} else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
return (Type) extension.getMessageDefaultInstance();
return (T) extension.getMessageDefaultInstance();
} else {
return (Type) extension.fromReflectionType(descriptor.getDefaultValue());
return (T) extension.fromReflectionType(descriptor.getDefaultValue());
}
} else {
return (Type) extension.fromReflectionType(value);
return (T) extension.fromReflectionType(value);
}
}
/** Get one element of a repeated extension. */
@Override
@SuppressWarnings("unchecked")
public final <Type> Type getExtension(
final ExtensionLite<MessageType, List<Type>> extensionLite, final int index) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> T getExtension(
final ExtensionLite<MessageT, List<T>> extensionLite, final int index) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor();
return (Type)
return (T)
extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index));
}
/** Check if a singular extension is present. */
@Override
public final <Type> boolean hasExtension(final Extension<MessageType, Type> extension) {
return hasExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> boolean hasExtension(final Extension<MessageT, T> extension) {
return hasExtension((ExtensionLite<MessageT, T>) extension);
}
/** Check if a singular extension is present. */
@Override
public final <Type> boolean hasExtension(
final GeneratedExtension<MessageType, Type> extension) {
return hasExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> boolean hasExtension(
final GeneratedExtension<MessageT, T> extension) {
return hasExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get the number of elements in a repeated extension. */
@Override
public final <Type> int getExtensionCount(
final Extension<MessageType, List<Type>> extension) {
return getExtensionCount((ExtensionLite<MessageType, List<Type>>) extension);
public final <T> int getExtensionCount(
final Extension<MessageT, List<T>> extension) {
return getExtensionCount((ExtensionLite<MessageT, List<T>>) extension);
}
/** Get the number of elements in a repeated extension. */
@Override
public final <Type> int getExtensionCount(
final GeneratedExtension<MessageType, List<Type>> extension) {
return getExtensionCount((ExtensionLite<MessageType, List<Type>>) extension);
public final <T> int getExtensionCount(
final GeneratedExtension<MessageT, List<T>> extension) {
return getExtensionCount((ExtensionLite<MessageT, List<T>>) extension);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(final Extension<MessageType, Type> extension) {
return getExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> T getExtension(final Extension<MessageT, T> extension) {
return getExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(
final GeneratedExtension<MessageType, Type> extension) {
return getExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> T getExtension(
final GeneratedExtension<MessageT, T> extension) {
return getExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get one element of a repeated extension. */
@Override
public final <Type> Type getExtension(
final Extension<MessageType, List<Type>> extension, final int index) {
return getExtension((ExtensionLite<MessageType, List<Type>>) extension, index);
public final <T> T getExtension(
final Extension<MessageT, List<T>> extension, final int index) {
return getExtension((ExtensionLite<MessageT, List<T>>) extension, index);
}
/** Get one element of a repeated extension. */
@Override
public final <Type> Type getExtension(
final GeneratedExtension<MessageType, List<Type>> extension, final int index) {
return getExtension((ExtensionLite<MessageType, List<Type>>) extension, index);
public final <T> T getExtension(
final GeneratedExtension<MessageT, List<T>> extension, final int index) {
return getExtension((ExtensionLite<MessageT, List<T>>) extension, index);
}
/** Called by subclasses to check if all extensions are initialized. */
@ -1363,9 +1361,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
*/
@SuppressWarnings("unchecked")
public abstract static class ExtendableBuilder<
MessageType extends ExtendableMessage,
BuilderType extends ExtendableBuilder<MessageType, BuilderType>>
extends Builder<BuilderType> implements ExtendableMessageOrBuilder<MessageType> {
MessageT extends ExtendableMessage,
BuilderT extends ExtendableBuilder<MessageT, BuilderT>>
extends Builder<BuilderT> implements ExtendableMessageOrBuilder<MessageT> {
private FieldSet.Builder<FieldDescriptor> extensions;
@ -1381,7 +1379,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public BuilderType clear() {
public BuilderT clear() {
extensions = null;
return super.clear();
}
@ -1392,7 +1390,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
}
private void verifyExtensionContainingType(final Extension<MessageType, ?> extension) {
private void verifyExtensionContainingType(final Extension<MessageT, ?> extension) {
if (extension.getDescriptor().getContainingType() != getDescriptorForType()) {
// This can only happen if someone uses unchecked operations.
throw new IllegalArgumentException(
@ -1406,18 +1404,17 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Check if a singular extension is present. */
@Override
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
public final <T> boolean hasExtension(final ExtensionLite<MessageT, T> extensionLite) {
Extension<MessageT, T> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
return extensions == null ? false : extensions.hasField(extension.getDescriptor());
return extensions != null && extensions.hasField(extension.getDescriptor());
}
/** Get the number of elements in a repeated extension. */
@Override
public final <Type> int getExtensionCount(
final ExtensionLite<MessageType, List<Type>> extensionLite) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> int getExtensionCount(final ExtensionLite<MessageT, List<T>> extensionLite) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
final FieldDescriptor descriptor = extension.getDescriptor();
@ -1426,184 +1423,182 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(final ExtensionLite<MessageType, Type> extensionLite) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
public final <T> T getExtension(final ExtensionLite<MessageT, T> extensionLite) {
Extension<MessageT, T> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor();
final Object value = extensions == null ? null : extensions.getField(descriptor);
if (value == null) {
if (descriptor.isRepeated()) {
return (Type) Collections.emptyList();
return (T) Collections.emptyList();
} else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
return (Type) extension.getMessageDefaultInstance();
return (T) extension.getMessageDefaultInstance();
} else {
return (Type) extension.fromReflectionType(descriptor.getDefaultValue());
return (T) extension.fromReflectionType(descriptor.getDefaultValue());
}
} else {
return (Type) extension.fromReflectionType(value);
return (T) extension.fromReflectionType(value);
}
}
/** Get one element of a repeated extension. */
@Override
public final <Type> Type getExtension(
final ExtensionLite<MessageType, List<Type>> extensionLite, final int index) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> T getExtension(
final ExtensionLite<MessageT, List<T>> extensionLite, final int index) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor();
if (extensions == null) {
throw new IndexOutOfBoundsException();
}
return (Type)
return (T)
extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index));
}
/** Set the value of an extension. */
public final <Type> BuilderType setExtension(
final ExtensionLite<MessageType, Type> extensionLite, final Type value) {
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
public final <T> BuilderT setExtension(
final ExtensionLite<MessageT, T> extensionLite, final T value) {
Extension<MessageT, T> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
ensureExtensionsIsMutable();
final FieldDescriptor descriptor = extension.getDescriptor();
extensions.setField(descriptor, extension.toReflectionType(value));
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
/** Set the value of one element of a repeated extension. */
public final <Type> BuilderType setExtension(
final ExtensionLite<MessageType, List<Type>> extensionLite,
final int index,
final Type value) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> BuilderT setExtension(
final ExtensionLite<MessageT, List<T>> extensionLite, final int index, final T value) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
ensureExtensionsIsMutable();
final FieldDescriptor descriptor = extension.getDescriptor();
extensions.setRepeatedField(descriptor, index, extension.singularToReflectionType(value));
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
/** Append a value to a repeated extension. */
public final <Type> BuilderType addExtension(
final ExtensionLite<MessageType, List<Type>> extensionLite, final Type value) {
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
public final <T> BuilderT addExtension(
final ExtensionLite<MessageT, List<T>> extensionLite, final T value) {
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
ensureExtensionsIsMutable();
final FieldDescriptor descriptor = extension.getDescriptor();
extensions.addRepeatedField(descriptor, extension.singularToReflectionType(value));
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
/** Clear an extension. */
public final BuilderType clearExtension(final ExtensionLite<MessageType, ?> extensionLite) {
Extension<MessageType, ?> extension = checkNotLite(extensionLite);
public final BuilderT clearExtension(final ExtensionLite<MessageT, ?> extensionLite) {
Extension<MessageT, ?> extension = checkNotLite(extensionLite);
verifyExtensionContainingType(extension);
ensureExtensionsIsMutable();
extensions.clearField(extension.getDescriptor());
onChanged();
return (BuilderType) this;
return (BuilderT) this;
}
/** Check if a singular extension is present. */
@Override
public final <Type> boolean hasExtension(final Extension<MessageType, Type> extension) {
return hasExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> boolean hasExtension(final Extension<MessageT, T> extension) {
return hasExtension((ExtensionLite<MessageT, T>) extension);
}
/** Check if a singular extension is present. */
@Override
public final <Type> boolean hasExtension(
final GeneratedExtension<MessageType, Type> extension) {
return hasExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> boolean hasExtension(
final GeneratedExtension<MessageT, T> extension) {
return hasExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get the number of elements in a repeated extension. */
@Override
public final <Type> int getExtensionCount(
final Extension<MessageType, List<Type>> extension) {
return getExtensionCount((ExtensionLite<MessageType, List<Type>>) extension);
public final <T> int getExtensionCount(
final Extension<MessageT, List<T>> extension) {
return getExtensionCount((ExtensionLite<MessageT, List<T>>) extension);
}
/** Get the number of elements in a repeated extension. */
@Override
public final <Type> int getExtensionCount(
final GeneratedExtension<MessageType, List<Type>> extension) {
return getExtensionCount((ExtensionLite<MessageType, List<Type>>) extension);
public final <T> int getExtensionCount(
final GeneratedExtension<MessageT, List<T>> extension) {
return getExtensionCount((ExtensionLite<MessageT, List<T>>) extension);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(final Extension<MessageType, Type> extension) {
return getExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> T getExtension(final Extension<MessageT, T> extension) {
return getExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(
final GeneratedExtension<MessageType, Type> extension) {
return getExtension((ExtensionLite<MessageType, Type>) extension);
public final <T> T getExtension(
final GeneratedExtension<MessageT, T> extension) {
return getExtension((ExtensionLite<MessageT, T>) extension);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(
final Extension<MessageType, List<Type>> extension, final int index) {
return getExtension((ExtensionLite<MessageType, List<Type>>) extension, index);
public final <T> T getExtension(
final Extension<MessageT, List<T>> extension, final int index) {
return getExtension((ExtensionLite<MessageT, List<T>>) extension, index);
}
/** Get the value of an extension. */
@Override
public final <Type> Type getExtension(
final GeneratedExtension<MessageType, List<Type>> extension, final int index) {
return getExtension((ExtensionLite<MessageType, List<Type>>) extension, index);
public final <T> T getExtension(
final GeneratedExtension<MessageT, List<T>> extension, final int index) {
return getExtension((ExtensionLite<MessageT, List<T>>) extension, index);
}
/** Set the value of an extension. */
public final <Type> BuilderType setExtension(
final Extension<MessageType, Type> extension, final Type value) {
return setExtension((ExtensionLite<MessageType, Type>) extension, value);
public final <T> BuilderT setExtension(
final Extension<MessageT, T> extension, final T value) {
return setExtension((ExtensionLite<MessageT, T>) extension, value);
}
/** Set the value of an extension. */
public <Type> BuilderType setExtension(
final GeneratedExtension<MessageType, Type> extension, final Type value) {
return setExtension((ExtensionLite<MessageType, Type>) extension, value);
public <T> BuilderT setExtension(
final GeneratedExtension<MessageT, T> extension, final T value) {
return setExtension((ExtensionLite<MessageT, T>) extension, value);
}
/** Set the value of one element of a repeated extension. */
public final <Type> BuilderType setExtension(
final Extension<MessageType, List<Type>> extension,
final int index, final Type value) {
return setExtension((ExtensionLite<MessageType, List<Type>>) extension, index, value);
public final <T> BuilderT setExtension(
final Extension<MessageT, List<T>> extension,
final int index, final T value) {
return setExtension((ExtensionLite<MessageT, List<T>>) extension, index, value);
}
/** Set the value of one element of a repeated extension. */
public <Type> BuilderType setExtension(
final GeneratedExtension<MessageType, List<Type>> extension,
final int index, final Type value) {
return setExtension((ExtensionLite<MessageType, List<Type>>) extension, index, value);
public <T> BuilderT setExtension(
final GeneratedExtension<MessageT, List<T>> extension,
final int index, final T value) {
return setExtension((ExtensionLite<MessageT, List<T>>) extension, index, value);
}
/** Append a value to a repeated extension. */
public final <Type> BuilderType addExtension(
final Extension<MessageType, List<Type>> extension, final Type value) {
return addExtension((ExtensionLite<MessageType, List<Type>>) extension, value);
public final <T> BuilderT addExtension(
final Extension<MessageT, List<T>> extension, final T value) {
return addExtension((ExtensionLite<MessageT, List<T>>) extension, value);
}
/** Append a value to a repeated extension. */
public <Type> BuilderType addExtension(
final GeneratedExtension<MessageType, List<Type>> extension, final Type value) {
return addExtension((ExtensionLite<MessageType, List<Type>>) extension, value);
public <T> BuilderT addExtension(
final GeneratedExtension<MessageT, List<T>> extension, final T value) {
return addExtension((ExtensionLite<MessageT, List<T>>) extension, value);
}
/** Clear an extension. */
public final <Type> BuilderType clearExtension(
final Extension<MessageType, ?> extension) {
return clearExtension((ExtensionLite<MessageType, ?>) extension);
public final <T> BuilderT clearExtension(
final Extension<MessageT, ?> extension) {
return clearExtension((ExtensionLite<MessageT, ?>) extension);
}
/** Clear an extension. */
public <Type> BuilderType clearExtension(
final GeneratedExtension<MessageType, ?> extension) {
return clearExtension((ExtensionLite<MessageType, ?>) extension);
public <T> BuilderT clearExtension(
final GeneratedExtension<MessageT, ?> extension) {
return clearExtension((ExtensionLite<MessageT, ?>) extension);
}
/** Called by subclasses to check if all extensions are initialized. */
protected boolean extensionsAreInitialized() {
return extensions == null ? true : extensions.isInitialized();
return extensions == null || extensions.isInitialized();
}
/**
@ -1739,60 +1734,60 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
public boolean hasField(final FieldDescriptor field) {
if (field.isExtension()) {
verifyContainingType(field);
return extensions == null ? false : extensions.hasField(field);
return extensions != null && extensions.hasField(field);
} else {
return super.hasField(field);
}
}
@Override
public BuilderType setField(final FieldDescriptor field, final Object value) {
public BuilderT setField(final FieldDescriptor field, final Object value) {
if (field.isExtension()) {
verifyContainingType(field);
ensureExtensionsIsMutable();
extensions.setField(field, value);
onChanged();
return (BuilderType) this;
return (BuilderT) this;
} else {
return super.setField(field, value);
}
}
@Override
public BuilderType clearField(final FieldDescriptor field) {
public BuilderT clearField(final FieldDescriptor field) {
if (field.isExtension()) {
verifyContainingType(field);
ensureExtensionsIsMutable();
extensions.clearField(field);
onChanged();
return (BuilderType) this;
return (BuilderT) this;
} else {
return super.clearField(field);
}
}
@Override
public BuilderType setRepeatedField(
public BuilderT setRepeatedField(
final FieldDescriptor field, final int index, final Object value) {
if (field.isExtension()) {
verifyContainingType(field);
ensureExtensionsIsMutable();
extensions.setRepeatedField(field, index, value);
onChanged();
return (BuilderType) this;
return (BuilderT) this;
} else {
return super.setRepeatedField(field, index, value);
}
}
@Override
public BuilderType addRepeatedField(final FieldDescriptor field, final Object value) {
public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) {
if (field.isExtension()) {
verifyContainingType(field);
ensureExtensionsIsMutable();
extensions.addRepeatedField(field, value);
onChanged();
return (BuilderType) this;
return (BuilderT) this;
} else {
return super.addRepeatedField(field, value);
}
@ -1963,8 +1958,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
if (field.isRepeated()) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
if (field.isMapField()) {
fields[i] =
new MapFieldAccessor(field, camelCaseNames[i], messageClass, builderClass);
fields[i] = new MapFieldAccessor(field, messageClass);
} else {
fields[i] =
new RepeatedMessageFieldAccessor(
@ -2092,9 +2086,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
Message.Builder newBuilder();
Message.Builder getBuilder(GeneratedMessageV3.Builder builder);
Message.Builder getBuilder(GeneratedMessageV3.Builder<?> builder);
Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder builder, int index);
Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder<?> builder, int index);
}
/** OneofAccessor provides access to a single oneof. */
@ -2129,22 +2123,16 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
if (fieldDescriptor != null) {
return message.hasField(fieldDescriptor);
} else {
if (((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() == 0) {
return false;
}
return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() != 0;
}
return true;
}
public boolean has(GeneratedMessageV3.Builder builder) {
if (fieldDescriptor != null) {
return builder.hasField(fieldDescriptor);
} else {
if (((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() == 0) {
return false;
}
return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() != 0;
}
return true;
}
public FieldDescriptor get(final GeneratedMessageV3 message) {
@ -2421,12 +2409,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public Message.Builder getBuilder(GeneratedMessageV3.Builder builder) {
public Message.Builder getBuilder(GeneratedMessageV3.Builder<?> builder) {
throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type.");
}
@Override
public Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder builder, int index) {
public Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder<?> builder, int index) {
throw new UnsupportedOperationException(
"getRepeatedFieldBuilder() called on a non-Message type.");
}
@ -2434,9 +2422,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
private static class RepeatedFieldAccessor implements FieldAccessor {
interface MethodInvoker {
public Object get(final GeneratedMessageV3 message);
Object get(final GeneratedMessageV3 message);
public Object get(GeneratedMessageV3.Builder<?> builder);
Object get(GeneratedMessageV3.Builder<?> builder);
Object getRepeated(final GeneratedMessageV3 message, final int index);
@ -2455,15 +2443,15 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
private static final class ReflectionInvoker implements MethodInvoker {
protected final Method getMethod;
protected final Method getMethodBuilder;
protected final Method getRepeatedMethod;
protected final Method getRepeatedMethodBuilder;
protected final Method setRepeatedMethod;
protected final Method addRepeatedMethod;
protected final Method getCountMethod;
protected final Method getCountMethodBuilder;
protected final Method clearMethod;
private final Method getMethod;
private final Method getMethodBuilder;
private final Method getRepeatedMethod;
private final Method getRepeatedMethodBuilder;
private final Method setRepeatedMethod;
private final Method addRepeatedMethod;
private final Method getCountMethod;
private final Method getCountMethodBuilder;
private final Method clearMethod;
ReflectionInvoker(
final FieldDescriptor descriptor,
@ -2646,12 +2634,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public Message.Builder getBuilder(GeneratedMessageV3.Builder builder) {
public Message.Builder getBuilder(GeneratedMessageV3.Builder<?> builder) {
throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type.");
}
@Override
public Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder builder, int index) {
public Message.Builder getRepeatedBuilder(GeneratedMessageV3.Builder<?> builder, int index) {
throw new UnsupportedOperationException(
"getRepeatedFieldBuilder() called on a non-Message type.");
}
@ -2659,13 +2647,10 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
private static class MapFieldAccessor implements FieldAccessor {
MapFieldAccessor(
final FieldDescriptor descriptor,
final String camelCaseName,
final Class<? extends GeneratedMessageV3> messageClass,
final Class<? extends Builder> builderClass) {
final FieldDescriptor descriptor, final Class<? extends GeneratedMessageV3> messageClass) {
field = descriptor;
Method getDefaultInstanceMethod = getMethodOrDie(messageClass, "getDefaultInstance");
MapField defaultMapField =
MapField<?, ?> defaultMapField =
getMapField((GeneratedMessageV3) invokeOrDie(getDefaultInstanceMethod, null));
mapEntryMessageDefaultInstance = defaultMapField.getMapEntryMessageDefaultInstance();
}
@ -2793,17 +2778,17 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public com.google.protobuf.Message.Builder newBuilder() {
public Message.Builder newBuilder() {
return mapEntryMessageDefaultInstance.newBuilderForType();
}
@Override
public com.google.protobuf.Message.Builder getBuilder(Builder builder) {
public Message.Builder getBuilder(Builder<?> builder) {
throw new UnsupportedOperationException("Nested builder not supported for map fields.");
}
@Override
public com.google.protobuf.Message.Builder getRepeatedBuilder(Builder builder, int index) {
public Message.Builder getRepeatedBuilder(Builder<?> builder, int index) {
throw new UnsupportedOperationException("Map fields cannot be repeated");
}
}
@ -2832,12 +2817,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
}
private EnumDescriptor enumDescriptor;
private final EnumDescriptor enumDescriptor;
private Method valueOfMethod;
private Method getValueDescriptorMethod;
private final Method valueOfMethod;
private final Method getValueDescriptorMethod;
private boolean supportUnknownEnumValue;
private final boolean supportUnknownEnumValue;
private Method getValueMethod;
private Method getValueMethodBuilder;
private Method setValueMethod;
@ -2898,21 +2883,21 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
}
private EnumDescriptor enumDescriptor;
private final EnumDescriptor enumDescriptor;
private final Method valueOfMethod;
private final Method getValueDescriptorMethod;
private boolean supportUnknownEnumValue;
private final boolean supportUnknownEnumValue;
private Method getRepeatedValueMethod;
private Method getRepeatedValueMethodBuilder;
private Method setRepeatedValueMethod;
private Method addRepeatedValueMethod;
@Override
@SuppressWarnings("unchecked")
public Object get(final GeneratedMessageV3 message) {
final List newList = new ArrayList<>();
final List<Object> newList = new ArrayList<>();
final int size = getRepeatedCount(message);
for (int i = 0; i < size; i++) {
newList.add(getRepeated(message, i));
@ -2921,9 +2906,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
@SuppressWarnings("unchecked")
public Object get(final GeneratedMessageV3.Builder builder) {
final List newList = new ArrayList<>();
final List<Object> newList = new ArrayList<>();
final int size = getRepeatedCount(builder);
for (int i = 0; i < size; i++) {
newList.add(getRepeated(builder, i));
@ -3071,7 +3055,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
}
@Override
public Message.Builder getBuilder(GeneratedMessageV3.Builder builder) {
public Message.Builder getBuilder(GeneratedMessageV3.Builder<?> builder) {
return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder);
}
}
@ -3123,7 +3107,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
@Override
public Message.Builder getRepeatedBuilder(
final GeneratedMessageV3.Builder builder, final int index) {
final GeneratedMessageV3.Builder<?> builder, final int index) {
return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder, index);
}
}
@ -3143,13 +3127,13 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
/**
* Checks that the {@link Extension} is non-Lite and returns it as a {@link GeneratedExtension}.
*/
private static <MessageType extends ExtendableMessage<MessageType>, T>
Extension<MessageType, T> checkNotLite(ExtensionLite<MessageType, T> extension) {
private static <MessageT extends ExtendableMessage<MessageT>, T>
Extension<MessageT, T> checkNotLite(ExtensionLite<MessageT, T> extension) {
if (extension.isLite()) {
throw new IllegalArgumentException("Expected non-lite extension.");
}
return (Extension<MessageType, T>) extension;
return (Extension<MessageT, T>) extension;
}
protected static boolean isStringEmpty(final Object value) {

@ -43,7 +43,6 @@ import org.junit.runners.JUnit4;
/** Unit tests for Any message. */
@RunWith(JUnit4.class)
public class AnyTest {
@Test
public void testAnyGeneratedApi() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
@ -78,6 +77,40 @@ public class AnyTest {
}
}
@Test
public void testAnyGeneratedExemplarApi() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TestUtil.setAllFields(builder);
TestAllTypes message = builder.build();
TestAny container = TestAny.newBuilder().setValue(Any.pack(message)).build();
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
TestAllTypes result = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
TestUtil.assertAllFieldsSet(result);
// Unpacking to a wrong exemplar will throw an exception.
try {
container.getValue().unpackSameTypeAs(TestAny.getDefaultInstance());
assertWithMessage("Exception is expected.").fail();
} catch (InvalidProtocolBufferException e) {
// expected.
}
// Test that unpacking throws an exception if parsing fails.
TestAny.Builder containerBuilder = container.toBuilder();
containerBuilder.getValueBuilder().setValue(ByteString.copyFrom(new byte[] {0x11}));
container = containerBuilder.build();
try {
container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
assertWithMessage("Exception is expected.").fail();
} catch (InvalidProtocolBufferException e) {
// expected.
}
}
@Test
public void testCustomTypeUrls() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
@ -90,7 +123,9 @@ public class AnyTest {
.isEqualTo("xxx.com/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().is(TestAllTypes.class)).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().is(TestAny.class)).isFalse();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
TestAllTypes result = container.getValue().unpack(TestAllTypes.class);
TestUtil.assertAllFieldsSet(result);
@ -101,7 +136,9 @@ public class AnyTest {
.isEqualTo("yyy.com/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().is(TestAllTypes.class)).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().is(TestAny.class)).isFalse();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
result = container.getValue().unpack(TestAllTypes.class);
TestUtil.assertAllFieldsSet(result);
@ -112,12 +149,54 @@ public class AnyTest {
.isEqualTo("/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().is(TestAllTypes.class)).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().is(TestAny.class)).isFalse();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
result = container.getValue().unpack(TestAllTypes.class);
TestUtil.assertAllFieldsSet(result);
}
@Test
public void testCustomTypeUrlsWithExemplars() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TestUtil.setAllFields(builder);
TestAllTypes message = builder.build();
TestAny container = TestAny.newBuilder().setValue(Any.pack(message, "xxx.com")).build();
assertThat(container.getValue().getTypeUrl())
.isEqualTo("xxx.com/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
TestAllTypes result = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
TestUtil.assertAllFieldsSet(result);
container = TestAny.newBuilder().setValue(Any.pack(message, "yyy.com/")).build();
assertThat(container.getValue().getTypeUrl())
.isEqualTo("yyy.com/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
result = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
TestUtil.assertAllFieldsSet(result);
container = TestAny.newBuilder().setValue(Any.pack(message, "")).build();
assertThat(container.getValue().getTypeUrl())
.isEqualTo("/" + TestAllTypes.getDescriptor().getFullName());
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
assertThat(container.getValue().isSameTypeAs(TestAny.getDefaultInstance())).isFalse();
result = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
TestUtil.assertAllFieldsSet(result);
}
@Test
public void testCachedUnpackResult() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
@ -132,4 +211,19 @@ public class AnyTest {
TestAllTypes result2 = container.getValue().unpack(TestAllTypes.class);
assertThat(Objects.equals(result1, result2)).isTrue();
}
@Test
public void testCachedUnpackExemplarResult() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
TestUtil.setAllFields(builder);
TestAllTypes message = builder.build();
TestAny container = TestAny.newBuilder().setValue(Any.pack(message)).build();
assertThat(container.getValue().isSameTypeAs(TestAllTypes.getDefaultInstance())).isTrue();
TestAllTypes result1 = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
TestAllTypes result2 = container.getValue().unpackSameTypeAs(TestAllTypes.getDefaultInstance());
assertThat(Objects.equals(result1, result2)).isTrue();
}
}

@ -187,8 +187,6 @@ else
# Can't issue these together, when fully parallel, something sometimes chokes
# at random.
"${BazelBin}" test //src/... $BazelFlags
# Fire off the conformance tests also.
"${BazelBin}" test //objectivec:conformance_test $BazelFlags
fi
# Ensure the WKT sources checked in are current.

@ -69,6 +69,10 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
* if (any.is(Foo.class)) {
* foo = any.unpack(Foo.class);
* }
* // or ...
* if (any.isSameTypeAs(Foo.getDefaultInstance())) {
* foo = any.unpack(Foo.getDefaultInstance());
* }
*
* Example 3: Pack and unpack a message in Python.
*

@ -89,7 +89,7 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html

@ -102,7 +102,7 @@ static CFHashCode GPBRootExtensionKeyHash(const void *value) {
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html

@ -1,3 +1,33 @@
// 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.
//
// Use this file to import your target's public headers that you would like to
// expose to Swift.

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2016 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2011 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 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

@ -1,5 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2015 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

@ -30,7 +30,7 @@ __EOF__
fi
# Make sure the compiler is current.
"${BazelBin}" build $@ //:protoc
"${BazelBin}" build //:protoc $@
cd src
declare -a RUNTIME_PROTO_FILES=( \

@ -2,10 +2,12 @@
#
# See also code generation logic under /src/google/protobuf/compiler/php.
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@upb//cmake:build_defs.bzl", "staleness_test")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load("//conformance:defs.bzl", "conformance_test")
load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION", "PROTOC_VERSION")
filegroup(
name = "source_files",
@ -14,15 +16,11 @@ filegroup(
"//php:__pkg__",
],
srcs = glob([
"ext/google/protobuf/*.h",
"ext/google/protobuf/*.c",
"src/GPBMetadata/Google/Protobuf/**/*.php",
"src/Google/Protobuf/**/*.php",
]) + [
"composer.json",
"ext/google/protobuf/wkt.inc",
"ext/google/protobuf/config.m4",
"ext/google/protobuf/package.xml",
":php_ext_source_files",
],
)
@ -137,3 +135,76 @@ pkg_files(
strip_prefix = strip_prefix.from_pkg(""),
visibility = ["//pkg:__pkg__"],
)
################################################################################
# PECL .tgz Release
################################################################################
pkg_files(
name = "php_ext_source_files",
srcs = glob([
"ext/google/protobuf/*.h",
"ext/google/protobuf/*.c",
]) + [
"//:LICENSE",
"ext/google/protobuf/config.m4",
"ext/google/protobuf/wkt.inc",
],
)
pkg_files(
name = "utf8_range_files",
srcs = [
"@utf8_range//:utf8_range_srcs",
"@utf8_range//:LICENSE",
],
prefix = "third_party/utf8_range",
)
pkg_filegroup(
name = "pecl_release_files",
srcs = [
":php_ext_source_files",
":utf8_range_files",
],
prefix = "protobuf-%s" % PROTOBUF_PHP_VERSION,
)
# PECL .tgz without package.xml
pkg_tar(
name = "release_without_package",
extension = "tgz",
srcs = [
":pecl_release_files",
],
out = "release_without_package.tgz",
)
# Generate PECL package.xml
genrule(
name = "generate_package_xml",
srcs = [
":release_without_package",
"ext/google/protobuf/template_package.xml",
],
outs = ["package.xml"],
cmd = " ".join([
"$(location ext/google/protobuf/generate_package_xml.sh)",
"$(location ext/google/protobuf/template_package.xml)",
PROTOBUF_PHP_VERSION,
PROTOC_VERSION,
"$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')",
"$(location package.xml)"
]),
tools = ["ext/google/protobuf/generate_package_xml.sh"],
)
pkg_tar(
name = "release",
extension = "tgz",
srcs = [
":pecl_release_files",
":generate_package_xml",
],
out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION,
)

@ -0,0 +1,41 @@
#!/bin/bash
template_package_xml=$1
release_version=$2
protoc_version=$3
release_files=$4
out=$5
date=$(date +%Y-%m-%d)
time=$(date +%H:%M:%S)
php_version_array=(${release_version//RC/ })
api_version=${php_version_array[0]}
if [ ${#php_version_array[@]} -eq 2 ]; then
rc=${php_version_array[1]}
stability='beta'
else
stability='stable'
fi
files="\\n"
for file in ${release_files//,/ }; do
name=$(echo $file | grep .*[^/]\$ | sed -e "s;protobuf-${release_version}/;;")
if [ ! -z $name ]; then
if [[ $name =~ LICENSE$ ]]; then
role='doc'
else
role='src'
fi
files+=" <file baseinstalldir=\"/\" name=\"${name}\" role=\"${role}\"/>\\n"
fi
done
cat $template_package_xml |
sed -e "s;TEMPLATE_DATE;${date};" |
sed -e "s;TEMPLATE_TIME;${time};" |
sed -e "s;TEMPLATE_PHP_RELEASE;${release_version};" |
sed -e "s;TEMPLATE_PHP_API;${api_version};" |
sed -e "s;TEMPLATE_PHP_STABILITY;${stability};g" |
sed -e "s;TEMPLATE_PROTOC_VERSION;${protoc_version};" |
sed -e "s;TEMPLATE_FILES;${files};" > $out

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.5" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>protobuf</name>
<channel>pecl.php.net</channel>
<summary>Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.</summary>
<description>https://developers.google.com/protocol-buffers/</description>
<lead>
<name>Protobuf Team</name>
<user>protobufpackages</user>
<email>protobuf-packages@google.com</email>
<active>yes</active>
</lead>
<date>TEMPLATE_DATE</date>
<time>TEMPLATE_TIME</time>
<version>
<release>TEMPLATE_PHP_RELEASE</release>
<api>TEMPLATE_PHP_API</api>
</version>
<stability>
<release>TEMPLATE_PHP_STABILITY</release>
<api>TEMPLATE_PHP_STABILITY</api>
</stability>
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
<notes>
* See github.com/protocolbuffers/protobuf/releases/tag/vTEMPLATE_PROTOC_VERSION for release notes.
</notes>
<contents>
<dir baseinstalldir="/" name="/">TEMPLATE_FILES</dir>
</contents>
<dependencies>
<required>
<php>
<min>7.0.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>protobuf</providesextension>
<extsrcrelease/>
</package>

@ -344,15 +344,8 @@ cc_dist_library(
}),
tags = ["manual"],
deps = [
"//src/google/protobuf:arena",
"//src/google/protobuf:arena_align",
"//src/google/protobuf:arena_allocation_policy",
"//src/google/protobuf:arena_cleanup",
"//src/google/protobuf:arena_config",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf/io",
"//src/google/protobuf/io:io_win32",
"//src/google/protobuf/stubs:lite",
],
)
@ -367,33 +360,11 @@ cc_dist_library(
}),
tags = ["manual"],
deps = [
"//src/google/protobuf:wkt_cc_proto",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf:arena",
"//src/google/protobuf:arena_align",
"//src/google/protobuf:arena_allocation_policy",
"//src/google/protobuf:arena_cleanup",
"//src/google/protobuf:arena_config",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf:port_def",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf:wkt_cc_proto",
"//src/google/protobuf/compiler:importer",
"//src/google/protobuf/io",
"//src/google/protobuf/io:gzip_stream",
"//src/google/protobuf/io:io_win32",
"//src/google/protobuf/io:printer",
"//src/google/protobuf/io:tokenizer",
"//src/google/protobuf/io:zero_copy_sink",
"//src/google/protobuf/json",
"//src/google/protobuf/json:descriptor_traits",
"//src/google/protobuf/json:lexer",
"//src/google/protobuf/json:message_path",
"//src/google/protobuf/json:parser",
"//src/google/protobuf/json:unparser",
"//src/google/protobuf/json:untyped_message",
"//src/google/protobuf/json:writer",
"//src/google/protobuf/json:zero_copy_buffered_stream",
"//src/google/protobuf/stubs",
"//src/google/protobuf/stubs:lite",
"//src/google/protobuf/util:delimited_message_util",
"//src/google/protobuf/util:differencer",
"//src/google/protobuf/util:field_mask_util",
@ -407,25 +378,19 @@ cc_dist_library(
name = "protoc",
tags = ["manual"],
deps = [
"//src/google/protobuf/compiler:code_generator",
"//src/google/protobuf/compiler:command_line_interface",
"//src/google/protobuf/compiler/cpp",
"//src/google/protobuf/compiler/cpp:names",
"//src/google/protobuf/compiler/cpp:names_internal",
"//src/google/protobuf/compiler/csharp",
"//src/google/protobuf/compiler/csharp:names",
"//src/google/protobuf/compiler/java",
"//src/google/protobuf/compiler/java:names",
"//src/google/protobuf/compiler/java:names_internal",
"//src/google/protobuf/compiler/objectivec",
"//src/google/protobuf/compiler/objectivec:line_consumer",
"//src/google/protobuf/compiler/objectivec:names",
"//src/google/protobuf/compiler/objectivec:names_internal",
"//src/google/protobuf/compiler/php",
"//src/google/protobuf/compiler/php:names",
"//src/google/protobuf/compiler/python",
"//src/google/protobuf/compiler/ruby",
],
dist_deps = [
":protobuf",
":protobuf_lite",
],
)
cc_dist_library(
@ -433,6 +398,7 @@ cc_dist_library(
testonly = 1,
tags = ["manual"],
deps = ["//src/google/protobuf:lite_test_util"],
dist_deps = [":protobuf_lite"],
)
cc_dist_library(
@ -440,11 +406,19 @@ cc_dist_library(
testonly = 1,
tags = ["manual"],
deps = [
"//src/google/protobuf:lite_test_util",
"//src/google/protobuf:test_util",
"//src/google/protobuf:test_util2",
"//src/google/protobuf/compiler:annotation_test_util",
"//src/google/protobuf/compiler/cpp:unittest_lib",
],
dist_deps = [
":common_test",
":lite_test_util",
":protoc",
":protobuf",
":protobuf_lite",
],
)
cc_dist_library(
@ -452,12 +426,16 @@ cc_dist_library(
testonly = 1,
tags = ["manual"],
deps = [
"//src/google/protobuf/testing",
"//src/google/protobuf/compiler:mock_code_generator",
"//src/google/protobuf/testing",
],
dist_deps = [
":protobuf",
":protobuf_lite",
":protoc",
],
)
################################################################################
# Distribution sources
################################################################################

@ -281,7 +281,10 @@ def _cmake_var_fragment(owner, varname, prefix, entries):
).format(
owner = owner,
varname = varname,
entries = "\n".join([" %s%s" % (prefix, f) for f in entries]),
# Strip out "wkt/google/protobuf/" from the well-known type file paths.
# This is currently necessary to allow checked-in and generated
# versions of the well-known type generated code to coexist.
entries = "\n".join([" %s%s" % (prefix, f.replace("wkt/google/protobuf/", "")) for f in entries]),
)
def _cmake_file_list_impl(ctx):

@ -134,12 +134,16 @@ CcFileList = provider(
)
def _flatten_target_files(targets):
return depset(transitive = [target.files for target in targets])
return depset(transitive = [
target.files
for target in targets
# Filter out targets from external workspaces
if target.label.workspace_name == "" or
target.label.workspace_name == "com_google_protobuf"
])
files = []
for target in targets:
files.extend(target.files.to_list())
return files
def _get_transitive_sources(targets, attr, deps):
return depset(targets, transitive = [getattr(dep[CcFileList], attr) for dep in deps if CcFileList in dep])
def _cc_file_list_aspect_impl(target, ctx):
# Extract sources from a `cc_library` (or similar):
@ -165,14 +169,22 @@ def _cc_file_list_aspect_impl(target, ctx):
internal_hdrs.append(src)
return [CcFileList(
hdrs = _flatten_target_files(getattr(rule_attr, "hdrs", depset())),
textual_hdrs = _flatten_target_files(getattr(
rule_attr,
hdrs = _get_transitive_sources(
_flatten_target_files(rule_attr.hdrs).to_list(),
"hdrs",
rule_attr.deps,
),
textual_hdrs = _get_transitive_sources(
_flatten_target_files(rule_attr.textual_hdrs).to_list(),
"textual_hdrs",
depset(),
)),
internal_hdrs = depset(internal_hdrs),
srcs = depset(srcs),
rule_attr.deps,
),
internal_hdrs = _get_transitive_sources(
internal_hdrs,
"internal_hdrs",
rule_attr.deps,
),
srcs = _get_transitive_sources(srcs, "srcs", rule_attr.deps),
)]
cc_file_list_aspect = aspect(
@ -198,7 +210,9 @@ Output is CcFileList. Example:
# srcs = depset([File("foo.cc")]),
# )
""",
required_providers = [CcInfo],
implementation = _cc_file_list_aspect_impl,
attr_aspects = ["deps"],
)
################################################################################
@ -206,10 +220,10 @@ Output is CcFileList. Example:
################################################################################
def _collect_inputs(deps):
"""Collects files from a list of immediate deps.
"""Collects files from a list of deps.
This rule collects source files and linker inputs for C++ deps. Only
these immediate deps are considered, not transitive deps.
This rule collects source files and linker inputs transitively for C++
deps.
The return value is a struct with object files (linker inputs),
partitioned by PIC and non-pic, and the rules' source and header files:
@ -221,9 +235,8 @@ def _collect_inputs(deps):
)
Args:
deps: Iterable of immediate deps. These will be treated as the "inputs,"
but not the transitive deps.
deps: Iterable of immediate deps, which will be treated as roots to
recurse transitively.
Returns:
A struct with linker inputs, source files, and header files.
"""
@ -265,6 +278,27 @@ def _collect_inputs(deps):
),
)
# Given structs a and b returned from _collect_inputs(), returns a copy of a
# but with all files from b subtracted out.
def _subtract_files(a, b):
result_args = {}
top_level_fields = ["objects", "pic_objects"]
for field in top_level_fields:
to_remove = {e: None for e in getattr(b, field)}
result_args[field] = [e for e in getattr(a, field) if not e in to_remove]
cc_file_list_args = {}
file_list_fields = ["srcs", "hdrs", "internal_hdrs", "textual_hdrs"]
for field in file_list_fields:
to_remove = {e: None for e in getattr(b.cc_file_list, field).to_list()}
cc_file_list_args[field] = depset(
[e for e in getattr(a.cc_file_list, field).to_list() if not e in to_remove],
)
result_args["cc_file_list"] = CcFileList(**cc_file_list_args)
return struct(**result_args)
# Implementation for cc_dist_library rule.
def _cc_dist_library_impl(ctx):
cc_toolchain_info = find_cc_toolchain(ctx)
@ -274,7 +308,7 @@ def _cc_dist_library_impl(ctx):
cc_toolchain = cc_toolchain_info,
)
inputs = _collect_inputs(ctx.attr.deps)
inputs = _subtract_files(_collect_inputs(ctx.attr.deps), _collect_inputs(ctx.attr.dist_deps))
# For static libraries, build separately with and without pic.
@ -346,20 +380,17 @@ Create libraries suitable for distribution.
This rule creates static and dynamic libraries from the libraries listed in
'deps'. The resulting libraries are suitable for distributing all of 'deps'
in a single logical library, for example, in an installable binary package.
Only the targets listed in 'deps' are included in the result (i.e., the
output does not include transitive dependencies), allowing precise control
over the library boundary.
The result includes all transitive dependencies, excluding those reachable
from 'dist_deps' or defined in a separate repository (e.g. Abseil).
The outputs of this rule are a dynamic library and a static library. (If
the build produces both PIC and non-PIC object files, then there is also a
second static library.) The example below illustrates additional details.
This rule is different from Bazel's experimental `shared_cc_library` in
several ways. First, this rule ignores transitive dependencies, which means
that dynamic library dependencies generally need to be specified via
'linkopts'. Second, this rule produces a static archive library in addition
to the dynamic shared library. Third, this rule is not directly usable as a
C++ dependency (although the outputs could be used, e.g., by `cc_import`).
This rule is different from Bazel's experimental `shared_cc_library` in two
ways. First, this rule produces a static archive library in addition to the
dynamic shared library. Second, this rule is not directly usable as a C++
dependency (although the outputs could be used, e.g., by `cc_import`).
Example:
@ -372,15 +403,18 @@ Example:
cc_dist_library(
name = "dist",
linkopts = ["-la"], # libdist.so dynamically links against liba.so.
deps = [":b", ":c"], # Output contains b.o and c.o, but not a.o.
deps = [":b", ":c"], # Output contains a.o, b.o, and c.o.
)
""",
attrs = {
"deps": attr.label_list(
doc = ("The list of libraries to be included in the outputs. " +
"Only these targets' compilation outputs will be " +
"included (i.e., the transitive dependencies are not " +
"included in the output)."),
doc = ("The list of libraries to be included in the outputs, " +
"along with their transitive dependencies."),
aspects = [cc_file_list_aspect],
),
"dist_deps": attr.label_list(
doc = ("The list of cc_dist_library dependencies that " +
"should be excluded."),
aspects = [cc_file_list_aspect],
),
"linkopts": attr.string_list(

@ -135,6 +135,6 @@ def protobuf_deps():
_github_archive(
name = "upb",
repo = "https://github.com/protocolbuffers/upb",
commit = "9e2d7f02da5440bfb0dfb069f61baa278aa2fbf6",
sha256 = "9eb13368a136af314855e1497838cf3124846b6a73a7e7c882455a52b8c04662",
commit = "73661563dbb82bf7fdd614dd8da1186c0acc6b17",
sha256 = "0b2789aa957c665165fa66892a6402489d6491cb097391fd8ea5b5a248dbde35",
)

@ -1,3 +1,4 @@
PROTOC_VERSION = "21.9"
PROTOBUF_JAVA_VERSION = "3.21.9"
PROTOBUF_PYTHON_VERSION = "4.21.9"
PROTOBUF_PHP_VERSION = "3.21.9"

@ -0,0 +1,46 @@
#!/bin/bash
# This script updates src/file_lists.cmake and the checked-in generated code
# for the well-known types, commits the resulting changes, and pushes them.
# This does not do anything useful when run manually, but should be run by our
# GitHub action instead.
set -ex
# Cd to the repo root.
cd $(dirname -- "$0")
previous_commit_title=$(git log -1 --pretty='%s')
# Exit early if the previous commit was auto-generated. This reduces the risk
# of a bug causing an infinite loop of auto-generated commits.
if (echo "$previous_commit_title" | grep -q "^Auto-generate files"); then
echo "Previous commit was auto-generated"
exit 0
fi
# Run the staleness tests and use them to update any stale files.
bazel test //src:cmake_lists_staleness_test || ./bazel-bin/src/cmake_lists_staleness_test --fix
bazel test //src/google/protobuf:well_known_types_staleness_test || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
# Try to determine the most recent CL or pull request.
pr_from_merge=$(echo "$previous_commit_title" | sed -n 's/^Merge pull request #\([0-9]\+\).*/\1/p')
pr_from_squash=$(echo "$previous_commit_title" | sed -n 's/^.*(#\([0-9]\+\))$/\1/p')
cl=$(git log -1 --pretty='%b' | sed -n 's/^PiperOrigin-RevId: \([0-9]*\)$/\1/p')
if [ ! -z "$pr_from_merge" ]; then
commit_message="Auto-generate files after PR #$pr_from_merge"
elif [ ! -z "$pr_from_squash" ]; then
commit_message="Auto-generate files after PR #$pr_from_squash"
elif [ ! -z "$cl" ]; then
commit_message="Auto-generate files after cl/$cl"
else
# If we are unable to determine the CL or pull request number, we fall back
# on this default commit message. Typically this should not occur, but could
# happen if a pull request was merged via a rebase.
commit_message="Auto-generate files"
fi
git add -A
git diff --staged --quiet || git commit -am "$commit_message"
git push

@ -1,35 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

@ -66,6 +66,7 @@ if _USE_C_DESCRIPTORS:
# and make it return True when the descriptor is an instance of the extension
# type written in C++.
class DescriptorMetaclass(type):
def __instancecheck__(cls, obj):
if super(DescriptorMetaclass, cls).__instancecheck__(obj):
return True
@ -633,13 +634,29 @@ class FieldDescriptor(DescriptorBase):
if (self.cpp_type == FieldDescriptor.CPPTYPE_MESSAGE or
self.containing_oneof):
return True
if hasattr(self.file, 'syntax'):
return self.file.syntax == 'proto2'
if hasattr(self.message_type, 'syntax'):
return self.message_type.syntax == 'proto2'
raise RuntimeError(
'has_presence is not ready to use because field %s is not'
' linked with message type nor file' % self.full_name)
# self.containing_type is used here instead of self.file for legacy
# compatibility. FieldDescriptor.file was added in cl/153110619
# Some old/generated code didn't link file to FieldDescriptor.
# TODO(jieluo): remove syntax usage b/240619313
return self.containing_type.syntax == 'proto2'
@property
def is_packed(self):
"""Returns if the field is packed."""
if self.label != FieldDescriptor.LABEL_REPEATED:
return False
field_type = self.type
if (field_type == FieldDescriptor.TYPE_STRING or
field_type == FieldDescriptor.TYPE_GROUP or
field_type == FieldDescriptor.TYPE_MESSAGE or
field_type == FieldDescriptor.TYPE_BYTES):
return False
if self.containing_type.syntax == 'proto2':
return self.has_options and self.GetOptions().packed
else:
return (not self.has_options or
not self.GetOptions().HasField('packed') or
self.GetOptions().packed)
@staticmethod
def ProtoTypeToCppProtoType(proto_type):
@ -720,6 +737,18 @@ class EnumDescriptor(_NestedDescriptorBase):
# Values are reversed to ensure that the first alias is retained.
self.values_by_number = dict((v.number, v) for v in reversed(values))
@property
def is_closed(self):
"""If the enum is closed.
closed enum means:
- Has a fixed set of named values.
- Encountering values not in this set causes them to be treated as
unknown fields.
- The first value (i.e., the default) may be nonzero.
"""
return self.file.syntax == 'proto2'
def CopyToProto(self, proto):
"""Copies this to a descriptor_pb2.EnumDescriptorProto.

@ -35,7 +35,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
import unittest
import warnings
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
@ -45,6 +44,7 @@ from google.protobuf import descriptor
from google.protobuf import descriptor_pool
from google.protobuf import symbol_database
from google.protobuf import text_format
from google.protobuf import unittest_custom_options_pb2
TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII = """

@ -33,11 +33,11 @@
import unittest
from google.protobuf import field_mask_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import field_mask
from google.protobuf.internal import test_util
from google.protobuf import descriptor
from google.protobuf import map_unittest_pb2
class FieldMaskTest(unittest.TestCase):

@ -42,15 +42,15 @@ __author__ = 'robinson@google.com (Will Robinson)'
import unittest
from google.protobuf.internal import test_bad_identifiers_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_mset_wire_format_pb2
from google.protobuf import unittest_no_generic_services_pb2
from google.protobuf import unittest_pb2
from google.protobuf import service
from google.protobuf import symbol_database
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_no_generic_services_pb2
MAX_EXTENSION = 536870912

@ -44,12 +44,12 @@ from google.protobuf import field_mask_pb2
from google.protobuf import struct_pb2
from google.protobuf import timestamp_pb2
from google.protobuf import wrappers_pb2
from google.protobuf import any_test_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf import descriptor_pool
from google.protobuf import json_format
from google.protobuf import any_test_pb2
from google.protobuf.util import json_format_pb2
from google.protobuf.util import json_format_proto3_pb2

@ -50,20 +50,20 @@ import warnings
cmp = lambda x, y: (x > y) - (x < y)
from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor
from google.protobuf import unittest_pb2 # pylint: disable=g-import-not-at-top
from google.protobuf.internal import api_implementation
from google.protobuf.internal import encoder
from google.protobuf.internal import more_extensions_pb2
from google.protobuf.internal import packed_field_test_pb2
from google.protobuf.internal import test_util
from google.protobuf.internal import test_proto3_optional_pb2
from google.protobuf.internal import test_util
from google.protobuf.internal import testing_refleaks
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf.internal import _parameterized
from google.protobuf import map_proto2_unittest_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
UCS2_MAXUNICODE = 65535

@ -283,20 +283,8 @@ def _IsMessageMapField(field):
def _AttachFieldHelpers(cls, field_descriptor):
is_repeated = (field_descriptor.label == _FieldDescriptor.LABEL_REPEATED)
is_packable = (is_repeated and
wire_format.IsTypePackable(field_descriptor.type))
is_proto3 = field_descriptor.containing_type.syntax == 'proto3'
if not is_packable:
is_packed = False
elif field_descriptor.containing_type.syntax == 'proto2':
is_packed = (field_descriptor.has_options and
field_descriptor.GetOptions().packed)
else:
has_packed_false = (field_descriptor.has_options and
field_descriptor.GetOptions().HasField('packed') and
field_descriptor.GetOptions().packed == False)
is_packed = not has_packed_false
is_map_entry = _IsMapField(field_descriptor)
is_packed = field_descriptor.is_packed
if is_map_entry:
field_encoder = encoder.MapEncoder(field_descriptor)
@ -320,16 +308,12 @@ def _AttachFieldHelpers(cls, field_descriptor):
tag_bytes = encoder.TagBytes(field_descriptor.number, wiretype)
decode_type = field_descriptor.type
if (decode_type == _FieldDescriptor.TYPE_ENUM and
type_checkers.SupportsOpenEnums(field_descriptor)):
not field_descriptor.enum_type.is_closed):
decode_type = _FieldDescriptor.TYPE_INT32
oneof_descriptor = None
clear_if_default = False
if field_descriptor.containing_oneof is not None:
oneof_descriptor = field_descriptor
elif (is_proto3 and not is_repeated and
field_descriptor.cpp_type != _FieldDescriptor.CPPTYPE_MESSAGE):
clear_if_default = True
if is_map_entry:
is_message_map = _IsMessageMapField(field_descriptor)
@ -341,7 +325,7 @@ def _AttachFieldHelpers(cls, field_descriptor):
field_decoder = decoder.StringDecoder(
field_descriptor.number, is_repeated, is_packed,
field_descriptor, field_descriptor._default_constructor,
clear_if_default)
not field_descriptor.has_presence)
elif field_descriptor.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
field_decoder = type_checkers.TYPE_TO_DECODER[decode_type](
field_descriptor.number, is_repeated, is_packed,
@ -351,7 +335,7 @@ def _AttachFieldHelpers(cls, field_descriptor):
field_descriptor.number, is_repeated, is_packed,
# pylint: disable=protected-access
field_descriptor, field_descriptor._default_constructor,
clear_if_default)
not field_descriptor.has_presence)
cls._decoders_by_tag[tag_bytes] = (field_decoder, oneof_descriptor)
@ -683,7 +667,6 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
property_name = _PropertyName(proto_field_name)
type_checker = type_checkers.GetTypeChecker(field)
default_value = field.default_value
is_proto3 = field.containing_type.syntax == 'proto3'
def getter(self):
# TODO(protobuf-team): This may be broken since there may not be
@ -692,8 +675,6 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
getter.__module__ = None
getter.__doc__ = 'Getter for %s.' % proto_field_name
clear_when_set_to_default = is_proto3 and not field.containing_oneof
def field_setter(self, new_value):
# pylint: disable=protected-access
# Testing the value for truthiness captures all of the proto3 defaults
@ -703,7 +684,7 @@ def _AddPropertiesForNonRepeatedScalarField(field, cls):
except TypeError as e:
raise TypeError(
'Cannot set %s to %.1024r: %s' % (field.full_name, new_value, e))
if clear_when_set_to_default and not new_value:
if not field.has_presence and not new_value:
self._fields.pop(field, None)
else:
self._fields[field] = new_value
@ -825,24 +806,16 @@ def _AddListFieldsMethod(message_descriptor, cls):
cls.ListFields = ListFields
_PROTO3_ERROR_TEMPLATE = \
('Protocol message %s has no non-repeated submessage field "%s" '
'nor marked as optional')
_PROTO2_ERROR_TEMPLATE = 'Protocol message %s has no non-repeated field "%s"'
def _AddHasFieldMethod(message_descriptor, cls):
"""Helper for _AddMessageMethods()."""
is_proto3 = (message_descriptor.syntax == "proto3")
error_msg = _PROTO3_ERROR_TEMPLATE if is_proto3 else _PROTO2_ERROR_TEMPLATE
hassable_fields = {}
for field in message_descriptor.fields:
if field.label == _FieldDescriptor.LABEL_REPEATED:
continue
# For proto3, only submessages and fields inside a oneof have presence.
if (is_proto3 and field.cpp_type != _FieldDescriptor.CPPTYPE_MESSAGE and
not field.containing_oneof):
if not field.has_presence:
continue
hassable_fields[field.name] = field
@ -853,8 +826,10 @@ def _AddHasFieldMethod(message_descriptor, cls):
def HasField(self, field_name):
try:
field = hassable_fields[field_name]
except KeyError:
raise ValueError(error_msg % (message_descriptor.full_name, field_name))
except KeyError as exc:
raise ValueError('Protocol message %s has no non-repeated field "%s" '
'nor has presence is not available for this field.' % (
message_descriptor.full_name, field_name)) from exc
if isinstance(field, descriptor_mod.OneofDescriptor):
try:

@ -44,7 +44,6 @@ import unittest
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor
from google.protobuf import message
@ -59,6 +58,7 @@ from google.protobuf.internal import test_util
from google.protobuf.internal import testing_refleaks
from google.protobuf.internal import decoder
from google.protobuf.internal import _parameterized
from google.protobuf import unittest_proto3_arena_pb2
warnings.simplefilter('error', DeprecationWarning)

@ -41,12 +41,8 @@ import unittest
from google.protobuf import any_pb2
from google.protobuf import struct_pb2
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import any_test_pb2 as test_extend_any
from google.protobuf.internal import api_implementation
@ -56,6 +52,10 @@ from google.protobuf.internal import test_util
from google.protobuf import descriptor_pool
from google.protobuf import text_format
from google.protobuf.internal import _parameterized
from google.protobuf import any_test_pb2
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_proto3_arena_pb2
# pylint: enable=g-import-not-at-top

@ -75,10 +75,6 @@ def ToShortestFloat(original):
return rounded
def SupportsOpenEnums(field_descriptor):
return field_descriptor.containing_type.syntax == 'proto3'
def GetTypeChecker(field):
"""Returns a type checker for a message field of the specified types.
@ -93,11 +89,11 @@ def GetTypeChecker(field):
field.type == _FieldDescriptor.TYPE_STRING):
return UnicodeValueChecker()
if field.cpp_type == _FieldDescriptor.CPPTYPE_ENUM:
if SupportsOpenEnums(field):
if field.enum_type.is_closed:
return EnumValueChecker(field.enum_type)
else:
# When open enums are supported, any int32 can be assigned.
return _VALUE_CHECKERS[_FieldDescriptor.CPPTYPE_INT32]
else:
return EnumValueChecker(field.enum_type)
return _VALUE_CHECKERS[field.cpp_type]

@ -36,10 +36,8 @@ __author__ = 'bohdank@google.com (Bohdan Koval)'
import sys
import unittest
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
from google.protobuf.internal import api_implementation
from google.protobuf.internal import encoder
from google.protobuf.internal import message_set_extensions_pb2
@ -50,6 +48,8 @@ from google.protobuf.internal import type_checkers
from google.protobuf.internal import wire_format
from google.protobuf import descriptor
from google.protobuf import unknown_fields
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
try:
import tracemalloc # pylint: disable=g-import-not-at-top
except ImportError:

@ -43,7 +43,7 @@ TAG_TYPE_MASK = (1 << TAG_TYPE_BITS) - 1 # 0x7
# These numbers identify the wire type of a protocol buffer value.
# We use the least-significant TAG_TYPE_BITS bits of the varint-encoded
# tag-and-type to store one of these WIRETYPE_* constants.
# These values must match WireType enum in google/protobuf/wire_format.h.
# These values must match WireType enum in //net/proto2/public/wire_format.h.
WIRETYPE_VARINT = 0
WIRETYPE_FIXED64 = 1
WIRETYPE_LENGTH_DELIMITED = 2

@ -287,10 +287,11 @@ class _Printer(object):
if enum_value is not None:
return enum_value.name
else:
if field.file.syntax == 'proto3':
if field.enum_type.is_closed:
raise SerializeToJsonError('Enum field contains an integer value '
'which can not mapped to an enum value.')
else:
return value
raise SerializeToJsonError('Enum field contains an integer value '
'which can not mapped to an enum value.')
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_STRING:
if field.type == descriptor.FieldDescriptor.TYPE_BYTES:
# Use base64 Data encoding for bytes
@ -799,11 +800,11 @@ def _ConvertScalarFieldValue(value, field, path, require_str=False):
raise ParseError('Invalid enum value {0} for enum type {1}'.format(
value, field.enum_type.full_name))
if enum_value is None:
if field.file.syntax == 'proto3':
# Proto3 accepts unknown enums.
if field.enum_type.is_closed:
raise ParseError('Invalid enum value {0} for enum type {1}'.format(
value, field.enum_type.full_name))
else:
return number
raise ParseError('Invalid enum value {0} for enum type {1}'.format(
value, field.enum_type.full_name))
return enum_value.number
except ParseError as e:
raise ParseError('{0} at {1}'.format(e, path))

@ -1182,6 +1182,11 @@ static PyObject* GetHasOptions(PyBaseDescriptor *self, void *closure) {
Py_RETURN_FALSE;
}
}
static PyObject* GetIsClosed(PyBaseDescriptor* self, void* closure) {
return PyBool_FromLong(_GetDescriptor(self)->is_closed());
}
static int SetHasOptions(PyBaseDescriptor *self, PyObject *value,
void *closure) {
return CheckCalledFromGeneratedFile("has_options");
@ -1225,6 +1230,7 @@ static PyGetSetDef Getters[] = {
"Containing type"},
{"has_options", (getter)GetHasOptions, (setter)SetHasOptions,
"Has Options"},
{"is_closed", (getter)GetIsClosed, nullptr, "If the enum is closed"},
{"_options", (getter) nullptr, (setter)SetOptions, "Options"},
{"_serialized_options", (getter) nullptr, (setter)SetSerializedOptions,
"Serialized Options"},

@ -340,7 +340,7 @@ def _BuildMessageFromTypeName(type_name, descriptor_pool):
return message_type()
# These values must match WireType enum in google/protobuf/wire_format.h.
# These values must match WireType enum in //net/proto2/public/wire_format.h.
WIRETYPE_LENGTH_DELIMITED = 2
WIRETYPE_START_GROUP = 3
@ -1852,12 +1852,8 @@ def ParseEnum(field, value):
raise ValueError('Enum type "%s" has no value named %s.' %
(enum_descriptor.full_name, value))
else:
# Numeric value.
if hasattr(field.file, 'syntax'):
# Attribute is checked for compatibility.
if field.file.syntax == 'proto3':
# Proto3 accept numeric unknown enums.
return number
if not field.enum_type.is_closed:
return number
enum_value = enum_descriptor.values_by_number.get(number, None)
if enum_value is None:
raise ValueError('Enum type "%s" has no value with number %d.' %

@ -1300,7 +1300,7 @@ VALUE build_module_from_enumdesc(VALUE _enumdesc) {
return mod;
}
// Internal only; used by Google::Protobuf.deep_copy.
// Internal to the library; used by Google::Protobuf.deep_copy.
upb_Message* Message_deep_copy(const upb_Message* msg, const upb_MessageDef* m,
upb_Arena* arena) {
// Serialize and parse.

File diff suppressed because it is too large Load Diff

@ -269,14 +269,39 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define UPB_DEPRECATED
#endif
#ifndef UPB_INTERNAL_ARRAY_H_
#define UPB_INTERNAL_ARRAY_H_
#ifndef UPB_INTERNAL_ATOI_H_
#define UPB_INTERNAL_ATOI_H_
// Must be last.
#ifdef __cplusplus
extern "C" {
#endif
// We use these hand-written routines instead of strto[u]l() because the "long
// long" variants aren't in c89. Also our version allows setting a ptr limit.
// Return the new position of the pointer after parsing the int, or NULL on
// integer overflow.
const char* upb_BufToUint64(const char* ptr, const char* end, uint64_t* val);
const char* upb_BufToInt64(const char* ptr, const char* end, int64_t* val,
bool* is_neg);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_INTERNAL_ATOI_H_ */
#ifndef UPB_INTERNAL_ARRAY_INTERNAL_H_
#define UPB_INTERNAL_ARRAY_INTERNAL_H_
#include <string.h>
#ifndef UPB_ARRAY_H_
#define UPB_ARRAY_H_
#ifndef UPB_COLLECTIONS_ARRAY_H_
#define UPB_COLLECTIONS_ARRAY_H_
#ifndef UPB_MESSAGE_VALUE_H_
@ -295,14 +320,14 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define UPB_MSG_H_
#ifndef UPB_ARENA_H_
#define UPB_ARENA_H_
#ifndef UPB_MEM_ARENA_H_
#define UPB_MEM_ARENA_H_
#include <string.h>
#ifndef UPB_ALLOC_H_
#define UPB_ALLOC_H_
#ifndef UPB_MEM_ALLOC_H_
#define UPB_MEM_ALLOC_H_
// Must be last.
@ -345,7 +370,7 @@ UPB_INLINE void upb_free(upb_alloc* alloc, void* ptr) {
alloc->func(alloc, ptr, 0, 0);
}
/* The global allocator used by upb. Uses the standard malloc()/free(). */
// The global allocator used by upb. Uses the standard malloc()/free().
extern upb_alloc upb_alloc_global;
@ -369,7 +394,7 @@ UPB_INLINE void upb_gfree(void* ptr) { upb_free(&upb_alloc_global, ptr); }
#endif
#endif /* UPB_ALLOC_H_ */
#endif /* UPB_MEM_ALLOC_H_ */
// Must be last.
@ -502,7 +527,7 @@ UPB_INLINE upb_Arena* upb_Arena_New(void) {
#endif
#endif /* UPB_ARENA_H_ */
#endif /* UPB_MEM_ARENA_H_ */
// Must be last.
@ -757,12 +782,6 @@ UPB_INLINE int _upb_Log2CeilingSize(int x) { return 1 << _upb_Log2Ceiling(x); }
// Must be last.
#ifdef __cplusplus
extern "C" {
#endif
// Definitions common to both upb_Array and upb_Map.
typedef union {
bool bool_val;
float float_val;
@ -783,10 +802,6 @@ typedef union {
upb_Message* msg;
} upb_MutableMessageValue;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MESSAGE_VALUE_H_ */
@ -837,7 +852,7 @@ bool upb_Array_Resize(upb_Array* array, size_t size, upb_Arena* arena);
#endif
#endif /* UPB_ARRAY_H_ */
#endif /* UPB_COLLECTIONS_ARRAY_H_ */
// Must be last.
@ -845,7 +860,7 @@ bool upb_Array_Resize(upb_Array* array, size_t size, upb_Arena* arena);
extern "C" {
#endif
/* Our internal representation for repeated fields. */
// Our internal representation for repeated fields.
struct upb_Array {
uintptr_t data; /* Tagged ptr: low 3 bits of ptr are lg2(elem size). */
size_t size; /* The number of elements in the array. */
@ -884,10 +899,10 @@ UPB_INLINE upb_Array* _upb_Array_New(upb_Arena* a, size_t init_capacity,
return arr;
}
/* Resizes the capacity of the array to be at least min_size. */
// Resizes the capacity of the array to be at least min_size.
bool _upb_array_realloc(upb_Array* arr, size_t min_size, upb_Arena* arena);
/* Fallback functions for when the accessors require a resize. */
// Fallback functions for when the accessors require a resize.
void* _upb_Array_Resize_fallback(upb_Array** arr_ptr, size_t size,
int elem_size_lg2, upb_Arena* arena);
bool _upb_Array_Append_fallback(upb_Array** arr_ptr, const void* value,
@ -963,7 +978,7 @@ UPB_INLINE bool _upb_Array_Append_accessor2(void* msg, size_t ofs,
return true;
}
/* Used by old generated code, remove once all code has been regenerated. */
// Used by old generated code, remove once all code has been regenerated.
UPB_INLINE int _upb_sizelg2(upb_CType type) {
switch (type) {
case kUpb_CType_Bool:
@ -1005,35 +1020,10 @@ UPB_INLINE bool _upb_Array_Append_accessor(void* msg, size_t ofs,
#endif
#endif /* UPB_INTERNAL_ARRAY_H_ */
#endif /* UPB_INTERNAL_ARRAY_INTERNAL_H_ */
#ifndef UPB_INTERNAL_ATOI_H_
#define UPB_INTERNAL_ATOI_H_
// Must be last.
#ifdef __cplusplus
extern "C" {
#endif
// We use these hand-written routines instead of strto[u]l() because the "long
// long" variants aren't in c89. Also our version allows setting a ptr limit.
// Return the new position of the pointer after parsing the int, or NULL on
// integer overflow.
const char* upb_BufToUint64(const char* ptr, const char* end, uint64_t* val);
const char* upb_BufToInt64(const char* ptr, const char* end, int64_t* val,
bool* is_neg);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_INTERNAL_ATOI_H_ */
#ifndef UPB_MAP_H_
#define UPB_MAP_H_
#ifndef UPB_COLLECTIONS_MAP_H_
#define UPB_COLLECTIONS_MAP_H_
// Must be last.
@ -1117,7 +1107,7 @@ void upb_MapIterator_SetValue(upb_Map* map, size_t iter,
#endif
#endif /* UPB_MAP_H_ */
#endif /* UPB_COLLECTIONS_MAP_H_ */
/*
** Our memory representation for parsing tables and messages themselves.
@ -1187,6 +1177,8 @@ upb_ExtensionRegistry* upb_ExtensionRegistry_New(upb_Arena* arena);
// Adds the given extension info for the array |e| of size |count| into the
// registry. If there are any errors, the entire array is backed out.
// The extensions must outlive the registry.
// Possible errors include OOM or an extension number that already exists.
// TODO: There is currently no way to determine the exact reason for failure.
bool upb_ExtensionRegistry_AddArray(upb_ExtensionRegistry* r,
const upb_MiniTable_Extension** e,
size_t count);
@ -2167,6 +2159,70 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
#endif /* UPB_MSG_INT_H_ */
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
#ifndef UPB_COLLECTIONS_MAP_SORTER_INTERNAL_H_
#define UPB_COLLECTIONS_MAP_SORTER_INTERNAL_H_
// Must be last.
#ifdef __cplusplus
extern "C" {
#endif
// _upb_mapsorter sorts maps and provides ordered iteration over the entries.
// Since maps can be recursive (map values can be messages which contain other
// maps), _upb_mapsorter can contain a stack of maps.
typedef struct {
upb_tabent const** entries;
int size;
int cap;
} _upb_mapsorter;
typedef struct {
int start;
int pos;
int end;
} _upb_sortedmap;
UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter* s) {
s->entries = NULL;
s->size = 0;
s->cap = 0;
}
UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter* s) {
if (s->entries) free(s->entries);
}
UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map,
_upb_sortedmap* sorted, upb_MapEntry* ent) {
if (sorted->pos == sorted->end) return false;
const upb_tabent* tabent = s->entries[sorted->pos++];
upb_StringView key = upb_tabstrview(tabent->key);
_upb_map_fromkey(key, &ent->k, map->key_size);
upb_value val = {tabent->val.val};
_upb_map_fromvalue(val, &ent->v, map->val_size);
return true;
}
UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s,
_upb_sortedmap* sorted) {
s->size = sorted->start;
}
bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const upb_Map* map, _upb_sortedmap* sorted);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_COLLECTIONS_MAP_SORTER_INTERNAL_H_ */
/* This file was generated by upbc (the upb compiler) from the input
* file:
*
@ -2179,12 +2235,10 @@ UPB_INLINE void _upb_msg_map_set_value(void* msg, const void* val,
#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
/*
* upb_decode: parsing into a upb_Message using a upb_MiniTable.
*/
// upb_decode: parsing into a upb_Message using a upb_MiniTable.
#ifndef UPB_DECODE_H_
#define UPB_DECODE_H_
#ifndef UPB_WIRE_DECODE_H_
#define UPB_WIRE_DECODE_H_
// Must be last.
@ -2242,7 +2296,7 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
#endif
#endif /* UPB_DECODE_H_ */
#endif /* UPB_WIRE_DECODE_H_ */
// These are the specialized field parser functions for the fast parser.
// Generated tables will refer to these by name.
@ -2278,8 +2332,8 @@ upb_DecodeStatus upb_Decode(const char* buf, size_t size, upb_Message* msg,
// - '1' for one-byte tags (field numbers 1-15)
// - '2' for two-byte tags (field numbers 16-2048)
#ifndef UPB_DECODE_FAST_H_
#define UPB_DECODE_FAST_H_
#ifndef UPB_WIRE_DECODE_FAST_H_
#define UPB_WIRE_DECODE_FAST_H_
// Must be last.
@ -2380,14 +2434,14 @@ TAGBYTES(r)
#endif
#endif /* UPB_DECODE_FAST_H_ */
#endif /* UPB_WIRE_DECODE_FAST_H_ */
/*
* upb_Encode: parsing from a upb_Message using a upb_MiniTable.
*/
#ifndef UPB_ENCODE_H_
#define UPB_ENCODE_H_
#ifndef UPB_WIRE_ENCODE_H_
#define UPB_WIRE_ENCODE_H_
// Must be last.
@ -2432,7 +2486,7 @@ upb_EncodeStatus upb_Encode(const void* msg, const upb_MiniTable* l,
#endif
#endif /* UPB_ENCODE_H_ */
#endif /* UPB_WIRE_ENCODE_H_ */
#ifdef __cplusplus
@ -5657,12 +5711,12 @@ extern const upb_MiniTable_File google_protobuf_descriptor_proto_upb_file_layout
* decode.c and decode_fast.c.
*/
#ifndef UPB_INTERNAL_DECODE_H_
#define UPB_INTERNAL_DECODE_H_
#ifndef UPB_WIRE_DECODE_INTERNAL_H_
#define UPB_WIRE_DECODE_INTERNAL_H_
#ifndef UPB_INTERNAL_ARENA_H_
#define UPB_INTERNAL_ARENA_H_
#ifndef UPB_MEM_ARENA_INTERNAL_H_
#define UPB_MEM_ARENA_INTERNAL_H_
// Must be last.
@ -5700,8 +5754,7 @@ struct upb_Arena {
#endif
#endif /* UPB_INTERNAL_ARENA_H_ */
#endif /* UPB_MEM_ARENA_INTERNAL_H_ */
#include "third_party/utf8_range/utf8_range.h"
// Must be last.
@ -5872,7 +5925,7 @@ UPB_INLINE void _upb_Decoder_PopLimit(upb_Decoder* d, const char* ptr,
}
#endif /* UPB_INTERNAL_DECODE_H_ */
#endif /* UPB_WIRE_DECODE_INTERNAL_H_ */
#ifndef UPB_JSON_DECODE_H_
#define UPB_JSON_DECODE_H_
@ -6655,8 +6708,32 @@ size_t upb_JsonEncode(const upb_Message* msg, const upb_MessageDef* m,
#endif /* UPB_JSONENCODE_H_ */
#ifndef UPB_INTERNAL_ENCODE_H_
#define UPB_INTERNAL_ENCODE_H_
#ifndef UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#define UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#include <stdio.h>
// Must be last.
UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt,
va_list ap) {
#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
// The msvc runtime has a non-conforming vsnprintf() that requires the
// following compatibility code to become conformant.
int n = -1;
if (size != 0) n = _vsnprintf_s(buf, size, _TRUNCATE, fmt, ap);
if (n == -1) n = _vscprintf(fmt, ap);
return n;
#else
return vsnprintf(buf, size, fmt, ap);
#endif
}
#endif // UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#ifndef UPB_WIRE_ENCODE_INTERNAL_H_
#define UPB_WIRE_ENCODE_INTERNAL_H_
// Must be last.
@ -6679,37 +6756,27 @@ void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size);
#endif
#endif /* UPB_INTERNAL_ENCODE_H_ */
#endif /* UPB_WIRE_ENCODE_INTERNAL_H_ */
#ifndef UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#define UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#ifndef UPB_MINI_TABLE_COMMON_H_
#define UPB_MINI_TABLE_COMMON_H_
#include <stdio.h>
// Must be last.
UPB_INLINE int _upb_vsnprintf(char* buf, size_t size, const char* fmt,
va_list ap) {
#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
// The msvc runtime has a non-conforming vsnprintf() that requires the
// following compatibility code to become conformant.
int n = -1;
if (size != 0) n = _vsnprintf_s(buf, size, _TRUNCATE, fmt, ap);
if (n == -1) n = _vscprintf(fmt, ap);
return n;
#else
return vsnprintf(buf, size, fmt, ap);
#endif
}
#endif // UPB_INTERNAL_VSNPRINTF_COMPAT_H_
#ifndef UPB_MINI_TABLE_H_
#define UPB_MINI_TABLE_H_
typedef enum {
kUpb_FieldModifier_IsRepeated = 1 << 0,
kUpb_FieldModifier_IsPacked = 1 << 1,
kUpb_FieldModifier_IsClosedEnum = 1 << 2,
kUpb_FieldModifier_IsProto3Singular = 1 << 3,
kUpb_FieldModifier_IsRequired = 1 << 4,
} kUpb_FieldModifier;
// Must be last.
typedef enum {
kUpb_MessageModifier_ValidateUtf8 = 1 << 0,
kUpb_MessageModifier_DefaultIsPacked = 1 << 1,
kUpb_MessageModifier_IsExtendable = 1 << 2,
} kUpb_MessageModifier;
#ifdef __cplusplus
extern "C" {
@ -6730,81 +6797,112 @@ UPB_INLINE const upb_MiniTable_Enum* upb_MiniTable_GetSubEnumTable(
return mini_table->subs[field->submsg_index].subenum;
}
/** upb_MtDataEncoder *********************************************************/
#ifdef __cplusplus
} /* extern "C" */
#endif
// Functions to encode a string in a format that can be loaded by
// upb_MiniTable_Build().
#endif /* UPB_MINI_TABLE_COMMON_H_ */
#ifndef UPB_MINI_TABLE_COMMON_INTERNAL_H_
#define UPB_MINI_TABLE_COMMON_INTERNAL_H_
// Must be last.
typedef enum {
kUpb_MessageModifier_ValidateUtf8 = 1 << 0,
kUpb_MessageModifier_DefaultIsPacked = 1 << 1,
kUpb_MessageModifier_IsExtendable = 1 << 2,
} kUpb_MessageModifier;
kUpb_EncodedType_Double = 0,
kUpb_EncodedType_Float = 1,
kUpb_EncodedType_Fixed32 = 2,
kUpb_EncodedType_Fixed64 = 3,
kUpb_EncodedType_SFixed32 = 4,
kUpb_EncodedType_SFixed64 = 5,
kUpb_EncodedType_Int32 = 6,
kUpb_EncodedType_UInt32 = 7,
kUpb_EncodedType_SInt32 = 8,
kUpb_EncodedType_Int64 = 9,
kUpb_EncodedType_UInt64 = 10,
kUpb_EncodedType_SInt64 = 11,
kUpb_EncodedType_OpenEnum = 12,
kUpb_EncodedType_Bool = 13,
kUpb_EncodedType_Bytes = 14,
kUpb_EncodedType_String = 15,
kUpb_EncodedType_Group = 16,
kUpb_EncodedType_Message = 17,
kUpb_EncodedType_ClosedEnum = 18,
kUpb_EncodedType_RepeatedBase = 20,
} upb_EncodedType;
typedef enum {
kUpb_FieldModifier_IsRepeated = 1 << 0,
kUpb_FieldModifier_IsPacked = 1 << 1,
kUpb_FieldModifier_IsClosedEnum = 1 << 2,
kUpb_FieldModifier_IsProto3Singular = 1 << 3,
kUpb_FieldModifier_IsRequired = 1 << 4,
} kUpb_FieldModifier;
kUpb_EncodedFieldModifier_FlipPacked = 1 << 0,
// upb only.
kUpb_EncodedFieldModifier_IsProto3Singular = 1 << 2,
kUpb_EncodedFieldModifier_IsRequired = 1 << 3,
} upb_EncodedFieldModifier;
typedef struct {
char* end; // Limit of the buffer passed as a parameter.
// Aliased to internal-only members in .cc.
char internal[32];
} upb_MtDataEncoder;
enum {
kUpb_EncodedValue_MinField = ' ',
kUpb_EncodedValue_MaxField = 'I',
kUpb_EncodedValue_MinModifier = 'L',
kUpb_EncodedValue_MaxModifier = '[',
kUpb_EncodedValue_End = '^',
kUpb_EncodedValue_MinSkip = '_',
kUpb_EncodedValue_MaxSkip = '~',
kUpb_EncodedValue_OneofSeparator = '~',
kUpb_EncodedValue_FieldSeparator = '|',
kUpb_EncodedValue_MinOneofField = ' ',
kUpb_EncodedValue_MaxOneofField = 'b',
kUpb_EncodedValue_MaxEnumMask = 'A',
};
// If the input buffer has at least this many bytes available, the encoder call
// is guaranteed to succeed (as long as field number order is maintained).
#define kUpb_MtDataEncoder_MinSize 16
enum {
kUpb_EncodedVersion_EnumV1 = '!',
kUpb_EncodedVersion_ExtensionV1 = '#',
kUpb_EncodedVersion_MapV1 = '%',
kUpb_EncodedVersion_MessageV1 = '$',
kUpb_EncodedVersion_MessageSetV1 = '&',
};
// Encodes field/oneof information for a given message. The sequence of calls
// should look like:
//
// upb_MtDataEncoder e;
// char buf[256];
// char* ptr = buf;
// e.end = ptr + sizeof(buf);
// unit64_t msg_mod = ...; // bitwise & of kUpb_MessageModifiers or zero
// ptr = upb_MtDataEncoder_StartMessage(&e, ptr, msg_mod);
// // Fields *must* be in field number order.
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
//
// // If oneofs are present. Oneofs must be encoded after regular fields.
// ptr = upb_MiniTable_StartOneof(&e, ptr)
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
//
// ptr = upb_MiniTable_StartOneof(&e, ptr);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
//
// Oneofs must be encoded after all regular fields.
char* upb_MtDataEncoder_StartMessage(upb_MtDataEncoder* e, char* ptr,
uint64_t msg_mod);
char* upb_MtDataEncoder_PutField(upb_MtDataEncoder* e, char* ptr,
upb_FieldType type, uint32_t field_num,
uint64_t field_mod);
char* upb_MtDataEncoder_StartOneof(upb_MtDataEncoder* e, char* ptr);
char* upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder* e, char* ptr,
uint32_t field_num);
#ifdef __cplusplus
extern "C" {
#endif
// Encodes the set of values for a given enum. The values must be given in
// order (after casting to uint32_t), and repeats are not allowed.
char* upb_MtDataEncoder_StartEnum(upb_MtDataEncoder* e, char* ptr);
char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr,
uint32_t val);
char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr);
UPB_INLINE char _upb_ToBase92(int8_t ch) {
extern const char _kUpb_ToBase92[];
UPB_ASSERT(0 <= ch && ch < 92);
return _kUpb_ToBase92[ch];
}
// Encodes an entire mini descriptor for one extension.
char* upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder* e, char* ptr,
upb_FieldType type, uint32_t field_num,
uint64_t field_mod);
UPB_INLINE char _upb_FromBase92(uint8_t ch) {
extern const int8_t _kUpb_FromBase92[];
if (' ' > ch || ch > '~') return -1;
return _kUpb_FromBase92[ch - ' '];
}
/** upb_MiniTable *************************************************************/
UPB_INLINE bool _upb_FieldType_IsPackable(upb_FieldType type) {
// clang-format off
const unsigned kUnpackableTypes =
(1 << kUpb_FieldType_String) |
(1 << kUpb_FieldType_Bytes) |
(1 << kUpb_FieldType_Message) |
(1 << kUpb_FieldType_Group);
// clang-format on
return (1 << type) & ~kUnpackableTypes;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_COMMON_INTERNAL_H_ */
#ifndef UPB_MINI_TABLE_DECODE_H_
#define UPB_MINI_TABLE_DECODE_H_
// Must be last.
typedef enum {
kUpb_MiniTablePlatform_32Bit,
@ -6813,6 +6911,10 @@ typedef enum {
UPB_SIZE(kUpb_MiniTablePlatform_32Bit, kUpb_MiniTablePlatform_64Bit),
} upb_MiniTablePlatform;
#ifdef __cplusplus
extern "C" {
#endif
// Builds a mini table from the data encoded in the buffer [data, len]. If any
// errors occur, returns NULL and sets a status message. In the success case,
// the caller must call upb_MiniTable_SetSub*() for all message or proto2 enum
@ -6842,15 +6944,6 @@ const char* upb_MiniTable_BuildExtension(const char* data, size_t len,
upb_MiniTable_Sub sub,
upb_Status* status);
// Special-case functions for MessageSet layout and map entries.
upb_MiniTable* upb_MiniTable_BuildMessageSet(upb_MiniTablePlatform platform,
upb_Arena* arena);
upb_MiniTable* upb_MiniTable_BuildMapEntry(upb_FieldType key_type,
upb_FieldType value_type,
bool value_is_proto3_enum,
upb_MiniTablePlatform platform,
upb_Arena* arena);
upb_MiniTable_Enum* upb_MiniTable_BuildEnum(const char* data, size_t len,
upb_Arena* arena,
upb_Status* status);
@ -6866,17 +6959,92 @@ upb_MiniTable* upb_MiniTable_BuildWithBuf(const char* data, size_t len,
upb_Arena* arena, void** buf,
size_t* buf_size, upb_Status* status);
// For testing only.
char upb_ToBase92(int8_t ch);
char upb_FromBase92(uint8_t ch);
bool upb_IsTypePackable(upb_FieldType type);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_DECODE_H_ */
#ifndef UPB_MINI_TABLE_ENCODE_INTERNAL_H_
#define UPB_MINI_TABLE_ENCODE_INTERNAL_H_
// Must be last.
// If the input buffer has at least this many bytes available, the encoder call
// is guaranteed to succeed (as long as field number order is maintained).
#define kUpb_MtDataEncoder_MinSize 16
typedef struct {
char* end; // Limit of the buffer passed as a parameter.
// Aliased to internal-only members in .cc.
char internal[32];
} upb_MtDataEncoder;
#ifdef __cplusplus
extern "C" {
#endif
// Encodes field/oneof information for a given message. The sequence of calls
// should look like:
//
// upb_MtDataEncoder e;
// char buf[256];
// char* ptr = buf;
// e.end = ptr + sizeof(buf);
// unit64_t msg_mod = ...; // bitwise & of kUpb_MessageModifiers or zero
// ptr = upb_MtDataEncoder_StartMessage(&e, ptr, msg_mod);
// // Fields *must* be in field number order.
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
// ptr = upb_MtDataEncoder_PutField(&e, ptr, ...);
//
// // If oneofs are present. Oneofs must be encoded after regular fields.
// ptr = upb_MiniTable_StartOneof(&e, ptr)
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
//
// ptr = upb_MiniTable_StartOneof(&e, ptr);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
// ptr = upb_MiniTable_PutOneofField(&e, ptr, ...);
//
// Oneofs must be encoded after all regular fields.
char* upb_MtDataEncoder_StartMessage(upb_MtDataEncoder* e, char* ptr,
uint64_t msg_mod);
char* upb_MtDataEncoder_PutField(upb_MtDataEncoder* e, char* ptr,
upb_FieldType type, uint32_t field_num,
uint64_t field_mod);
char* upb_MtDataEncoder_StartOneof(upb_MtDataEncoder* e, char* ptr);
char* upb_MtDataEncoder_PutOneofField(upb_MtDataEncoder* e, char* ptr,
uint32_t field_num);
// Encodes the set of values for a given enum. The values must be given in
// order (after casting to uint32_t), and repeats are not allowed.
char* upb_MtDataEncoder_StartEnum(upb_MtDataEncoder* e, char* ptr);
char* upb_MtDataEncoder_PutEnumValue(upb_MtDataEncoder* e, char* ptr,
uint32_t val);
char* upb_MtDataEncoder_EndEnum(upb_MtDataEncoder* e, char* ptr);
// Encodes an entire mini descriptor for an extension.
char* upb_MtDataEncoder_EncodeExtension(upb_MtDataEncoder* e, char* ptr,
upb_FieldType type, uint32_t field_num,
uint64_t field_mod);
// Encodes an entire mini descriptor for a map.
char* upb_MtDataEncoder_EncodeMap(upb_MtDataEncoder* e, char* ptr,
upb_FieldType key_type,
upb_FieldType value_type, uint64_t value_mod);
// Encodes an entire mini descriptor for a message set.
char* upb_MtDataEncoder_EncodeMessageSet(upb_MtDataEncoder* e, char* ptr);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MINI_TABLE_H_ */
#endif /* UPB_MINI_TABLE_ENCODE_INTERNAL_H_ */
#ifndef UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
#define UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_
@ -7355,70 +7523,6 @@ upb_MethodDef* _upb_MethodDefs_New(
#endif /* UPB_REFLECTION_METHOD_DEF_INTERNAL_H_ */
// EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE /////////////////////////
#ifndef UPB_MAP_SORTER_H_
#define UPB_MAP_SORTER_H_
// Must be last.
#ifdef __cplusplus
extern "C" {
#endif
// _upb_mapsorter sorts maps and provides ordered iteration over the entries.
// Since maps can be recursive (map values can be messages which contain other
// maps), _upb_mapsorter can contain a stack of maps.
typedef struct {
upb_tabent const** entries;
int size;
int cap;
} _upb_mapsorter;
typedef struct {
int start;
int pos;
int end;
} _upb_sortedmap;
UPB_INLINE void _upb_mapsorter_init(_upb_mapsorter* s) {
s->entries = NULL;
s->size = 0;
s->cap = 0;
}
UPB_INLINE void _upb_mapsorter_destroy(_upb_mapsorter* s) {
if (s->entries) free(s->entries);
}
UPB_INLINE bool _upb_sortedmap_next(_upb_mapsorter* s, const upb_Map* map,
_upb_sortedmap* sorted, upb_MapEntry* ent) {
if (sorted->pos == sorted->end) return false;
const upb_tabent* tabent = s->entries[sorted->pos++];
upb_StringView key = upb_tabstrview(tabent->key);
_upb_map_fromkey(key, &ent->k, map->key_size);
upb_value val = {tabent->val.val};
_upb_map_fromvalue(val, &ent->v, map->val_size);
return true;
}
UPB_INLINE void _upb_mapsorter_popmap(_upb_mapsorter* s,
_upb_sortedmap* sorted) {
s->size = sorted->start;
}
bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const upb_Map* map, _upb_sortedmap* sorted);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* UPB_MAP_SORTER_H_ */
/* See port_def.inc. This should #undef all macros #defined there. */
#undef UPB_SIZE

@ -15,7 +15,6 @@ def internal_ruby_extension(
**kwargs: extra arguments to forward to the genrule.
"""
native.genrule(
name = name,
srcs = deps + [
@ -31,5 +30,5 @@ def internal_ruby_extension(
"BAZEL=true rake\n" +
"popd\n" +
"cp `dirname $(location Rakefile)`/%s $(OUTS)\n" % extension,
**kwargs,
**kwargs
)

@ -254,6 +254,8 @@ set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/metadata_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/parse_context.h
${protobuf_SOURCE_DIR}/src/google/protobuf/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/port_def.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/port_undef.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
@ -545,6 +547,8 @@ set(lite_test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_test_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_test_util_impl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/proto3_lite_unittest.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util2.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.h
)
@ -567,8 +571,6 @@ set(test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_tester.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.inc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util2.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.inc
)

@ -5,6 +5,7 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@upb//cmake:build_defs.bzl", "staleness_test")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
package(
@ -106,15 +107,22 @@ WELL_KNOWN_TYPES = [
"wrappers",
]
# When we generate code for the well-known types, we put the resulting files in
# wkt/google/protobuf and add ./wkt to the include paths below. This is a
# somewhat strange setup but is necessary to satisfy these two constraints:
# - We need to keep the checked-in sources for now, since Cocoapods relies on
# them.
# - The Bazel build should always use the generated sources so that developers
# don't have to worry about manually updating the checked-in sources.
genrule(
name = "gen_wkt_cc_sources",
srcs = [wkt + ".proto" for wkt in WELL_KNOWN_TYPES],
outs =
[wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
[wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
["wkt/google/protobuf/" + wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
["wkt/google/protobuf/" + wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
cmd = """
$(execpath //src/google/protobuf/compiler:protoc_nowkt) \
--cpp_out=$(RULEDIR)/../.. \
--cpp_out=dllexport_decl=PROTOBUF_EXPORT:$(RULEDIR)/wkt \
--proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \
$(SRCS)
""",
@ -122,12 +130,21 @@ genrule(
visibility = ["//visibility:private"],
)
staleness_test(
name = "well_known_types_staleness_test",
outs =
[wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
[wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
generated_pattern = "wkt/google/protobuf/%s",
tags = ["manual"],
)
cc_library(
name = "wkt_cc_proto",
srcs = [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
hdrs = [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES],
srcs = ["wkt/google/protobuf/" + wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
hdrs = ["wkt/google/protobuf/" + wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES],
copts = COPTS,
include_prefix = "google/protobuf",
includes = ["wkt"],
linkopts = LINK_OPTS,
visibility = ["//pkg:__pkg__"],
deps = [":protobuf_nowkt"],

@ -45,7 +45,7 @@ static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
static constexpr const ::_pb::ServiceDescriptor**
file_level_service_descriptors_google_2fprotobuf_2fany_2eproto = nullptr;
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) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Any, _internal_metadata_),
@ -208,7 +208,7 @@ void Any::SetCachedSize(int size) const {
void Any::Clear() {
// @@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
(void) cached_has_bits;
@ -221,27 +221,29 @@ const char* Any::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
uint32_t tag;
::uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string type_url = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Any.type_url"));
} else
} else {
goto handle_unusual;
}
continue;
// bytes value = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_value();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
} else {
goto handle_unusual;
}
continue;
default:
goto handle_unusual;
@ -266,11 +268,11 @@ failure:
#undef CHK_
}
uint8_t* Any::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
::uint8_t* Any::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@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;
// string type_url = 1;
@ -297,12 +299,12 @@ uint8_t* Any::_InternalSerialize(
return target;
}
size_t Any::ByteSizeLong() const {
::size_t Any::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)
size_t total_size = 0;
::size_t total_size = 0;
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@ -336,7 +338,7 @@ void Any::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)
GOOGLE_DCHECK_NE(&from, _this);
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_type_url().empty()) {

@ -46,7 +46,7 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
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
descriptor_table_google_2fprotobuf_2fany_2eproto;
@ -189,10 +189,10 @@ class PROTOBUF_EXPORT Any final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() 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;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:

@ -63,6 +63,10 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes";
// if (any.is(Foo.class)) {
// foo = any.unpack(Foo.class);
// }
// // or ...
// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
// foo = any.unpack(Foo.getDefaultInstance());
// }
//
// Example 3: Pack and unpack a message in Python.
//

@ -28,12 +28,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/any.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
namespace google {
namespace protobuf {

@ -28,10 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/any_test.pb.h"
#include "google/protobuf/any.pb.h"
#include "google/protobuf/unittest.pb.h"
#include <gtest/gtest.h>
#include "absl/strings/str_cat.h"
#include "google/protobuf/any_test.pb.h"
// Must be included last.

@ -80,7 +80,7 @@ static constexpr const ::_pb::EnumDescriptor**
file_level_enum_descriptors_google_2fprotobuf_2fapi_2eproto = nullptr;
static constexpr const ::_pb::ServiceDescriptor**
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) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::Api, _internal_metadata_),
@ -311,7 +311,7 @@ void Api::SetCachedSize(int size) const {
void Api::Clear() {
// @@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
(void) cached_has_bits;
@ -332,22 +332,23 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
uint32_t tag;
::uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.name"));
} else
} else {
goto handle_unusual;
}
continue;
// repeated .google.protobuf.Method methods = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
ptr -= 1;
do {
ptr += 1;
@ -355,12 +356,13 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
} else
} else {
goto handle_unusual;
}
continue;
// repeated .google.protobuf.Option options = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
@ -368,30 +370,33 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else
} else {
goto handle_unusual;
}
continue;
// string version = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_version();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Api.version"));
} else
} else {
goto handle_unusual;
}
continue;
// .google.protobuf.SourceContext source_context = 5;
case 5:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 42)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 42)) {
ptr = ctx->ParseMessage(_internal_mutable_source_context(), ptr);
CHK_(ptr);
} else
} else {
goto handle_unusual;
}
continue;
// repeated .google.protobuf.Mixin mixins = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@ -399,17 +404,19 @@ const char* Api::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
} else
} else {
goto handle_unusual;
}
continue;
// .google.protobuf.Syntax syntax = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
} else
} else {
goto handle_unusual;
}
continue;
default:
goto handle_unusual;
@ -434,11 +441,11 @@ failure:
#undef CHK_
}
uint8_t* Api::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
::uint8_t* Api::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@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;
// string name = 1;
@ -507,12 +514,12 @@ uint8_t* Api::_InternalSerialize(
return target;
}
size_t Api::ByteSizeLong() const {
::size_t Api::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api)
size_t total_size = 0;
::size_t total_size = 0;
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@ -580,7 +587,7 @@ void Api::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_N
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api)
GOOGLE_DCHECK_NE(&from, _this);
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.methods_.MergeFrom(from._impl_.methods_);
@ -697,7 +704,7 @@ Method::Method(const Method& from)
_this->GetArenaForAllocation());
}
::memcpy(&_impl_.request_streaming_, &from._impl_.request_streaming_,
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.syntax_) -
static_cast<::size_t>(reinterpret_cast<char*>(&_impl_.syntax_) -
reinterpret_cast<char*>(&_impl_.request_streaming_)) + sizeof(_impl_.syntax_));
// @@protoc_insertion_point(copy_constructor:google.protobuf.Method)
}
@ -753,7 +760,7 @@ void Method::SetCachedSize(int size) const {
void Method::Clear() {
// @@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
(void) cached_has_bits;
@ -761,7 +768,7 @@ void Method::Clear() {
_impl_.name_.ClearToEmpty();
_impl_.request_type_url_.ClearToEmpty();
_impl_.response_type_url_.ClearToEmpty();
::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_.request_streaming_)) + sizeof(_impl_.syntax_));
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
@ -771,58 +778,63 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
uint32_t tag;
::uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.name"));
} else
} else {
goto handle_unusual;
}
continue;
// string request_type_url = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_request_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.request_type_url"));
} else
} else {
goto handle_unusual;
}
continue;
// bool request_streaming = 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);
CHK_(ptr);
} else
} else {
goto handle_unusual;
}
continue;
// string response_type_url = 4;
case 4:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 34)) {
auto str = _internal_mutable_response_type_url();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Method.response_type_url"));
} else
} else {
goto handle_unusual;
}
continue;
// bool response_streaming = 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);
CHK_(ptr);
} else
} else {
goto handle_unusual;
}
continue;
// repeated .google.protobuf.Option options = 6;
case 6:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 50)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 50)) {
ptr -= 1;
do {
ptr += 1;
@ -830,17 +842,19 @@ const char* Method::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<50>(ptr));
} else
} else {
goto handle_unusual;
}
continue;
// .google.protobuf.Syntax syntax = 7;
case 7:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 56)) {
uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 56)) {
::uint32_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
_internal_set_syntax(static_cast<::PROTOBUF_NAMESPACE_ID::Syntax>(val));
} else
} else {
goto handle_unusual;
}
continue;
default:
goto handle_unusual;
@ -865,11 +879,11 @@ failure:
#undef CHK_
}
uint8_t* Method::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
::uint8_t* Method::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@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;
// string name = 1;
@ -937,12 +951,12 @@ uint8_t* Method::_InternalSerialize(
return target;
}
size_t Method::ByteSizeLong() const {
::size_t Method::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method)
size_t total_size = 0;
::size_t total_size = 0;
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@ -1006,7 +1020,7 @@ void Method::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBU
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method)
GOOGLE_DCHECK_NE(&from, _this);
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
_this->_impl_.options_.MergeFrom(from._impl_.options_);
@ -1154,7 +1168,7 @@ void Mixin::SetCachedSize(int size) const {
void Mixin::Clear() {
// @@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
(void) cached_has_bits;
@ -1167,28 +1181,30 @@ const char* Mixin::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
uint32_t tag;
::uint32_t tag;
ptr = ::_pbi::ReadTag(ptr, &tag);
switch (tag >> 3) {
// string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 10)) {
auto str = _internal_mutable_name();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.name"));
} else
} else {
goto handle_unusual;
}
continue;
// string root = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
if (PROTOBUF_PREDICT_TRUE(static_cast<::uint8_t>(tag) == 18)) {
auto str = _internal_mutable_root();
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
CHK_(::_pbi::VerifyUTF8(str, "google.protobuf.Mixin.root"));
} else
} else {
goto handle_unusual;
}
continue;
default:
goto handle_unusual;
@ -1213,11 +1229,11 @@ failure:
#undef CHK_
}
uint8_t* Mixin::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
::uint8_t* Mixin::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@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;
// string name = 1;
@ -1248,12 +1264,12 @@ uint8_t* Mixin::_InternalSerialize(
return target;
}
size_t Mixin::ByteSizeLong() const {
::size_t Mixin::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin)
size_t total_size = 0;
::size_t total_size = 0;
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@ -1287,7 +1303,7 @@ void Mixin::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin)
GOOGLE_DCHECK_NE(&from, _this);
uint32_t cached_has_bits = 0;
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (!from._internal_name().empty()) {

@ -48,7 +48,7 @@ PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fapi_2eproto {
static const uint32_t offsets[];
static const ::uint32_t offsets[];
};
PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable
descriptor_table_google_2fprotobuf_2fapi_2eproto;
@ -166,10 +166,10 @@ class PROTOBUF_EXPORT Api final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() 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;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
@ -425,10 +425,10 @@ class PROTOBUF_EXPORT Method final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() 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;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:
@ -662,10 +662,10 @@ class PROTOBUF_EXPORT Mixin final :
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() 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;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
::uint8_t* _InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _impl_._cached_size_.Get(); }
private:

@ -114,53 +114,35 @@ void arena_delete_object(void* object) {
struct ArenaOptions {
// This defines the size of the first block requested from the system malloc.
// Subsequent block sizes will increase in a geometric series up to a maximum.
size_t start_block_size;
size_t start_block_size = internal::AllocationPolicy::kDefaultStartBlockSize;
// This defines the maximum block size requested from system malloc (unless an
// individual arena allocation request occurs with a size larger than this
// maximum). Requested block sizes increase up to this value, then remain
// here.
size_t max_block_size;
size_t max_block_size = internal::GetDefaultArenaMaxBlockSize();
// An initial block of memory for the arena to use, or nullptr for none. If
// provided, the block must live at least as long as the arena itself. The
// creator of the Arena retains ownership of the block after the Arena is
// destroyed.
char* initial_block;
char* initial_block = nullptr;
// The size of the initial block, if provided.
size_t initial_block_size;
size_t initial_block_size = 0;
// A function pointer to an alloc method that returns memory blocks of size
// requested. By default, it contains a ptr to the malloc function.
//
// NOTE: block_alloc and dealloc functions are expected to behave like
// malloc and free, including Asan poisoning.
void* (*block_alloc)(size_t);
void* (*block_alloc)(size_t) = nullptr;
// A function pointer to a dealloc method that takes ownership of the blocks
// from the arena. By default, it contains a ptr to a wrapper function that
// calls free.
void (*block_dealloc)(void*, size_t);
ArenaOptions()
: start_block_size(internal::AllocationPolicy::kDefaultStartBlockSize),
max_block_size(internal::GetDefaultArenaMaxBlockSize()),
initial_block(nullptr),
initial_block_size(0),
block_alloc(nullptr),
block_dealloc(nullptr),
make_metrics_collector(nullptr) {}
void (*block_dealloc)(void*, size_t) = nullptr;
private:
// If make_metrics_collector is not nullptr, it will be called at Arena init
// time. It may return a pointer to a collector instance that will be notified
// of interesting events related to the arena.
internal::ArenaMetricsCollector* (*make_metrics_collector)();
internal::ArenaMetricsCollector* MetricsCollector() const {
return make_metrics_collector ? (*make_metrics_collector)() : nullptr;
}
internal::AllocationPolicy AllocationPolicy() const {
internal::AllocationPolicy res;
res.start_block_size = start_block_size;
@ -170,8 +152,6 @@ struct ArenaOptions {
return res;
}
friend void arena_metrics::EnableArenaMetrics(ArenaOptions*);
friend class Arena;
friend class ArenaOptionsTestFriend;
};

@ -42,7 +42,6 @@
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_arena.pb.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
@ -56,6 +55,7 @@
#include "google/protobuf/message_lite.h"
#include "google/protobuf/repeated_field.h"
#include "google/protobuf/test_util.h"
#include "google/protobuf/unittest_arena.pb.h"
#include "google/protobuf/unknown_field_set.h"
#include "google/protobuf/wire_format_lite.h"

@ -34,9 +34,9 @@
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/io/coded_stream.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/message_lite.h"
#include "google/protobuf/parse_context.h"

@ -39,12 +39,12 @@
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/message_lite.h"
#include <gtest/gtest.h>
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
// Must be included last.

@ -60,6 +60,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
],
)
@ -245,9 +247,9 @@ cc_test(
":command_line_interface",
":mock_code_generator",
"//:protobuf",
"//src/google/protobuf/compiler/cpp:names",
"//src/google/protobuf:cc_test_protos",
"//src/google/protobuf:test_util2",
"//src/google/protobuf/compiler/cpp:names",
"//src/google/protobuf/io",
"//src/google/protobuf/stubs",
"//src/google/protobuf/testing",

@ -37,12 +37,12 @@
#include "google/protobuf/testing/file.h"
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/command_line_interface.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
namespace google {
namespace protobuf {

@ -34,7 +34,7 @@
#include "google/protobuf/compiler/command_line_interface.h"
#include "absl/container/btree_map.h"
#include "absl/container/btree_set.h"
#include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/platform_macros.h"
@ -806,95 +806,95 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
}
it->second.swap(data_);
} else {
// This was an OpenForInsert().
return;
}
// This was an OpenForInsert().
// If the data doesn't end with a clean line break, add one.
if (!data_.empty() && data_[data_.size() - 1] != '\n') {
data_.push_back('\n');
}
// If the data doesn't end with a clean line break, add one.
if (!data_.empty() && data_[data_.size() - 1] != '\n') {
data_.push_back('\n');
}
// Find the file we are going to insert into.
if (!already_present) {
std::cerr << filename_
<< ": Tried to insert into file that doesn't exist."
<< std::endl;
directory_->had_error_ = true;
return;
}
std::string* target = &it->second;
// Find the file we are going to insert into.
if (!already_present) {
std::cerr << filename_ << ": Tried to insert into file that doesn't exist."
<< std::endl;
directory_->had_error_ = true;
return;
}
std::string* target = &it->second;
// Find the insertion point.
std::string magic_string =
absl::Substitute("@@protoc_insertion_point($0)", insertion_point_);
std::string::size_type pos = target->find(magic_string);
// Find the insertion point.
std::string magic_string =
absl::Substitute("@@protoc_insertion_point($0)", insertion_point_);
std::string::size_type pos = target->find(magic_string);
if (pos == std::string::npos) {
std::cerr << filename_ << ": insertion point \"" << insertion_point_
<< "\" not found." << std::endl;
directory_->had_error_ = true;
return;
}
if (pos == std::string::npos) {
std::cerr << filename_ << ": insertion point \"" << insertion_point_
<< "\" not found." << std::endl;
directory_->had_error_ = true;
return;
}
if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
// Support for inline "/* @@protoc_insertion_point() */"
pos = pos - 3;
if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
// Support for inline "/* @@protoc_insertion_point() */"
pos = pos - 3;
} else {
// Seek backwards to the beginning of the line, which is where we will
// insert the data. Note that this has the effect of pushing the
// insertion point down, so the data is inserted before it. This is
// intentional because it means that multiple insertions at the same point
// will end up in the expected order in the final output.
pos = target->find_last_of('\n', pos);
if (pos == std::string::npos) {
// Insertion point is on the first line.
pos = 0;
} else {
// Seek backwards to the beginning of the line, which is where we will
// insert the data. Note that this has the effect of pushing the
// insertion point down, so the data is inserted before it. This is
// intentional because it means that multiple insertions at the same point
// will end up in the expected order in the final output.
pos = target->find_last_of('\n', pos);
if (pos == std::string::npos) {
// Insertion point is on the first line.
pos = 0;
} else {
// Advance to character after '\n'.
++pos;
}
// Advance to character after '\n'.
++pos;
}
}
// Extract indent.
std::string indent_(*target, pos,
target->find_first_not_of(" \t", pos) - pos);
// Extract indent.
std::string indent_(*target, pos,
target->find_first_not_of(" \t", pos) - pos);
if (indent_.empty()) {
// No indent. This makes things easier.
target->insert(pos, data_);
UpdateMetadata(data_, pos, data_.size(), 0);
} else {
// Calculate how much space we need.
int indent_size = 0;
for (int i = 0; i < data_.size(); i++) {
if (data_[i] == '\n') indent_size += indent_.size();
}
if (indent_.empty()) {
// No indent. This makes things easier.
target->insert(pos, data_);
UpdateMetadata(data_, pos, data_.size(), 0);
return;
}
// Calculate how much space we need.
int indent_size = 0;
for (int i = 0; i < data_.size(); i++) {
if (data_[i] == '\n') indent_size += indent_.size();
}
// Make a hole for it.
target->insert(pos, data_.size() + indent_size, '\0');
// Now copy in the data.
std::string::size_type data_pos = 0;
char* target_ptr = &(*target)[pos];
while (data_pos < data_.size()) {
// Copy indent.
memcpy(target_ptr, indent_.data(), indent_.size());
target_ptr += indent_.size();
// Copy line from data_.
// We already guaranteed that data_ ends with a newline (above), so this
// search can't fail.
std::string::size_type line_length =
data_.find_first_of('\n', data_pos) + 1 - data_pos;
memcpy(target_ptr, data_.data() + data_pos, line_length);
target_ptr += line_length;
data_pos += line_length;
}
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
// Make a hole for it.
target->insert(pos, data_.size() + indent_size, '\0');
GOOGLE_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size);
}
// Now copy in the data.
std::string::size_type data_pos = 0;
char* target_ptr = &(*target)[pos];
while (data_pos < data_.size()) {
// Copy indent.
memcpy(target_ptr, indent_.data(), indent_.size());
target_ptr += indent_.size();
// Copy line from data_.
// We already guaranteed that data_ ends with a newline (above), so this
// search can't fail.
std::string::size_type line_length =
data_.find_first_of('\n', data_pos) + 1 - data_pos;
memcpy(target_ptr, data_.data() + data_pos, line_length);
target_ptr += line_length;
data_pos += line_length;
}
GOOGLE_CHECK_EQ(target_ptr, &(*target)[pos] + data_.size() + indent_size);
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
}
// ===================================================================
@ -2212,7 +2212,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile(
DiskSourceTree* source_tree) {
FileDescriptorSet file_set;
std::set<const FileDescriptor*> already_seen;
absl::flat_hash_set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i], false, false, &already_seen,
file_set.mutable_file());
@ -2293,7 +2293,7 @@ bool CommandLineInterface::GeneratePluginOutput(
}
std::set<const FileDescriptor*> already_seen;
absl::flat_hash_set<const FileDescriptor*> already_seen;
for (int i = 0; i < parsed_files.size(); i++) {
request.add_file_to_generate(parsed_files[i]->name());
GetTransitiveDependencies(parsed_files[i],
@ -2442,13 +2442,13 @@ bool CommandLineInterface::WriteDescriptorSet(
const std::vector<const FileDescriptor*>& parsed_files) {
FileDescriptorSet file_set;
std::set<const FileDescriptor*> already_seen;
absl::flat_hash_set<const FileDescriptor*> already_seen;
if (!imports_in_descriptor_set_) {
// Since we don't want to output transitive dependencies, but we do want
// things to be in dependency order, add all dependencies that aren't in
// parsed_files to already_seen. This will short circuit the recursion
// in GetTransitiveDependencies.
std::set<const FileDescriptor*> to_output;
absl::flat_hash_set<const FileDescriptor*> to_output;
to_output.insert(parsed_files.begin(), parsed_files.end());
for (int i = 0; i < parsed_files.size(); i++) {
const FileDescriptor* file = parsed_files[i];
@ -2506,7 +2506,7 @@ bool CommandLineInterface::WriteDescriptorSet(
void CommandLineInterface::GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
bool include_source_code_info,
std::set<const FileDescriptor*>* already_seen,
absl::flat_hash_set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output) {
if (!already_seen->insert(file).second) {
// Already saw this file. Skip.
@ -2579,9 +2579,9 @@ namespace {
// order of the nested messages is also preserved.
typedef std::pair<int, int> FieldRange;
void GatherOccupiedFieldRanges(
const Descriptor* descriptor, std::set<FieldRange>* ranges,
const Descriptor* descriptor, absl::btree_set<FieldRange>* ranges,
std::vector<const Descriptor*>* nested_messages) {
std::set<const Descriptor*> groups;
absl::flat_hash_set<const Descriptor*> groups;
for (int i = 0; i < descriptor->field_count(); ++i) {
const FieldDescriptor* fd = descriptor->field(i);
ranges->insert(FieldRange(fd->number(), fd->number() + 1));
@ -2613,27 +2613,26 @@ void GatherOccupiedFieldRanges(
// Actually prints the formatted free field numbers for given message name and
// occupied ranges.
void FormatFreeFieldNumbers(const std::string& name,
const std::set<FieldRange>& ranges) {
const absl::btree_set<FieldRange>& ranges) {
std::string output;
absl::StrAppendFormat(&output, "%-35s free:", name.c_str());
int next_free_number = 1;
for (std::set<FieldRange>::const_iterator i = ranges.begin();
i != ranges.end(); ++i) {
for (const auto& range : ranges) {
// This happens when groups re-use parent field numbers, in which
// case we skip the FieldRange entirely.
if (next_free_number >= i->second) continue;
if (next_free_number >= range.second) continue;
if (next_free_number < i->first) {
if (next_free_number + 1 == i->first) {
if (next_free_number < range.first) {
if (next_free_number + 1 == range.first) {
// Singleton
absl::StrAppendFormat(&output, " %d", next_free_number);
} else {
// Range
absl::StrAppendFormat(&output, " %d-%d", next_free_number,
i->first - 1);
range.first - 1);
}
}
next_free_number = i->second;
next_free_number = range.second;
}
if (next_free_number <= FieldDescriptor::kMaxNumber) {
absl::StrAppendFormat(&output, " %d-INF", next_free_number);
@ -2644,7 +2643,7 @@ void FormatFreeFieldNumbers(const std::string& name,
} // namespace
void CommandLineInterface::PrintFreeFieldNumbers(const Descriptor* descriptor) {
std::set<FieldRange> ranges;
absl::btree_set<FieldRange> ranges;
std::vector<const Descriptor*> nested_messages;
GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);

@ -40,13 +40,12 @@
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "absl/container/btree_map.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/strings/string_view.h"
@ -322,7 +321,7 @@ class PROTOC_EXPORT CommandLineInterface {
static void GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
bool include_source_code_info,
std::set<const FileDescriptor*>* already_seen,
absl::flat_hash_set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output);
// Implements the --print_free_field_numbers. This function prints free field
@ -360,9 +359,8 @@ class PROTOC_EXPORT CommandLineInterface {
const GeneratorInfo* FindGeneratorByFlag(const std::string& name) const;
const GeneratorInfo* FindGeneratorByOption(const std::string& option) const;
using GeneratorMap = std::map<std::string, GeneratorInfo>;
GeneratorMap generators_by_flag_name_;
GeneratorMap generators_by_option_name_;
absl::btree_map<std::string, GeneratorInfo> generators_by_flag_name_;
absl::flat_hash_map<std::string, GeneratorInfo> generators_by_option_name_;
// A map from generator names to the parameters specified using the option
// flag. For example, if the user invokes the compiler with:
// protoc --foo_out=outputdir --foo_opt=enable_bar ...
@ -412,7 +410,7 @@ class PROTOC_EXPORT CommandLineInterface {
// Names of proto files which are allowed to be imported. Used by build
// systems to enforce depend-on-what-you-import.
std::set<std::string> direct_dependencies_;
absl::flat_hash_set<std::string> direct_dependencies_;
bool direct_dependencies_explicitly_set_ = false;
// If there's a violation of depend-on-what-you-import, this string will be

@ -51,9 +51,7 @@
#include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/any.pb.h"
#include "google/protobuf/test_util2.h"
#include "google/protobuf/unittest.pb.h"
#include "google/protobuf/unittest_custom_options.pb.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
@ -64,12 +62,14 @@
#include "absl/strings/substitute.h"
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/command_line_interface.h"
#include "google/protobuf/compiler/cpp/names.h"
#include "google/protobuf/compiler/mock_code_generator.h"
#include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/cpp/names.h"
#include "google/protobuf/io/io_win32.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/test_util2.h"
#include "google/protobuf/unittest_custom_options.pb.h"
// Must be included last.
#include "google/protobuf/port_def.inc"

@ -79,6 +79,7 @@ cc_library(
visibility = [
"//pkg:__pkg__",
"//src/google/protobuf/compiler:__pkg__",
"@io_kythe//kythe/cxx/tools:__subpackages__",
],
deps = [
":names_internal",

@ -42,13 +42,13 @@
// "generate_descriptor_proto.sh" and add
// descriptor.pb.{h,cc} to your changelist.
#include <memory>
#include <string>
#include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/compiler/cpp/generator.h"
#include "google/protobuf/compiler/importer.h"
#include "google/protobuf/test_util2.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/testing/googletest.h"
@ -56,6 +56,7 @@
#include "absl/container/flat_hash_map.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/test_util2.h"
namespace google {
namespace protobuf {
@ -123,7 +124,7 @@ class MockGeneratorContext : public GeneratorContext {
}
private:
std::map<std::string, std::unique_ptr<std::string>> files_;
absl::flat_hash_map<std::string, std::unique_ptr<std::string>> files_;
};
const char kDescriptorParameter[] = "dllexport_decl=PROTOBUF_EXPORT";

@ -35,7 +35,6 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
#include <set>
#include <string>
#include "google/protobuf/descriptor.h"

@ -36,10 +36,10 @@
#include <string>
#include "google/protobuf/wire_format.h"
#include "absl/container/flat_hash_map.h"
#include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/wire_format.h"
namespace google {
namespace protobuf {

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

Loading…
Cancel
Save