Merge tag 'refs/tags/sync-piper' into sync-stage

pull/10623/head
Mike Kruskal 2 years ago
commit 634a49adf3
  1. 31
      .github/workflows/generated_cmake.yml
  2. 10
      BUILD.bazel
  3. 5
      CHANGES.txt
  4. 9
      CMakeLists.txt
  5. 2
      Protobuf.podspec
  6. 2
      conformance/README.md
  7. 2
      csharp/Google.Protobuf.Tools.nuspec
  8. 10
      csharp/src/Google.Protobuf.Test/JsonParserTest.cs
  9. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  10. 16
      csharp/src/Google.Protobuf/JsonParser.cs
  11. 8
      csharp/src/Google.Protobuf/Reflection/Descriptor.cs
  12. 4
      docs/options.md
  13. 1
      examples/.bazelrc
  14. 6
      java/README.md
  15. 2
      java/bom/pom.xml
  16. 2
      java/core/pom.xml
  17. 25
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  18. 3
      java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
  19. 2
      java/kotlin-lite/pom.xml
  20. 2
      java/kotlin/pom.xml
  21. 2
      java/lite.md
  22. 2
      java/lite/pom.xml
  23. 2
      java/pom.xml
  24. 2
      java/util/pom.xml
  25. 11
      kokoro/linux/32-bit/test_php.sh
  26. 2
      kokoro/linux/bazel/common.cfg
  27. 2
      kokoro/linux/cmake/build.sh
  28. 3
      kokoro/macos/ruby31/build.sh
  29. 4
      kokoro/release/ruby/macos/ruby/ruby_build_environment.sh
  30. 2
      kokoro/windows/bazel/build.bat
  31. 5
      kokoro/windows/cmake/build.bat
  32. 4
      kokoro/windows/cmake_install/build.bat
  33. 4
      kokoro/windows/cmake_nmake/build.bat
  34. 4
      kokoro/windows/cmake_shared/build.bat
  35. 5
      objectivec/GPBCodedInputStream.h
  36. 6
      objectivec/GPBCodedInputStream.m
  37. 4
      objectivec/GPBCodedInputStream_PackagePrivate.h
  38. 4
      objectivec/GPBDictionary.m
  39. 4
      objectivec/GPBDictionary_PackagePrivate.h
  40. 4
      objectivec/GPBExtensionInternals.h
  41. 6
      objectivec/GPBExtensionInternals.m
  42. 32
      objectivec/GPBExtensionRegistry.h
  43. 14
      objectivec/GPBMessage.h
  44. 24
      objectivec/GPBMessage.m
  45. 4
      objectivec/GPBMessage_PackagePrivate.h
  46. 23
      php/ext/google/protobuf/package.xml
  47. 2
      php/ext/google/protobuf/protobuf.h
  48. 4
      php/generate_descriptor_protos.sh
  49. 4
      php/generate_test_protos.sh
  50. 24
      php/src/Google/Protobuf/Internal/MessageOptions.php
  51. 3
      pkg/BUILD.bazel
  52. 6
      protobuf_version.bzl
  53. 2
      protoc-artifacts/pom.xml
  54. 3
      python/google/protobuf/json_format.py
  55. 5
      python/google/protobuf/pyext/message.cc
  56. 2
      python/google/protobuf/text_format.py
  57. 2
      ruby/google-protobuf.gemspec
  58. 4
      ruby/pom.xml
  59. 39
      src/file_lists.cmake
  60. 92
      src/google/protobuf/BUILD.bazel
  61. 2
      src/google/protobuf/any.pb.h
  62. 4
      src/google/protobuf/any_lite.cc
  63. 2
      src/google/protobuf/api.pb.h
  64. 12
      src/google/protobuf/arena.cc
  65. 3
      src/google/protobuf/arena.h
  66. 59
      src/google/protobuf/arena_impl.h
  67. 39
      src/google/protobuf/compiler/BUILD.bazel
  68. 8
      src/google/protobuf/compiler/code_generator.cc
  69. 19
      src/google/protobuf/compiler/command_line_interface.cc
  70. 1
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  71. 3
      src/google/protobuf/compiler/cpp/BUILD.bazel
  72. 1834
      src/google/protobuf/compiler/cpp/file.cc
  73. 119
      src/google/protobuf/compiler/cpp/file.h
  74. 9
      src/google/protobuf/compiler/cpp/generator.cc
  75. 41
      src/google/protobuf/compiler/cpp/helpers.cc
  76. 41
      src/google/protobuf/compiler/cpp/helpers.h
  77. 10
      src/google/protobuf/compiler/cpp/parse_function_generator.cc
  78. 2
      src/google/protobuf/compiler/csharp/BUILD.bazel
  79. 3
      src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
  80. 13
      src/google/protobuf/compiler/csharp/csharp_enum.cc
  81. 10
      src/google/protobuf/compiler/csharp/csharp_field_base.cc
  82. 8
      src/google/protobuf/compiler/csharp/csharp_field_base.h
  83. 10
      src/google/protobuf/compiler/csharp/csharp_generator.cc
  84. 4
      src/google/protobuf/compiler/csharp/csharp_helpers.cc
  85. 2
      src/google/protobuf/compiler/csharp/csharp_helpers.h
  86. 12
      src/google/protobuf/compiler/csharp/csharp_map_field.cc
  87. 17
      src/google/protobuf/compiler/csharp/csharp_message.cc
  88. 12
      src/google/protobuf/compiler/csharp/csharp_message_field.cc
  89. 2
      src/google/protobuf/compiler/csharp/csharp_names.h
  90. 13
      src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
  91. 13
      src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
  92. 12
      src/google/protobuf/compiler/importer.cc
  93. 2
      src/google/protobuf/compiler/java/BUILD.bazel
  94. 12
      src/google/protobuf/compiler/java/helpers.cc
  95. 3
      src/google/protobuf/compiler/java/helpers.h
  96. 23
      src/google/protobuf/compiler/mock_code_generator.cc
  97. 3
      src/google/protobuf/compiler/objectivec/BUILD.bazel
  98. 16
      src/google/protobuf/compiler/objectivec/objectivec_enum.cc
  99. 13
      src/google/protobuf/compiler/objectivec/objectivec_extension.cc
  100. 15
      src/google/protobuf/compiler/objectivec/objectivec_field.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,24 +1,29 @@
name: Generated CMake File Lists
name: Generate CMake File Lists
on:
- push
- pull_request
push:
branches:
- main
- '[0-9]+.x'
# The 21.x branch predates support for auto-generation of the CMake file
# lists, so we make sure to exclude it.
- '!21.x'
jobs:
cmake:
if: github.repository == 'protocolbuffers/protobuf'
runs-on: ubuntu-latest
strategy:
fail-fast: false # Don't cancel all jobs if one fails.
steps:
- uses: actions/checkout@v2
- name: Set up Bazel read-only caching
run: echo "BAZEL_CACHE_AUTH=--remote_upload_local_results=false" >> $GITHUB_ENV
- name: Generate CMake files
run: cd ${{ github.workspace }} && bazel build //pkg:gen_src_file_lists --test_output=errors $BAZEL_CACHE $BAZEL_CACHE_AUTH
- name: Compare to Golden file
run: diff -du bazel-bin/pkg/src_file_lists.cmake src/file_lists.cmake
- name: Report
run: echo "::error file=cmake/update_file_lists.sh::CMake files are stale, please run cmake/update_file_lists.sh"
if: failure()
- uses: actions/checkout@v3
with:
# Note: this token has an expiration date, so if the workflow starts
# failing then you may need to generate a fresh token.
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Configure name and email address in Git
run: cd ${{ github.workspace }} && git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com"
- name: Commit and push update
run: cd ${{ github.workspace }} && ./cmake/push_auto_update.sh

@ -294,18 +294,8 @@ alias(
proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",

@ -43,6 +43,11 @@
Compiler
* Print full path name of source .proto file on error
2022-09-13 version 21.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* Reduce memory consumption of MessageSet parsing
2022-08-09 version 21.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
PHP

@ -19,6 +19,10 @@ endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Honor visibility properties for all target types.
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# Project
project(protobuf C CXX)
@ -53,6 +57,11 @@ 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"

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

@ -81,7 +81,7 @@ Ruby:
JRuby:
$ [[ $(ruby --version) == "jruby"* ]] || echo "Switch to Java Ruby!"
$ bazel test //ruby:conformance_test --define=ruby_platform=java \
$ bazel test //ruby:conformance_test_jruby --define=ruby_platform=java \
--action_env=PATH --action_env=GEM_PATH --action_env=GEM_HOME
Testing other Protocol Buffer implementations

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

@ -576,6 +576,10 @@ namespace Google.Protobuf
[TestCase("-3.402823e38", -3.402823e38f)]
[TestCase("1.5e1", 15f)]
[TestCase("15e-1", 1.5f)]
[TestCase("3.4028235e38", float.MaxValue)]
[TestCase("-3.4028235e38", float.MinValue)]
[TestCase("3.4028235e+38", float.MaxValue)]
[TestCase("-3.4028235e+38", float.MinValue)]
public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue)
{
string json = "{ \"singleFloat\": " + jsonValue + "}";
@ -584,8 +588,10 @@ namespace Google.Protobuf
}
[Test]
[TestCase("3.402824e38", typeof(InvalidProtocolBufferException))]
[TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))]
[TestCase("3.4028236e38", typeof(InvalidProtocolBufferException))]
[TestCase("-3.4028236e38", typeof(InvalidProtocolBufferException))]
[TestCase("3.4028236e+38", typeof(InvalidProtocolBufferException))]
[TestCase("-3.4028236e+38", typeof(InvalidProtocolBufferException))]
[TestCase("1,0", typeof(InvalidJsonException))]
[TestCase("1.0.0", typeof(InvalidJsonException))]
[TestCase("+1", typeof(InvalidJsonException))]

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

@ -642,19 +642,15 @@ namespace Google.Protobuf
{
return float.NaN;
}
if (value > float.MaxValue || value < float.MinValue)
float converted = (float) value;
// If the value is out of range of float, the cast representation will be infinite.
// If the original value was infinite as well, that's fine - we'll return the 32-bit
// version (with the correct sign).
if (float.IsInfinity(converted) && !double.IsInfinity(value))
{
if (double.IsPositiveInfinity(value))
{
return float.PositiveInfinity;
}
if (double.IsNegativeInfinity(value))
{
return float.NegativeInfinity;
}
throw new InvalidProtocolBufferException($"Value out of range: {value}");
}
return (float) value;
return converted;
case FieldType.Enum:
CheckInteger(value);
// Just return it as an int, and let the CLR convert it.

@ -6641,6 +6641,10 @@ namespace Google.Protobuf.Reflection {
private bool mapEntry_;
/// <summary>
/// NOTE: Do not set the option in .proto files. Always use the maps syntax
/// instead. The option should only be implicitly set by the proto compiler
/// parser.
///
/// Whether the message is an automatically generated map entry type for the
/// maps field.
///
@ -6658,10 +6662,6 @@ namespace Google.Protobuf.Reflection {
/// use a native map in the target language to hold the keys and values.
/// The reflection APIs in such implementations still need to work as
/// if the field is a repeated message field.
///
/// NOTE: Do not set the option in .proto files. Always use the maps syntax
/// instead. The option should only be implicitly set by the proto compiler
/// parser.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]

@ -344,3 +344,7 @@ with info about your project (name and website) so we can add an entry for you.
1. mypy-protobuf
* Website: https://github.com/nipunn1313/mypy-protobuf
* Extension: 1151-1154
1. Pigweed protobuf compiler
* Website: https://pigweed.dev/pw_protobuf
* Extension: 1155

@ -0,0 +1 @@
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14

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

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

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

@ -61,7 +61,6 @@ public final class TextFormat {
private static final String DEBUG_STRING_SILENT_MARKER = "\t ";
/**
* Outputs a textual representation of the Protocol Message supplied into the parameter output.
* (This representation is the new version of the classic "ProtocolPrinter" output from the
@ -739,9 +738,9 @@ public final class TextFormat {
// Groups must be serialized with their original capitalization.
generator.print(field.getMessageType().getName());
} else {
generator.print(field.getName());
}
generator.print(field.getName());
}
}
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
generator.print(" {");
@ -1836,16 +1835,16 @@ public final class TextFormat {
extension = target.findExtensionByName(extensionRegistry, name);
if (extension == null) {
String message =
(tokenizer.getPreviousLine() + 1)
+ ":"
+ (tokenizer.getPreviousColumn() + 1)
+ ":\t"
+ type.getFullName()
+ ".["
+ name
+ "]";
unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
String message =
(tokenizer.getPreviousLine() + 1)
+ ":"
+ (tokenizer.getPreviousColumn() + 1)
+ ":\t"
+ type.getFullName()
+ ".["
+ name
+ "]";
unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION));
} else {
if (extension.descriptor.getContainingType() != type) {
throw tokenizer.parseExceptionPreviousToken(

@ -125,6 +125,3 @@ message ReservedAsMapFieldWithEnumValue {
// null is not a 'reserved word' per se but as a literal needs similar care
map<string, SampleEnum> null = 10;
}
package map_for_proto2_lite_test;
option java_package = "map_lite_test";
option optimize_for = LITE_RUNTIME;

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

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

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

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

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

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

@ -36,9 +36,13 @@ build_php_c() {
test_php_c
}
cmake .
cmake --build . --target protoc -- -j20
mkdir build
pushd build
cmake ..
cmake --build . -- -j20
ctest --verbose --parallel 20
export PROTOC=$(pwd)/protoc
popd
build_php 7.0
build_php 7.1
@ -49,3 +53,6 @@ build_php_c 7.4
build_php_c 7.1-zts
build_php_c 7.2-zts
build_php_c 7.5-zts
# Cleanup after CMake build
rm -rf build

@ -6,7 +6,7 @@ timeout_mins: 15
env_vars {
key: "BAZEL_TARGETS"
value: "//src/..."
value: "//src/... @com_google_protobuf_examples//..."
}
action {

@ -19,7 +19,7 @@ docker run \
--cidfile $tmpfile \
-v $GIT_REPO_ROOT:/workspace \
$CONTAINER_IMAGE \
/test.sh -Dprotobuf_BUILD_CONFORMANCE=ON
/test.sh -Dprotobuf_BUILD_CONFORMANCE=ON -Dprotobuf_BUILD_EXAMPLES=ON
# Save logs for Kokoro
docker cp \

@ -5,6 +5,9 @@
# Change to repo root
cd $(dirname $0)/../../..
# Fix locale issues in Monterey.
export LC_ALL=en_US.UTF-8
# Prepare worker environment to run tests
KOKORO_INSTALL_RVM=yes
source kokoro/macos/prepare_build_macos_rc

@ -2,6 +2,10 @@
set -ex
# Fix permissions
sudo chown -R $(whoami) $HOME/.rvm/
sudo chown -R $(whoami) /Library/Ruby/
set +ex # rvm script is very verbose and exits with errorcode
# Fix permissions

@ -24,7 +24,7 @@ bazel %BAZEL_STARTUP% build //:protoc //:protobuf //:protobuf_lite %BAZEL_FLAGS%
@rem TODO(b/241484899) Enable conformance tests on windows.
bazel %BAZEL_STARTUP% test %BAZEL_FLAGS% ^
--test_tag_filters=-conformance --build_tag_filters=-conformance ^
//src/... || goto :error
//src/... @com_google_protobuf_examples//... || goto :error
goto :EOF

@ -6,13 +6,14 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
md build -ea 0
md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
md build
md %KOKORO_ARTIFACTS_DIR%\logs
cd build
cmake .. ^
-G "Visual Studio 15 2017" -A x64 ^
-Dprotobuf_BUILD_EXAMPLES=ON ^
-Dprotobuf_BUILD_CONFORMANCE=OFF ^
-Dprotobuf_WITH_ZLIB=OFF ^
-Dprotobuf_TEST_XML_OUTDIR=%KOKORO_ARTIFACTS_DIR%\logs\ || goto :error

@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
md build -ea 0
md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
md build
md %KOKORO_ARTIFACTS_DIR%\logs
cd build

@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
md build -ea 0
md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
md build
md %KOKORO_ARTIFACTS_DIR%\logs
cd build

@ -6,8 +6,8 @@ call kokoro\windows\prepare_build_win64.bat || goto :error
@rem TODO(b/241475022) Use docker to guarantee better stability.
@rem TODO(b/241484899) Run conformance tests in windows.
md build -ea 0
md %KOKORO_ARTIFACTS_DIR%\logs -ea 0
md build
md %KOKORO_ARTIFACTS_DIR%\logs
cd build

@ -30,8 +30,9 @@
#import <Foundation/Foundation.h>
#import "GPBExtensionRegistry.h"
@class GPBMessage;
@class GPBExtensionRegistry;
NS_ASSUME_NONNULL_BEGIN
@ -184,7 +185,7 @@ CF_EXTERN_C_END
* extensions for message.
**/
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
/**
* Reads and discards a single field, given its tag value.

@ -434,7 +434,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
CheckRecursionLimit(&state_);
++state_.recursionDepth;
[message mergeFromCodedInputStream:self extensionRegistry:extensionRegistry];
@ -454,7 +454,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (void)readMessage:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
CheckRecursionLimit(&state_);
int32_t length = ReadRawVarint32(&state_);
size_t oldLimit = GPBCodedInputStreamPushLimit(&state_, length);
@ -466,7 +466,7 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state,
}
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage {
CheckRecursionLimit(&state_);

@ -61,7 +61,7 @@ typedef struct GPBCodedInputStreamState {
// support for older data.
- (void)readGroup:(int32_t)fieldNumber
message:(GPBMessage *)message
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
// Reads a group field value from the stream and merges it into the given
// UnknownFieldSet.
@ -70,7 +70,7 @@ typedef struct GPBCodedInputStreamState {
// Reads a map entry.
- (void)readMapEntry:(id)mapDictionary
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
field:(GPBFieldDescriptor *)field
parentMessage:(GPBMessage *)parentMessage;
@end

@ -386,7 +386,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict, GPBFieldDescri
static void ReadValue(GPBCodedInputStream *stream,
GPBGenericValue *valueToFill,
GPBDataType type,
GPBExtensionRegistry *registry,
id<GPBExtensionRegistry>registry,
GPBFieldDescriptor *field) {
switch (type) {
case GPBDataTypeBool:
@ -454,7 +454,7 @@ static void ReadValue(GPBCodedInputStream *stream,
void GPBDictionaryReadEntry(id mapDictionary,
GPBCodedInputStream *stream,
GPBExtensionRegistry *registry,
id<GPBExtensionRegistry>registry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage) {
GPBDataType keyDataType = field.mapKeyDataType;

@ -34,7 +34,7 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionRegistry;
@protocol GPBExtensionRegistry;
@class GPBFieldDescriptor;
@protocol GPBDictionaryInternalsProtocol
@ -493,7 +493,7 @@ BOOL GPBDictionaryIsInitializedInternalHelper(NSDictionary *dict,
// Helper to read a map instead.
void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
GPBExtensionRegistry *registry,
id<GPBExtensionRegistry>registry,
GPBFieldDescriptor *field,
GPBMessage *parentMessage);

@ -34,12 +34,12 @@
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionRegistry;
@protocol GPBExtensionRegistry;
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
GPBExtensionRegistry *extensionRegistry,
id<GPBExtensionRegistry>extensionRegistry,
GPBMessage *message);
size_t GPBComputeExtensionSerializedSizeIncludingTag(

@ -40,7 +40,7 @@
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
GPBExtensionRegistry *extensionRegistry,
id<GPBExtensionRegistry>extensionRegistry,
GPBMessage *existingValue)
__attribute__((ns_returns_retained));
@ -273,7 +273,7 @@ static void WriteArrayIncludingTagsToCodedOutputStream(
void GPBExtensionMergeFromInputStream(GPBExtensionDescriptor *extension,
BOOL isPackedOnStream,
GPBCodedInputStream *input,
GPBExtensionRegistry *extensionRegistry,
id<GPBExtensionRegistry>extensionRegistry,
GPBMessage *message) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;
@ -334,7 +334,7 @@ size_t GPBComputeExtensionSerializedSizeIncludingTag(
// Note that this returns a retained value intentionally.
static id NewSingleValueFromInputStream(GPBExtensionDescriptor *extension,
GPBCodedInputStream *input,
GPBExtensionRegistry *extensionRegistry,
id<GPBExtensionRegistry>extensionRegistry,
GPBMessage *existingValue) {
GPBExtensionDescription *description = extension->description_;
GPBCodedInputStreamState *state = &input->state_;

@ -41,6 +41,24 @@ NS_ASSUME_NONNULL_BEGIN
* GPBExtensionRegistry in which you have registered any extensions that you
* want to be able to parse. Otherwise, those extensions will just be treated
* like unknown fields.
**/
@protocol GPBExtensionRegistry <NSObject>
/**
* Looks for the extension registered for the given field number on a given
* GPBDescriptor.
*
* @param descriptor The descriptor to look for a registered extension on.
* @param fieldNumber The field number of the extension to look for.
*
* @return The registered GPBExtensionDescriptor or nil if none was found.
**/
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber;
@end
/**
* A concrete implementation of `GPBExtensionRegistry`.
*
* The *Root classes provide `+extensionRegistry` for the extensions defined
* in a given file *and* all files it imports. You can also create a
@ -54,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
* MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
* ```
**/
@interface GPBExtensionRegistry : NSObject<NSCopying>
@interface GPBExtensionRegistry : NSObject<NSCopying, GPBExtensionRegistry>
/**
* Adds the given GPBExtensionDescriptor to this registry.
@ -70,18 +88,6 @@ NS_ASSUME_NONNULL_BEGIN
**/
- (void)addExtensions:(GPBExtensionRegistry *)registry;
/**
* Looks for the extension registered for the given field number on a given
* GPBDescriptor.
*
* @param descriptor The descriptor to look for a registered extension on.
* @param fieldNumber The field number of the extension to look for.
*
* @return The registered GPBExtensionDescriptor or nil if none was found.
**/
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber;
@end
NS_ASSUME_NONNULL_END

@ -31,12 +31,12 @@
#import <Foundation/Foundation.h>
#import "GPBBootstrap.h"
#import "GPBExtensionRegistry.h"
@class GPBDescriptor;
@class GPBCodedInputStream;
@class GPBCodedOutputStream;
@class GPBExtensionDescriptor;
@class GPBExtensionRegistry;
@class GPBFieldDescriptor;
@class GPBUnknownFieldSet;
@ -147,7 +147,7 @@ CF_EXTERN_C_END
* @return A new instance of the generated class.
**/
+ (nullable instancetype)parseFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr;
/**
@ -171,7 +171,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
(nullable id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr;
/**
@ -196,7 +196,7 @@ CF_EXTERN_C_END
**/
+ (nullable instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
(nullable id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr;
/**
@ -239,7 +239,7 @@ CF_EXTERN_C_END
* @return An initialized instance of the generated class.
**/
- (nullable instancetype)initWithData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr;
/**
@ -264,7 +264,7 @@ CF_EXTERN_C_END
**/
- (nullable instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(nullable GPBExtensionRegistry *)extensionRegistry
(nullable id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr;
/**
@ -278,7 +278,7 @@ CF_EXTERN_C_END
* unsuccessful.
**/
- (void)mergeFromData:(NSData *)data
extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry;
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
/**
* Merges the fields from another message (of the same type) into this

@ -881,7 +881,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (instancetype)initWithData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@ -912,7 +912,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (instancetype)initWithCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry
(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
if ((self = [self init])) {
@try {
@ -1973,7 +1973,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeFrom
- (void)mergeFromData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
GPBCodedInputStream *input = [[GPBCodedInputStream alloc] initWithData:data];
[self mergeFromCodedInputStream:input extensionRegistry:extensionRegistry];
[input checkLastTagWas:0];
@ -1983,7 +1983,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
#pragma mark - mergeDelimitedFrom
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
GPBCodedInputStreamState *state = &input->state_;
if (GPBCodedInputStreamIsAtEnd(state)) {
return;
@ -2003,7 +2003,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromData:(NSData *)data
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
return [[[self alloc] initWithData:data
extensionRegistry:extensionRegistry
@ -2011,7 +2011,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
+ (instancetype)parseFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
return
[[[self alloc] initWithCodedInputStream:input
@ -2023,7 +2023,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
+ (instancetype)parseDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry
(id<GPBExtensionRegistry>)extensionRegistry
error:(NSError **)errorPtr {
GPBMessage *message = [[[self alloc] init] autorelease];
@try {
@ -2065,7 +2065,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (void)parseMessageSet:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
uint32_t typeId = 0;
NSData *rawBytes = nil;
GPBExtensionDescriptor *extension = nil;
@ -2117,7 +2117,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (BOOL)parseUnknownField:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
tag:(uint32_t)tag {
GPBWireFormat wireType = GPBWireFormatGetTagWireType(tag);
int32_t fieldNumber = GPBWireFormatGetTagFieldNumber(tag);
@ -2170,7 +2170,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
static void MergeSingleFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
GPBCodedInputStream *input, id<GPBExtensionRegistry>extensionRegistry) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
#define CASE_SINGLE_POD(NAME, TYPE, FUNC_TYPE) \
@ -2306,7 +2306,7 @@ static void MergeRepeatedPackedFieldFromCodedInputStream(
static void MergeRepeatedNotPackedFieldFromCodedInputStream(
GPBMessage *self, GPBFieldDescriptor *field, GPBFileSyntax syntax,
GPBCodedInputStream *input, GPBExtensionRegistry *extensionRegistry) {
GPBCodedInputStream *input, id<GPBExtensionRegistry>extensionRegistry) {
GPBCodedInputStreamState *state = &input->state_;
id genericArray = GetOrCreateArrayIvarWithField(self, field);
switch (GPBGetFieldDataType(field)) {
@ -2371,7 +2371,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
}
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry {
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry {
GPBDescriptor *descriptor = [self descriptor];
GPBFileSyntax syntax = descriptor.file.syntax;
GPBCodedInputStreamState *state = &input->state_;

@ -78,13 +78,13 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// or zero for EOF.
// NOTE: This will throw if there is an error while parsing.
- (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:(GPBExtensionRegistry *)extensionRegistry;
extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
// Parses the next delimited message of this type from the input and merges it
// with this message.
- (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
extensionRegistry:
(GPBExtensionRegistry *)extensionRegistry;
(id<GPBExtensionRegistry>)extensionRegistry;
- (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;

@ -10,11 +10,11 @@
<email>protobuf-packages@google.com</email>
<active>yes</active>
</lead>
<date>2022-08-09</date>
<time>09:24:23</time>
<date>2022-09-13</date>
<time>13:50:07</time>
<version>
<release>3.21.5</release>
<api>3.21.5</api>
<release>3.21.6</release>
<api>3.21.6</api>
</version>
<stability>
<release>stable</release>
@ -1403,5 +1403,20 @@ G A release.
<notes>
</notes>
</release>
<release>
<version>
<release>3.21.6</release>
<api>3.21.6</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2022-09-13</date>
<time>13:50:07</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
<notes>
</notes>
</release>
</changelog>
</package>

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

@ -5,7 +5,9 @@
set -e
PROTOC=$(realpath protoc)
if [[ -z "${PROTOC}" ]]; then
PROTOC=$(realpath protoc)
fi
if [ ! -f $PROTOC ]; then
bazel build -c opt //:protoc
PROTOC=$(realpath bazel-bin/protoc)

@ -4,7 +4,9 @@ set -ex
cd `dirname $0`/..
PROTOC=$(pwd)/protoc
if [[ -z "${PROTOC}" ]]; then
PROTOC=$(pwd)/protoc
fi
if [ ! -f $PROTOC ]; then
bazel build -c opt //:protoc
PROTOC=$(pwd)/bazel-bin/protoc

@ -53,6 +53,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
*/
protected $deprecated = null;
/**
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@ -68,9 +71,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
*
* Generated from protobuf field <code>optional bool map_entry = 7;</code>
*/
@ -114,6 +114,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* for the message, or it will be completely ignored; in the very least,
* this is a formalization for deprecating messages.
* @type bool $map_entry
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@ -129,9 +132,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
* @type array<\Google\Protobuf\Internal\UninterpretedOption>|\Google\Protobuf\Internal\RepeatedField $uninterpreted_option
* The parser stores options it doesn't recognize here. See above.
* }
@ -288,6 +288,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
}
/**
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@ -303,9 +306,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
*
* Generated from protobuf field <code>optional bool map_entry = 7;</code>
* @return bool
@ -326,6 +326,9 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
}
/**
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
* Whether the message is an automatically generated map entry type for the
* maps field.
* For maps fields:
@ -341,9 +344,6 @@ class MessageOptions extends \Google\Protobuf\Internal\Message
* use a native map in the target language to hold the keys and values.
* The reflection APIs in such implementations still need to work as
* if the field is a repeated message field.
* NOTE: Do not set the option in .proto files. Always use the maps syntax
* instead. The option should only be implicitly set by the proto compiler
* parser.
*
* Generated from protobuf field <code>optional bool map_entry = 7;</code>
* @param bool $var

@ -365,7 +365,8 @@ cc_dist_library(
}),
tags = ["manual"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf:wkt_cc_proto",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf:arena",
"//src/google/protobuf:protobuf_lite",
"//src/google/protobuf/compiler:importer",

@ -1,3 +1,3 @@
PROTOC_VERSION = '21.5'
PROTOBUF_JAVA_VERSION = '3.21.5'
PROTOBUF_PYTHON_VERSION = '4.21.5'
PROTOC_VERSION = '21.6'
PROTOBUF_JAVA_VERSION = '3.21.6'
PROTOBUF_PYTHON_VERSION = '4.21.6'

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

@ -109,7 +109,8 @@ def MessageToJson(
names as defined in the .proto file. If False, convert the field
names to lowerCamelCase.
indent: The JSON object will be pretty-printed with this indent level.
An indent level of 0 or negative will only insert newlines.
An indent level of 0 or negative will only insert newlines. If the
indent level is None, no newlines will be inserted.
sort_keys: If True, then the output will be sorted by field names.
use_integers_for_enums: If true, print integers instead of enum names.
descriptor_pool: A Descriptor Pool for resolving types. If None use the

@ -42,7 +42,7 @@
#include <string>
#include <vector>
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/match.h"
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
@ -70,6 +70,7 @@
#include "google/protobuf/pyext/unknown_field_set.h"
#include "google/protobuf/pyext/unknown_fields.h"
#include "google/protobuf/util/message_differencer.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/strtod.h"
@ -409,7 +410,7 @@ static PyObject* GetClassAttribute(CMessageClass *self, PyObject* name) {
Py_ssize_t attr_size;
static const char kSuffix[] = "_FIELD_NUMBER";
if (PyString_AsStringAndSize(name, &attr, &attr_size) >= 0 &&
HasSuffixString(absl::string_view(attr, attr_size), kSuffix)) {
absl::EndsWith(absl::string_view(attr, attr_size), kSuffix)) {
std::string field_name(attr, attr_size - sizeof(kSuffix) + 1);
LowerString(&field_name);

@ -1013,6 +1013,8 @@ class _Parser(object):
if not tokenizer.TryConsume(','):
tokenizer.TryConsume(';')
def _LogSilentMarker(self, field_name):
pass
def _DetectSilentMarker(self, tokenizer, field_name):

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.21.5"
s.version = "3.21.6"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"

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

@ -11,10 +11,18 @@ endif()
# //pkg:protobuf
set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.cc
@ -24,12 +32,9 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_heavy.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.cc
@ -58,16 +63,12 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.cc
@ -91,14 +92,21 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc
)
# //pkg:protobuf
set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_config.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_impl.h
@ -109,15 +117,12 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.h
${protobuf_SOURCE_DIR}/src/google/protobuf/duration.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h
${protobuf_SOURCE_DIR}/src/google/protobuf/empty.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h
${protobuf_SOURCE_DIR}/src/google/protobuf/explicitly_constructed.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/extension_set_inl.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_access_listener.h
${protobuf_SOURCE_DIR}/src/google/protobuf/field_mask.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_reflection.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_enum_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/generated_message_bases.h
@ -158,8 +163,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/service.h
${protobuf_SOURCE_DIR}/src/google/protobuf/source_context.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/struct.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h
@ -172,8 +175,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/timestamp.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/type.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator.h
@ -202,7 +203,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.pb.h
)
# //pkg:protobuf_lite
@ -456,6 +456,7 @@ set(libprotoc_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_options.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/php/php_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.h

@ -81,6 +81,57 @@ proto_library(
strip_import_prefix = "/src",
)
# Generate code for the well-known types on demand.
# This needs to be done in a separate genrule because we publish protoc and the
# C++ runtime with the WKT code linked in. We need to use a stripped down
# compiler and runtime library to generate them, and cc_proto_library doesn't
# support swapping out the compiler binary (even though a custom runtime can
# be passed to proto_lang_toolchain).
#
# TODO(b/246826624) We still check in generated pb.h and pb.cc files purely to
# support CMake builds. These aren't used at all by Bazel and will be removed
# in the future once CMake can generate them too.
WELL_KNOWN_TYPES = [
"any",
"api",
"duration",
"empty",
"field_mask",
"source_context",
"struct",
"timestamp",
"type",
"wrappers",
]
genrule(
name = "gen_wkt_cc_sources",
srcs = [wkt + ".proto" for wkt in WELL_KNOWN_TYPES],
exec_tools = ["//src/google/protobuf/compiler:protoc_nowkt"],
outs =
[wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
[wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
cmd = """
$(execpath //src/google/protobuf/compiler:protoc_nowkt) \
--cpp_out=$(RULEDIR)/../.. \
--proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \
$(SRCS)
""",
visibility = ["//visibility:private"],
)
cc_library(
name = "wkt_cc_proto",
srcs = [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
hdrs = [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES],
deps = [":protobuf_nowkt"],
copts = COPTS,
include_prefix = "google/protobuf",
linkopts = LINK_OPTS,
visibility = ["//pkg:__pkg__"],
)
# Built-in runtime types
proto_library(
@ -211,19 +262,14 @@ cc_library(
)
cc_library(
name = "protobuf",
name = "protobuf_nowkt",
srcs = [
"any.cc",
"any.pb.cc",
"api.pb.cc",
"descriptor.cc",
"descriptor.pb.cc",
"descriptor_database.cc",
"duration.pb.cc",
"dynamic_message.cc",
"empty.pb.cc",
"extension_set_heavy.cc",
"field_mask.pb.cc",
"generated_message_bases.cc",
"generated_message_reflection.cc",
"generated_message_tctable_full.cc",
@ -232,26 +278,16 @@ cc_library(
"message.cc",
"reflection_ops.cc",
"service.cc",
"source_context.pb.cc",
"struct.pb.cc",
"text_format.cc",
"timestamp.pb.cc",
"type.pb.cc",
"unknown_field_set.cc",
"wire_format.cc",
"wrappers.pb.cc",
],
hdrs = [
"any.pb.h",
"api.pb.h",
"descriptor.h",
"descriptor.pb.h",
"descriptor_database.h",
"duration.pb.h",
"dynamic_message.h",
"empty.pb.h",
"field_access_listener.h",
"field_mask.pb.h",
"generated_enum_reflection.h",
"generated_message_bases.h",
"generated_message_reflection.h",
@ -265,25 +301,19 @@ cc_library(
"reflection_internal.h",
"reflection_ops.h",
"service.h",
"source_context.pb.h",
"struct.pb.h",
"text_format.h",
"timestamp.pb.h",
"type.pb.h",
"unknown_field_set.h",
"wire_format.h",
"wrappers.pb.h",
],
copts = COPTS,
include_prefix = "google/protobuf",
linkopts = LINK_OPTS,
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
"//src/google/protobuf:__subpackages__",
],
deps = [
":protobuf_lite",
":protobuf_lite",
"//src/google/protobuf/io",
"//src/google/protobuf/io:gzip_stream",
"//src/google/protobuf/io:printer",
@ -300,6 +330,22 @@ cc_library(
],
)
cc_library(
name = "protobuf",
deps = [
":protobuf_nowkt",
":wkt_cc_proto",
],
copts = COPTS,
include_prefix = "google/protobuf",
linkopts = LINK_OPTS,
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
"//src/google/protobuf:__subpackages__",
],
)
# This provides just the header files for use in projects that need to build
# shared libraries for dynamic loading. This target is available until Bazel
# adds native support for such use cases.

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -29,7 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/any.h"
#include "google/protobuf/arenastring.h"
@ -72,7 +72,7 @@ bool AnyMetadata::InternalIs(absl::string_view type_name) const {
absl::string_view type_url = type_url_->Get();
return type_url.size() >= type_name.size() + 1 &&
type_url[type_url.size() - type_name.size() - 1] == '/' &&
HasSuffixString(type_url, type_name);
absl::EndsWith(type_url, type_name);
}
bool ParseAnyTypeUrl(absl::string_view type_url, std::string* url_prefix,

@ -13,7 +13,7 @@
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION
#if 3021006 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.

@ -105,7 +105,7 @@ class GetDeallocator {
size_t* space_allocated_;
};
SerialArena::SerialArena(Block* b, ThreadSafeArena& parent)
SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent)
: parent_(parent), space_allocated_(b->size()) {
set_head(b);
set_ptr(b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize));
@ -117,13 +117,13 @@ SerialArena* SerialArena::New(Memory mem, ThreadSafeArena& parent) {
ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(),
/*used=*/0, /*allocated=*/mem.size,
/*wasted=*/0);
auto b = new (mem.ptr) Block{nullptr, mem.size};
auto b = new (mem.ptr) ArenaBlock{nullptr, mem.size};
return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, parent);
}
template <typename Deallocator>
SerialArena::Memory SerialArena::Free(Deallocator deallocator) {
Block* b = head();
ArenaBlock* b = head();
Memory mem = {b, b->size()};
while (b->next) {
b = b->next; // We must first advance before deleting this block
@ -179,7 +179,7 @@ void SerialArena::AllocateNewBlock(size_t n) {
ThreadSafeArenaStats::RecordAllocateStats(parent_.arena_stats_.MutableStats(),
/*used=*/used,
/*allocated=*/mem.size, wasted);
set_head(new (mem.ptr) Block{head(), mem.size});
set_head(new (mem.ptr) ArenaBlock{head(), mem.size});
set_ptr(head()->Pointer(kBlockHeaderSize));
limit_ = head()->Pointer(head()->size());
@ -199,7 +199,7 @@ uint64_t SerialArena::SpaceUsed() const {
const uint64_t current_block_size = head()->size();
uint64_t space_used = std::min(
static_cast<uint64_t>(
ptr() - const_cast<Block*>(head())->Pointer(kBlockHeaderSize)),
ptr() - const_cast<ArenaBlock*>(head())->Pointer(kBlockHeaderSize)),
current_block_size);
space_used += space_used_.load(std::memory_order_relaxed);
// Remove the overhead of the SerialArena itself.
@ -208,7 +208,7 @@ uint64_t SerialArena::SpaceUsed() const {
}
void SerialArena::CleanupList() {
Block* b = head();
ArenaBlock* b = head();
b->cleanup_nodes = limit_;
do {
char* limit = reinterpret_cast<char*>(

@ -252,9 +252,6 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
inline ~Arena() {}
// TODO(protobuf-team): Fix callers to use constructor and delete this method.
void Init(const ArenaOptions&) {}
// API to create proto2 message objects on the arena. If the arena passed in
// is nullptr, then a heap allocated object is returned. Type T must be a
// message defined in a .proto file with cc_enable_arenas set to true,

@ -90,6 +90,29 @@ inline PROTOBUF_ALWAYS_INLINE void* AlignTo(void* p, size_t a) {
}
}
// Arena blocks are variable length malloc-ed objects. The following structure
// describes the common header for all blocks.
struct ArenaBlock {
ArenaBlock(ArenaBlock* next, size_t size)
: next(next), cleanup_nodes(nullptr), relaxed_size(size) {
GOOGLE_DCHECK_GT(size, sizeof(ArenaBlock));
}
char* Pointer(size_t n) {
GOOGLE_DCHECK(n <= size());
return reinterpret_cast<char*>(this) + n;
}
size_t size() const { return relaxed_size.load(std::memory_order_relaxed); }
ArenaBlock* const next;
void* cleanup_nodes;
private:
const std::atomic<size_t> relaxed_size;
// data follows
};
namespace cleanup {
template <typename T>
@ -545,29 +568,8 @@ class PROTOBUF_EXPORT SerialArena {
template <typename Deallocator>
Memory Free(Deallocator deallocator);
// Blocks are variable length malloc-ed objects. The following structure
// describes the common header for all blocks.
struct Block {
Block(Block* next, size_t size)
: next(next), cleanup_nodes(nullptr), relaxed_size(size) {}
char* Pointer(size_t n) {
GOOGLE_DCHECK(n <= size());
return reinterpret_cast<char*>(this) + n;
}
size_t size() const { return relaxed_size.load(std::memory_order_relaxed); }
Block* const next;
void* cleanup_nodes;
private:
const std::atomic<size_t> relaxed_size;
// data follows
};
ThreadSafeArena& parent_;
std::atomic<Block*> head_; // Head of linked list of blocks.
std::atomic<ArenaBlock*> head_; // Head of linked list of blocks.
std::atomic<size_t> space_used_{0}; // Necessary for metrics.
std::atomic<size_t> space_allocated_;
@ -577,9 +579,11 @@ class PROTOBUF_EXPORT SerialArena {
std::atomic<char*> ptr_;
// Helper getters/setters to handle relaxed operations on atomic variables.
Block* head() { return head_.load(std::memory_order_relaxed); }
const Block* head() const { return head_.load(std::memory_order_relaxed); }
void set_head(Block* head) {
ArenaBlock* head() { return head_.load(std::memory_order_relaxed); }
const ArenaBlock* head() const {
return head_.load(std::memory_order_relaxed);
}
void set_head(ArenaBlock* head) {
return head_.store(head, std::memory_order_relaxed);
}
char* ptr() { return ptr_.load(std::memory_order_relaxed); }
@ -604,7 +608,8 @@ class PROTOBUF_EXPORT SerialArena {
CachedBlock** cached_blocks_ = nullptr;
// Constructor is private as only New() should be used.
inline SerialArena(Block* b, ThreadSafeArena& parent);
inline SerialArena(ArenaBlock* b, ThreadSafeArena& parent);
void* AllocateAlignedFallback(size_t n);
void* AllocateAlignedWithCleanupFallback(size_t n, size_t align,
void (*destructor)(void*));
@ -612,7 +617,7 @@ class PROTOBUF_EXPORT SerialArena {
void AllocateNewBlock(size_t n);
public:
static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block));
static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(ArenaBlock));
};
// Tag type used to invoke the constructor of message-owned arena.

@ -11,7 +11,7 @@ load(
)
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
load("//build_defs:cpp_opts.bzl", "COPTS")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS")
proto_library(
name = "plugin_proto",
@ -37,7 +37,7 @@ cc_library(
include_prefix = "google/protobuf/compiler",
visibility = ["//visibility:public"],
deps = [
"//src/google/protobuf",
"//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
@ -59,7 +59,7 @@ cc_library(
include_prefix = "google/protobuf/compiler",
visibility = ["//visibility:public"],
deps = [
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
@ -82,26 +82,22 @@ cc_library(
deps = [
":code_generator",
":importer",
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/strings",
],
)
cc_library(
name = "protoc_lib",
name = "protoc_lib_nowkt",
srcs = [
"main.cc",
],
copts = COPTS,
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
],
deps = [
":code_generator",
":command_line_interface",
":importer",
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler/cpp",
"//src/google/protobuf/compiler/csharp",
"//src/google/protobuf/compiler/java",
@ -112,6 +108,29 @@ cc_library(
],
)
cc_binary(
name = "protoc_nowkt",
copts = COPTS,
linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
visibility = [
"//src/google/protobuf:__pkg__",
],
deps = [":protoc_lib_nowkt"],
)
cc_library(
name = "protoc_lib",
copts = COPTS,
visibility = [
"//:__pkg__",
"//pkg:__pkg__",
],
deps = [
"//:protobuf",
":protoc_lib_nowkt",
],
)
# Note: this is an alias for now. In the future, this rule will become the
# cc_binary for protoc, and //:protoc will become an alias.
alias(

@ -38,8 +38,8 @@
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/str_split.h"
#include "absl/strings/strip.h"
namespace google {
namespace protobuf {
@ -126,10 +126,10 @@ void ParseGeneratorParameter(
// Strips ".proto" or ".protodevel" from the end of a filename.
std::string StripProto(const std::string& filename) {
if (HasSuffixString(filename, ".protodevel")) {
return StripSuffixString(filename, ".protodevel");
if (absl::EndsWith(filename, ".protodevel")) {
return std::string(absl::StripSuffix(filename, ".protodevel"));
} else {
return StripSuffixString(filename, ".proto");
return std::string(absl::StripSuffix(filename, ".proto"));
}
}

@ -75,6 +75,7 @@
#include "google/protobuf/compiler/subprocess.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/match.h"
#include "google/protobuf/stubs/stringprintf.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
@ -1065,9 +1066,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (mode_ == MODE_COMPILE) {
for (int i = 0; i < output_directives_.size(); i++) {
std::string output_location = output_directives_[i].output_location;
if (!HasSuffixString(output_location, ".zip") &&
!HasSuffixString(output_location, ".jar") &&
!HasSuffixString(output_location, ".srcjar")) {
if (!absl::EndsWith(output_location, ".zip") &&
!absl::EndsWith(output_location, ".jar") &&
!absl::EndsWith(output_location, ".srcjar")) {
AddTrailingSlash(&output_location);
}
@ -1088,12 +1089,12 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
for (const auto& pair : output_directories) {
const std::string& location = pair.first;
GeneratorContextImpl* directory = pair.second.get();
if (HasSuffixString(location, "/")) {
if (absl::EndsWith(location, "/")) {
if (!directory->WriteAllToDisk(location)) {
return 1;
}
} else {
if (HasSuffixString(location, ".jar")) {
if (absl::EndsWith(location, ".jar")) {
directory->AddJarManifest();
}
@ -1971,7 +1972,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
// Some other flag. Look it up in the generators list.
const GeneratorInfo* generator_info = FindGeneratorByFlag(name);
if (generator_info == nullptr &&
(plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
(plugin_prefix_.empty() || !absl::EndsWith(name, "_out"))) {
// Check if it's a generator option flag.
generator_info = FindGeneratorByOption(name);
if (generator_info != nullptr) {
@ -1981,7 +1982,7 @@ CommandLineInterface::InterpretArgument(const std::string& name,
parameters->append(",");
}
parameters->append(value);
} else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) {
} else if (absl::StartsWith(name, "--") && absl::EndsWith(name, "_opt")) {
std::string* parameters =
&plugin_parameters_[PluginName(plugin_prefix_, name)];
if (!parameters->empty()) {
@ -2165,8 +2166,8 @@ bool CommandLineInterface::GenerateOutput(
std::string error;
if (output_directive.generator == nullptr) {
// This is a plugin.
GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
HasSuffixString(output_directive.name, "_out"))
GOOGLE_CHECK(absl::StartsWith(output_directive.name, "--") &&
absl::EndsWith(output_directive.name, "_out"))
<< "Bad name for plugin generator: " << output_directive.name;
std::string plugin_name = PluginName(plugin_prefix_, output_directive.name);

@ -794,6 +794,7 @@ TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) {
"bar.proto", "Bar");
}
TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport_DescriptorSetIn) {
// Test parsing multiple input files with an import of a separate file.
FileDescriptorSet file_descriptor_set;

@ -53,9 +53,10 @@ cc_library(
"//src/google/protobuf/compiler:__pkg__",
],
deps = [
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/container:layout",

File diff suppressed because it is too large Load Diff

@ -36,55 +36,47 @@
#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
#include <algorithm>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/compiler/scc.h"
#include "absl/container/flat_hash_set.h"
#include "google/protobuf/compiler/cpp/enum.h"
#include "google/protobuf/compiler/cpp/extension.h"
#include "google/protobuf/compiler/cpp/field.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/port.h"
#include "google/protobuf/compiler/scc.h"
#include "google/protobuf/compiler/cpp/message.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/compiler/cpp/service.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/port.h"
namespace google {
namespace protobuf {
class FileDescriptor; // descriptor.h
namespace io {
class Printer; // printer.h
}
} // namespace protobuf
} // namespace google
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
class EnumGenerator; // enum.h
class MessageGenerator; // message.h
class ServiceGenerator; // service.h
class ExtensionGenerator; // extension.h
class FileGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
FileGenerator(const FileDescriptor* file, const Options& options);
FileGenerator(const FileGenerator&) = delete;
FileGenerator& operator=(const FileGenerator&) = delete;
~FileGenerator();
// Shared code between the two header generators below.
void GenerateHeader(io::Printer* printer);
~FileGenerator() = default;
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this proto header.
void GenerateProtoHeader(io::Printer* printer, const std::string& info_path);
void GenerateProtoHeader(io::Printer* p, absl::string_view info_path);
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this PB header.
void GeneratePBHeader(io::Printer* printer, const std::string& info_path);
void GenerateSource(io::Printer* printer);
void GeneratePBHeader(io::Printer* p, absl::string_view info_path);
void GenerateSource(io::Printer* p);
// The following member functions are used when the lite_implicit_weak_fields
// option is set. In this mode the code is organized a bit differently to
@ -95,80 +87,86 @@ class FileGenerator {
int NumMessages() const { return message_generators_.size(); }
int NumExtensions() const { return extension_generators_.size(); }
// Generates the source file for one message.
void GenerateSourceForMessage(int idx, io::Printer* printer);
void GenerateSourceForMessage(int idx, io::Printer* p);
// Generates the source file for one extension.
void GenerateSourceForExtension(int idx, io::Printer* printer);
void GenerateSourceForExtension(int idx, io::Printer* p);
// Generates a source file containing everything except messages and
// extensions.
void GenerateGlobalSource(io::Printer* printer);
void GenerateGlobalSource(io::Printer* p);
private:
// Generates a file, setting up the necessary accoutrements that start and
// end the file, calling `cb` in between.
//
// This includes header guards and file-global variables.
void GenerateFile(io::Printer* p, GeneratedFileType file_type,
std::function<void()> cb);
// Shared code between the two header generators.
void GenerateSharedHeaderCode(io::Printer* p);
// Internal type used by GenerateForwardDeclarations (defined in file.cc).
class ForwardDeclarations;
struct CrossFileReferences;
void IncludeFile(const std::string& google3_name, io::Printer* printer) {
DoIncludeFile(google3_name, false, printer);
void IncludeFile(absl::string_view google3_name, io::Printer* p) {
DoIncludeFile(google3_name, false, p);
}
void IncludeFileAndExport(const std::string& google3_name,
io::Printer* printer) {
DoIncludeFile(google3_name, true, printer);
void IncludeFileAndExport(absl::string_view google3_name, io::Printer* p) {
DoIncludeFile(google3_name, true, p);
}
void DoIncludeFile(const std::string& google3_name, bool do_export,
io::Printer* printer);
void DoIncludeFile(absl::string_view google3_name, bool do_export,
io::Printer* p);
std::string CreateHeaderInclude(const std::string& basename,
std::string CreateHeaderInclude(absl::string_view basename,
const FileDescriptor* file);
void GetCrossFileReferencesForField(const FieldDescriptor* field,
CrossFileReferences* refs);
void GetCrossFileReferencesForFile(const FileDescriptor* file,
CrossFileReferences* refs);
void GenerateInternalForwardDeclarations(const CrossFileReferences& refs,
io::Printer* printer);
void GenerateSourceIncludes(io::Printer* printer);
void GenerateSourcePrelude(io::Printer* printer);
void GenerateSourceDefaultInstance(int idx, io::Printer* printer);
io::Printer* p);
void GenerateSourceIncludes(io::Printer* p);
void GenerateSourcePrelude(io::Printer* p);
void GenerateSourceDefaultInstance(int idx, io::Printer* p);
void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs,
io::Printer* printer);
void GenerateReflectionInitializationCode(io::Printer* printer);
io::Printer* p);
void GenerateReflectionInitializationCode(io::Printer* p);
// For other imports, generates their forward-declarations.
void GenerateForwardDeclarations(io::Printer* printer);
void GenerateForwardDeclarations(io::Printer* p);
// Generates top or bottom of a header file.
void GenerateTopHeaderGuard(
io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type);
void GenerateBottomHeaderGuard(
io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type);
void GenerateTopHeaderGuard(io::Printer* p, GeneratedFileType file_type);
void GenerateBottomHeaderGuard(io::Printer* p, GeneratedFileType file_type);
// Generates #include directives.
void GenerateLibraryIncludes(io::Printer* printer);
void GenerateDependencyIncludes(io::Printer* printer);
void GenerateLibraryIncludes(io::Printer* p);
void GenerateDependencyIncludes(io::Printer* p);
// Generate a pragma to pull in metadata using the given info_path (if
// non-empty). info_path should be relative to printer's output.
void GenerateMetadataPragma(io::Printer* printer,
const std::string& info_path);
void GenerateMetadataPragma(io::Printer* p, absl::string_view info_path);
// Generates a couple of different pieces before definitions:
void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
void GenerateGlobalStateFunctionDeclarations(io::Printer* p);
// Generates types for classes.
void GenerateMessageDefinitions(io::Printer* printer);
void GenerateMessageDefinitions(io::Printer* p);
void GenerateEnumDefinitions(io::Printer* printer);
void GenerateEnumDefinitions(io::Printer* p);
// Generates generic service definitions.
void GenerateServiceDefinitions(io::Printer* printer);
void GenerateServiceDefinitions(io::Printer* p);
// Generates extension identifiers.
void GenerateExtensionIdentifiers(io::Printer* printer);
void GenerateExtensionIdentifiers(io::Printer* p);
// Generates inline function definitions.
void GenerateInlineFunctionDefinitions(io::Printer* printer);
void GenerateInlineFunctionDefinitions(io::Printer* p);
void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
void GenerateProto2NamespaceEnumSpecializations(io::Printer* p);
// Sometimes the names we use in a .proto file happen to be defined as
// macros on some platforms (e.g., macro/minor used in plugin.proto are
@ -177,7 +175,7 @@ class FileGenerator {
// undef the macro for these few platforms, or rename the field name for all
// platforms. Since these names are part of protobuf public API, renaming is
// generally a breaking change so we prefer the #undef approach.
void GenerateMacroUndefs(io::Printer* printer);
void GenerateMacroUndefs(io::Printer* p);
bool IsDepWeak(const FileDescriptor* dep) const {
if (weak_deps_.count(dep) != 0) {
@ -187,13 +185,16 @@ class FileGenerator {
return false;
}
std::set<const FileDescriptor*> weak_deps_;
absl::flat_hash_set<const FileDescriptor*> weak_deps_;
const FileDescriptor* file_;
const Options options_;
Options options_;
MessageSCCAnalyzer scc_analyzer_;
// This member is unused and should be deleted once all old-style variable
// maps are gone.
// TODO(b/245791219)
std::map<std::string, std::string> variables_;
// Contains the post-order walk of all the messages (and child messages) in

@ -70,6 +70,9 @@ absl::flat_hash_map<std::string, std::string> CommonVars(
{"uint32", "uint32_t"},
{"uint64", "uint64_t"},
{"hrule_thick", kThickSeparator},
{"hrule_thin", kThinSeparator},
// Warning: there is some clever naming/splitting here to avoid extract
// script rewrites. The names of these variables must not be things that
// the extract script will rewrite. That's why we use "CHK" (for example)
@ -83,9 +86,11 @@ absl::flat_hash_map<std::string, std::string> CommonVars(
: "GOOGLE3_PROTOBU"
"F"},
{"CHK", is_oss ? "GOOGLE_CHECK"
: "CHECK"},
: "CHEC"
"K"},
{"DCHK", is_oss ? "GOOGLE_DCHECK"
: "DCHECK"},
: "DCHEC"
"K"},
};
}
} // namespace

@ -43,6 +43,7 @@
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "google/protobuf/stubs/common.h"
@ -1087,6 +1088,46 @@ bool IsWellKnownMessage(const FileDescriptor* file) {
return well_known_files->find(file->name()) != well_known_files->end();
}
void NamespaceOpener::ChangeTo(absl::string_view name) {
std::vector<std::string> new_stack =
absl::StrSplit(name, "::", absl::SkipEmpty());
size_t len = std::min(name_stack_.size(), new_stack.size());
size_t common_idx = 0;
while (common_idx < len) {
if (name_stack_[common_idx] != new_stack[common_idx]) {
break;
}
++common_idx;
}
for (size_t i = name_stack_.size(); i > common_idx; i--) {
const auto& ns = name_stack_[i - 1];
if (ns == "PROTOBUF_NAMESPACE_ID") {
p_->Emit(R"cc(
PROTOBUF_NAMESPACE_CLOSE
)cc");
} else {
p_->Emit({{"ns", ns}}, R"(
} // namespace $ns$
)");
}
}
for (size_t i = common_idx; i < new_stack.size(); ++i) {
const auto& ns = new_stack[i];
if (ns == "PROTOBUF_NAMESPACE_ID") {
p_->Emit(R"cc(
PROTOBUF_NAMESPACE_OPEN
)cc");
} else {
p_->Emit({{"ns", ns}}, R"(
namespace $ns$ {
)");
}
}
name_stack_ = std::move(new_stack);
}
static void GenerateUtf8CheckCode(const FieldDescriptor* field,
const Options& options, bool for_parse,
const char* parameters,

@ -44,7 +44,7 @@
#include "google/protobuf/compiler/scc.h"
#include "google/protobuf/compiler/code_generator.h"
#include "absl/container/flat_hash_map.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/match.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/compiler/cpp/names.h"
#include "google/protobuf/compiler/cpp/options.h"
@ -52,6 +52,7 @@
#include "google/protobuf/io/printer.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/str_cat.h"
// Must be included last.
@ -887,43 +888,21 @@ void PrintFieldComment(const Formatter& format, const T* field) {
class PROTOC_EXPORT NamespaceOpener {
public:
explicit NamespaceOpener(const Formatter& format)
: printer_(format.printer()) {}
NamespaceOpener(const std::string& name, const Formatter& format)
explicit NamespaceOpener(io::Printer* p) : p_(p) {}
explicit NamespaceOpener(const Formatter& format) : p_(format.printer()) {}
NamespaceOpener(absl::string_view name, const Formatter& format)
: NamespaceOpener(format) {
ChangeTo(name);
}
NamespaceOpener(absl::string_view name, io::Printer* p) : NamespaceOpener(p) {
ChangeTo(name);
}
~NamespaceOpener() { ChangeTo(""); }
void ChangeTo(const std::string& name) {
std::vector<std::string> new_stack_ =
absl::StrSplit(name, "::", absl::SkipEmpty());
size_t len = std::min(name_stack_.size(), new_stack_.size());
size_t common_idx = 0;
while (common_idx < len) {
if (name_stack_[common_idx] != new_stack_[common_idx]) break;
common_idx++;
}
for (auto it = name_stack_.crbegin();
it != name_stack_.crend() - common_idx; ++it) {
if (*it == "PROTOBUF_NAMESPACE_ID") {
printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n");
} else {
printer_->Print("} // namespace $ns$\n", "ns", *it);
}
}
name_stack_.swap(new_stack_);
for (size_t i = common_idx; i < name_stack_.size(); ++i) {
if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") {
printer_->Print("PROTOBUF_NAMESPACE_OPEN\n");
} else {
printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]);
}
}
}
void ChangeTo(absl::string_view name);
private:
io::Printer* printer_;
io::Printer* p_;
std::vector<std::string> name_stack_;
};

@ -630,11 +630,11 @@ void ParseFunctionGenerator::GenerateFastFieldEntries(Formatter& format) {
std::string func_name = info.func_name;
// For 1-byte tags we have a more optimized version of the varint parser
// that can hardcode the offset and has bit.
if (HasSuffixString(func_name, "V8S1") ||
HasSuffixString(func_name, "V32S1") ||
HasSuffixString(func_name, "V64S1")) {
std::string field_type = HasSuffixString(func_name, "V8S1") ? "bool"
: HasSuffixString(func_name, "V32S1")
if (absl::EndsWith(func_name, "V8S1") ||
absl::EndsWith(func_name, "V32S1") ||
absl::EndsWith(func_name, "V64S1")) {
std::string field_type = absl::EndsWith(func_name, "V8S1") ? "bool"
: absl::EndsWith(func_name, "V32S1")
? "uint32_t"
: "uint64_t";
func_name =

@ -56,7 +56,7 @@ cc_library(
"//src/google/protobuf/compiler:__pkg__",
],
deps = [
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",

@ -33,9 +33,6 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/descriptor.h"

@ -33,22 +33,13 @@
#include <sstream>
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {

@ -37,21 +37,11 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_names.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
// Must be last.
#include "google/protobuf/port_def.inc"

@ -32,17 +32,13 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__
#include <string>
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/csharp/csharp_source_generator_base.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h"

@ -34,16 +34,6 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_names.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/compiler/csharp/csharp_reflection_class.h"

@ -41,9 +41,7 @@
#include "absl/container/flat_hash_set.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/csharp/csharp_enum_field.h"
#include "google/protobuf/compiler/csharp/csharp_field_base.h"
@ -57,8 +55,6 @@
#include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h"
#include "google/protobuf/compiler/csharp/csharp_wrapper_field.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/wire_format.h"
// Must be last.
#include "google/protobuf/port_def.inc"

@ -39,11 +39,11 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/port_def.inc"
#include "google/protobuf/port.h"
namespace google {
namespace protobuf {

@ -34,20 +34,10 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {
@ -98,7 +88,7 @@ void MapFieldGenerator::GenerateMembers(io::Printer* printer) {
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) {
printer->Print(
variables_,
"$name$_.MergeFrom(other.$name$_);\n");
"$name$_.Add(other.$name$_);\n");
}
void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {

@ -35,27 +35,18 @@
#include <sstream>
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_enum.h"
#include "google/protobuf/compiler/csharp/csharp_field_base.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_names.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/wire_format_lite.h"
// Must be last.
#include "google/protobuf/port_def.inc"

@ -34,23 +34,11 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/wire_format.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {

@ -39,8 +39,6 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__
#include <string>
#include "google/protobuf/port.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/port_def.inc"

@ -33,22 +33,13 @@
#include <sstream>
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/csharp/csharp_doc_comment.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
namespace google {
namespace protobuf {

@ -33,25 +33,16 @@
#include <sstream>
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_join.h"
#include "google/protobuf/compiler/csharp/csharp_enum.h"
#include "google/protobuf/compiler/csharp/csharp_field_base.h"
#include "google/protobuf/compiler/csharp/csharp_helpers.h"
#include "google/protobuf/compiler/csharp/csharp_message.h"
#include "google/protobuf/compiler/csharp/csharp_names.h"
#include "google/protobuf/compiler/csharp/csharp_options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h"
// Must be last.
#include "google/protobuf/port_def.inc"

@ -48,7 +48,7 @@
#include <memory>
#include <vector>
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/match.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
@ -282,7 +282,7 @@ static std::string CanonicalizePath(absl::string_view path) {
// backslashes are standard. Let's avoid confusion and use only forward
// slashes.
std::string path_str;
if (HasPrefixString(path, "\\\\")) {
if (absl::StartsWith(path, "\\\\")) {
// Avoid converting two leading backslashes.
path_str = "\\\\" + absl::StrReplaceAll(path.substr(2), {{"\\", "/"}});
} else {
@ -306,8 +306,8 @@ static std::string CanonicalizePath(absl::string_view path) {
}
static inline bool ContainsParentReference(absl::string_view path) {
return path == ".." || HasPrefixString(path, "../") ||
HasSuffixString(path, "/..") || absl::StrContains(path, "/../");
return path == ".." || absl::StartsWith(path, "../") ||
absl::EndsWith(path, "/..") || absl::StrContains(path, "/../");
}
// Maps a file from an old location to a new one. Typically, old_prefix is
@ -336,7 +336,7 @@ static bool ApplyMapping(absl::string_view filename,
// We do not allow the file name to use "..".
return false;
}
if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) {
if (absl::StartsWith(filename, "/") || IsWindowsAbsolutePath(filename)) {
// This is an absolute path, so it isn't matched by the empty string.
return false;
}
@ -344,7 +344,7 @@ static bool ApplyMapping(absl::string_view filename,
if (!result->empty()) result->push_back('/');
result->append(std::string(filename));
return true;
} else if (HasPrefixString(filename, old_prefix)) {
} else if (absl::StartsWith(filename, old_prefix)) {
// old_prefix is a prefix of the filename. Is it the whole filename?
if (filename.size() == old_prefix.size()) {
// Yep, it's an exact match.

@ -81,7 +81,7 @@ cc_library(
"//src/google/protobuf/compiler:__pkg__",
],
deps = [
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",

@ -221,7 +221,7 @@ std::string ToCamelCase(const std::string& input, bool lower_first) {
if (i == '_') {
capitalize_next = true;
} else if (capitalize_next) {
result.push_back(ToUpperCh(i));
result.push_back(absl::ascii_toupper(i));
capitalize_next = false;
} else {
result.push_back(i);
@ -230,20 +230,12 @@ std::string ToCamelCase(const std::string& input, bool lower_first) {
// Lower-case the first letter.
if (lower_first && !result.empty()) {
result[0] = ToLowerCh(result[0]);
result[0] = absl::ascii_tolower(result[0]);
}
return result;
}
char ToUpperCh(char ch) {
return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
}
char ToLowerCh(char ch) {
return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
}
std::string UnderscoresToCamelCase(const FieldDescriptor* field) {
return UnderscoresToCamelCase(FieldName(field), false);
}

@ -84,9 +84,6 @@ void PrintEnumVerifierLogic(io::Printer* printer,
// first letter.
std::string ToCamelCase(const std::string& input, bool lower_first);
char ToUpperCh(char ch);
char ToLowerCh(char ch);
// Converts a name to camel-case. If cap_first_letter is true, capitalize the
// first letter.
std::string UnderscoresToCamelCase(const std::string& name,

@ -39,19 +39,18 @@
#include <memory>
#include <vector>
#include "google/protobuf/stubs/strutil.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/common.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/compiler/plugin.pb.h"
#include "google/protobuf/descriptor.pb.h"
#include <gtest/gtest.h>
#include "absl/strings/str_join.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h"
@ -208,8 +207,8 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
std::string* error) const {
bool annotate = false;
for (int i = 0; i < file->message_type_count(); i++) {
if (HasPrefixString(file->message_type(i)->name(), "MockCodeGenerator_")) {
std::string command = StripPrefixString(
if (absl::StartsWith(file->message_type(i)->name(), "MockCodeGenerator_")) {
absl::string_view command = absl::StripPrefix(
file->message_type(i)->name(), "MockCodeGenerator_");
if (command == "Error") {
*error = "Saw message type MockCodeGenerator_Error.";
@ -252,12 +251,12 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
}
}
bool insert_endlines = HasPrefixString(parameter, "insert_endlines=");
if (insert_endlines || HasPrefixString(parameter, "insert=")) {
bool insert_endlines = absl::StartsWith(parameter, "insert_endlines=");
if (insert_endlines || absl::StartsWith(parameter, "insert=")) {
std::vector<std::string> insert_into = absl::StrSplit(
StripPrefixString(
parameter, insert_endlines ? "insert_endlines=" : "insert="),
",", absl::SkipEmpty());
absl::StripPrefix(parameter,
insert_endlines ? "insert_endlines=" : "insert="),
',', absl::SkipEmpty());
for (size_t i = 0; i < insert_into.size(); i++) {
{
@ -265,7 +264,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
std::string content =
GetOutputFileContent(name_, "first_insert", file, context);
if (insert_endlines) {
GlobalReplaceSubstring(",", ",\n", &content);
absl::StrReplaceAll({{",", ",\n"}}, &content);
}
if (annotate) {
auto* annotation = info.add_annotation();
@ -290,7 +289,7 @@ bool MockCodeGenerator::Generate(const FileDescriptor* file,
std::string content =
GetOutputFileContent(name_, "second_insert", file, context);
if (insert_endlines) {
GlobalReplaceSubstring(",", ",\n", &content);
absl::StrReplaceAll({{",", ",\n"}}, &content);
}
if (annotate) {
auto* annotation = info.add_annotation();

@ -35,6 +35,7 @@ cc_library(
"objectivec_message_field.h",
"objectivec_nsobject_methods.h",
"objectivec_oneof.h",
"objectivec_options.h",
"objectivec_primitive_field.h",
],
copts = COPTS,
@ -44,7 +45,7 @@ cc_library(
"//src/google/protobuf/compiler:__pkg__",
],
deps = [
"//:protobuf",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/strings",
],

@ -28,22 +28,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/compiler/objectivec/objectivec_enum.h"
#include <algorithm>
#include <map>
#include <string>
#include "google/protobuf/compiler/objectivec/objectivec_enum.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/objectivec_helpers.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include <algorithm> // std::find()
namespace google {
namespace protobuf {

@ -28,20 +28,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/compiler/objectivec/objectivec_extension.h"
#include <iostream>
#include "google/protobuf/compiler/objectivec/objectivec_extension.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/objectivec_helpers.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "google/protobuf/io/printer.h"
namespace google {

@ -28,24 +28,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/compiler/objectivec/objectivec_field.h"
#include <iostream>
#include "google/protobuf/compiler/objectivec/objectivec_field.h"
#include "google/protobuf/compiler/objectivec/objectivec_helpers.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/compiler/objectivec/objectivec_enum_field.h"
#include "google/protobuf/compiler/objectivec/objectivec_helpers.h"
#include "google/protobuf/compiler/objectivec/objectivec_map_field.h"
#include "google/protobuf/compiler/objectivec/objectivec_message_field.h"
#include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/stubs/strutil.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_split.h"
#include "absl/strings/str_replace.h"
namespace google {
namespace protobuf {

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

Loading…
Cancel
Save