Merge with main to fix unrelated tests.

pull/14562/head
Deanna Garcia 1 year ago
commit a27b3e6695
  1. 44
      .github/workflows/janitor.yml
  2. 1
      .github/workflows/staleness_check.yml
  3. 8
      .github/workflows/staleness_refresh.yml
  4. 1
      .github/workflows/test_upb.yml
  5. 2
      CMakeLists.txt
  6. 2
      Protobuf-C++.podspec
  7. 2
      Protobuf.podspec
  8. 5
      WORKSPACE
  9. 2
      csharp/Google.Protobuf.Tools.nuspec
  10. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  11. 47
      docs/third_party.md
  12. 6
      java/README.md
  13. 2
      java/bom/pom.xml
  14. 2
      java/core/pom.xml
  15. 2
      java/kotlin-lite/pom.xml
  16. 2
      java/kotlin/pom.xml
  17. 2
      java/lite.md
  18. 2
      java/lite/pom.xml
  19. 2
      java/pom.xml
  20. 2
      java/protoc/pom.xml
  21. 2
      java/util/pom.xml
  22. 3
      php/ext/google/protobuf/php-upb.h
  23. 2
      php/ext/google/protobuf/protobuf.h
  24. 10
      protobuf_version.bzl
  25. 2
      python/google/protobuf/__init__.py
  26. 2
      ruby/google-protobuf.gemspec
  27. 4
      ruby/pom.xml
  28. 2
      src/file_lists.cmake
  29. 4
      src/google/protobuf/any.pb.h
  30. 4
      src/google/protobuf/api.pb.h
  31. 204
      src/google/protobuf/compiler/cpp/extension.cc
  32. 4
      src/google/protobuf/compiler/cpp/extension.h
  33. 8
      src/google/protobuf/compiler/java/java_features.pb.cc
  34. 11
      src/google/protobuf/compiler/java/java_features.pb.h
  35. 10
      src/google/protobuf/compiler/java/message_field.cc
  36. 18
      src/google/protobuf/compiler/java/message_lite.cc
  37. 4
      src/google/protobuf/compiler/plugin.pb.h
  38. 15
      src/google/protobuf/compiler/rust/accessors/accessors.cc
  39. 9
      src/google/protobuf/compiler/rust/accessors/singular_message.cc
  40. 43
      src/google/protobuf/compiler/rust/context.h
  41. 23
      src/google/protobuf/compiler/rust/generator.cc
  42. 3
      src/google/protobuf/compiler/rust/oneof.cc
  43. 10
      src/google/protobuf/cpp_features.pb.cc
  44. 11
      src/google/protobuf/cpp_features.pb.h
  45. 4
      src/google/protobuf/descriptor.pb.h
  46. 4
      src/google/protobuf/duration.pb.h
  47. 4
      src/google/protobuf/empty.pb.h
  48. 14
      src/google/protobuf/extension_set.cc
  49. 71
      src/google/protobuf/extension_set.h
  50. 4
      src/google/protobuf/field_mask.pb.h
  51. 8
      src/google/protobuf/port_def.inc
  52. 4
      src/google/protobuf/source_context.pb.h
  53. 4
      src/google/protobuf/struct.pb.h
  54. 8
      src/google/protobuf/stubs/common.h
  55. 4
      src/google/protobuf/timestamp.pb.h
  56. 4
      src/google/protobuf/type.pb.h
  57. 4
      src/google/protobuf/wrappers.pb.h
  58. 13
      upb/cmake/CMakeLists.txt
  59. 30
      version.json

@ -28,3 +28,47 @@ jobs:
echo "Closing #$pr..."
gh pr close --comment "Auto-closing Copybara pull request" --delete-branch "$pr"
done
stale-others:
name: Close stale non-copybara PRs and issues
runs-on: ubuntu-latest
steps:
- uses: actions/stale@b69b346013879cedbf50c69f572cd85439a41936
with:
stale-issue-message: >
We triage inactive PRs and issues in order to make it easier to find
active work. If this issue should remain active or becomes active
again, please add a comment.
This issue is labeled `inactive` because the last activity was over
90 days ago.
close-pr-message: >
We triage inactive PRs and issues in order to make it easier to find
active work. If this issue should remain active or becomes active
again, please reopen it.
This issue was closed and archived because there has been no new
activity in the 14 days since the `inactive` label was added.
stale-pr-message: >
We triage inactive PRs and issues in order to make it easier to find
active work. If this PR should remain active, please add a comment.
This PR is labeled `inactive` because the last activity was over 90
days ago. This PR will be closed and archived after 14 additional
days without activity.
close-pr-message: >
We triage inactive PRs and issues in order to make it easier to find
active work. If this PR should remain active or becomes active
again, please reopen it.
This PR was closed and archived because there has been no new
activity in the 14 days since the `inactive` label was added.
stale-issue-label: 'inactive'
stale-pr-label: 'inactive'
days-before-stale: 90
days-before-close: 14
operations-per-run: 100

@ -54,6 +54,7 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: staleness
bash: >
set -ex;
if [[ -z $COMMIT_TRIGGERED_RUN || -z $MAIN_RUN ]]; then
bazel query 'attr(tags, "staleness_test", //...)' | xargs bazel test $BAZEL_FLAGS ||
echo "Please run ./regenerate_stale_files.sh to regenerate stale files";

@ -30,10 +30,6 @@ jobs:
# failing then you may need to generate a fresh token.
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Configure name and email address in Git
run: git config user.name "Protobuf Team Bot" && git config user.email "protobuf-team-bot@google.com"
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
uses: protocolbuffers/protobuf-ci/bazel@v2
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: staleness
bash: ci/push_auto_update.sh
run: cd ${{ github.workspace }} && ./ci/push_auto_update.sh

@ -100,6 +100,7 @@ jobs:
with:
cache: pip
cache-dependency-path: 'python/requirements.txt'
python-version: '3.11' # 3.12 doesn't have setuptools
- name: Run tests
uses: protocolbuffers/protobuf-ci/bazel@v2
with:

@ -79,7 +79,7 @@ if (protobuf_BUILD_SHARED_LIBS)
endif ()
# Version metadata
set(protobuf_VERSION_STRING "4.24.0")
set(protobuf_VERSION_STRING "4.25.0")
set(protobuf_DESCRIPTION "Protocol Buffers")
set(protobuf_CONTACT "protobuf@googlegroups.com")

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

@ -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.24.0'
s.version = '3.25.0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'

@ -1,5 +1,10 @@
workspace(name = "com_google_protobuf")
# An explicit self-reference to work around changes in Bazel 7.0
# See https://github.com/bazelbuild/bazel/issues/19973#issuecomment-1787814450
# buildifier: disable=duplicated-name
local_repository(name = "com_google_protobuf", path = ".")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
local_repository(

@ -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.24.0</version>
<version>3.25.0</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>

@ -5,7 +5,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.24.0</VersionPrefix>
<VersionPrefix>3.25.0</VersionPrefix>
<LangVersion>10.0</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks>

@ -169,9 +169,7 @@ Inactive:
* https://github.com/thesamet/rpcz (C++/Python, based on ZeroMQ)
* https://github.com/w359405949/libmaid (C++, Python)
## Other Utilities
There are miscellaneous other things you may find useful as a Protocol Buffers developer.
## Build
* [Bazel Build](https://bazel.build)
* [rules_closure](https://github.com/bazelbuild/rules_closure)
@ -179,17 +177,6 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
* [rules_go](https://github.com/bazelbuild/rules_go) `go`
* [rules_protobuf](https://github.com/pubref/rules_protobuf) `java` `c++`
`c#` `go` `js-closure` `js-node` `python` `ruby`
* [NetBeans IDE plugin](https://code.google.com/p/protobuf-netbeans-plugin/)
* [Wireshark/Ethereal packet sniffer plugin](https://code.google.com/p/protobuf-wireshark/)
* [Alternate encodings (JSON, XML, HTML) for Java protobufs](https://code.google.com/p/protobuf-java-format/)
* [Another JSON encoder/decoder for Java](https://github.com/sijuv/protobuf-codec)
* [Editor for serialized protobufs](https://code.google.com/p/protobufeditor/)
* [IntelliJ IDEA plugin](http://github.com/jvolkman/intellij-protobuf-editor)
* [IntelliJ Protobuf Plugin](https://github.com/devkanro/intellij-protobuf-plugin)
* [TextMate syntax highlighting](http://github.com/michaeledgar/protobuf-tmbundle)
* [Oracle PL SQL plugin](https://code.google.com/p/protocol-buffer-plsql/)
* [Eclipse editor for protobuf (from Google)](https://code.google.com/p/protobuf-dt/)
* [C++ Builder compatible protobuf](https://github.com/saadware/protobuf-cppbuilder)
* Maven Protobuf Compiler Plugin
* By xolstice.org
([Documentation](https://www.xolstice.org/protobuf-maven-plugin/))
@ -197,21 +184,43 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
[![Maven Central](https://img.shields.io/maven-central/v/org.xolstice.maven.plugins/protobuf-maven-plugin.svg)](https://repo1.maven.org/maven2/org/xolstice/maven/plugins/protobuf-maven-plugin/)
* https://code.google.com/p/maven-protoc-plugin/
* https://github.com/os72/protoc-jar-maven-plugin
* [Protobuf Plugin for Gradle](https://github.com/google/protobuf-gradle-plugin)
* [Sbt plugin for Protocol Buffers](https://github.com/Atry/sbt-cppp)
## IDE
* [Visual Studio Code Support for Protocol Buffers](https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3)
* [Visual Studio Language Service support for Protocol Buffers](http://visualstudiogallery.msdn.microsoft.com/4bc0f38c-b058-4e05-ae38-155e053c19c5)
* [IntelliJ IDEA plugin](http://github.com/jvolkman/intellij-protobuf-editor)
* [IntelliJ Protobuf Plugin](https://github.com/devkanro/intellij-protobuf-plugin)
* [TextMate syntax highlighting](http://github.com/michaeledgar/protobuf-tmbundle)
* [Notepad++ Syntax Highlighting for .proto files](https://github.com/chai2010/notepadplus-protobuf)
* [Eclipse editor for protobuf (from Google)](https://code.google.com/p/protobuf-dt/)
* [NetBeans IDE plugin](https://code.google.com/p/protobuf-netbeans-plugin/)
* [Editor for serialized protobufs](https://code.google.com/p/protobufeditor/)
## Documentation
* [Documentation generator plugin (Markdown/HTML/DocBook/...)](https://github.com/pseudomuto/protoc-gen-doc)
* [DocBook generator for .proto files](https://code.google.com/p/protoc-gen-docbook/)
## Other Utilities
There are miscellaneous other things you may find useful as a Protocol Buffers developer.
* [Wireshark/Ethereal packet sniffer plugin](https://code.google.com/p/protobuf-wireshark/)
* [Alternate encodings (JSON, XML, HTML) for Java protobufs](https://code.google.com/p/protobuf-java-format/)
* [Another JSON encoder/decoder for Java](https://github.com/sijuv/protobuf-codec)
* [Oracle PL SQL plugin](https://code.google.com/p/protocol-buffer-plsql/)
* [C++ Builder compatible protobuf](https://github.com/saadware/protobuf-cppbuilder)
* [Protobuf for nginx module](https://github.com/dbcode/protobuf-nginx/)
* [RSpec matchers and Cucumber step defs for testing Protocol Buffers](https://github.com/connamara/protobuf_spec)
* [Sbt plugin for Protocol Buffers](https://github.com/Atry/sbt-cppp)
* [Protobuf Plugin for Gradle](https://github.com/google/protobuf-gradle-plugin)
* [Multi-platform executable JAR and Java API for protoc](https://github.com/os72/protoc-jar)
* [Python scripts to convert between Protocol Buffers and JSON](https://github.com/NextTuesday/py-pb-converters)
* [Visual Studio Language Service support for Protocol Buffers](http://visualstudiogallery.msdn.microsoft.com/4bc0f38c-b058-4e05-ae38-155e053c19c5)
* [Visual Studio Code Support for Protocol Buffers](https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3)
* [C++ library for serialization/de-serialization between Protocol Buffers and
JSON.](https://github.com/yinqiwen/pbjson)
* [ProtoBuf with Java EE7 Expression Language 3.0; pure Java ProtoBuf Parser
and Builder.](https://github.com/protobufel/protobuf-el)
* [Notepad++ Syntax Highlighting for .proto files](https://github.com/chai2010/notepadplus-protobuf)
* [Linter for .proto files](https://github.com/ckaznocha/protoc-gen-lint)
* [Protocol Buffers Dynamic Schema - create protobuf schemas programmatically
(Java)](https://github.com/os72/protobuf-dynamic)

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.24.0</version>
<version>3.25.0</version>
</dependency>
```
@ -37,14 +37,14 @@ protobuf-java-util package:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.24.0</version>
<version>3.25.0</version>
</dependency>
```
### Gradle
If you are using Gradle, add the following to your `build.gradle` file's
dependencies: `implementation 'com.google.protobuf:protobuf-java:3.24.0'` Again,
dependencies: `implementation 'com.google.protobuf:protobuf-java:3.25.0'` 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.24.0</version>
<version>3.25.0</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.24.0</version>
<version>3.25.0</version>
</parent>
<artifactId>protobuf-java</artifactId>

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

@ -4,7 +4,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.24.0</version>
<version>3.25.0</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.24.0</version>
<version>3.25.0</version>
</dependency>
```

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

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

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

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

@ -10735,12 +10735,11 @@ bool _upb_DefPool_LoadDefInitEx(upb_DefPool* s, const _upb_DefPool_Init* init,
#endif /* UPB_REFLECTION_DEF_POOL_INTERNAL_H_ */
#ifdef __cplusplus
extern "C" {
#endif
extern _upb_DefPool_Init google_protobuf_descriptor_proto_upbdefinit;
UPB_INLINE const upb_MessageDef *google_protobuf_FileDescriptorSet_getmsgdef(upb_DefPool *s) {

@ -32,7 +32,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.24.0"
#define PHP_PROTOBUF_VERSION "3.25.0"
// ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types:

@ -1,6 +1,6 @@
""" Contains version numbers to be used in other bzl files """
PROTOC_VERSION = "24.0"
PROTOBUF_JAVA_VERSION = "3.24.0"
PROTOBUF_PYTHON_VERSION = "4.24.0"
PROTOBUF_PHP_VERSION = "3.24.0"
PROTOBUF_RUBY_VERSION = "3.24.0"
PROTOC_VERSION = "25.0"
PROTOBUF_JAVA_VERSION = "3.25.0"
PROTOBUF_PYTHON_VERSION = "4.25.0"
PROTOBUF_PHP_VERSION = "3.25.0"
PROTOBUF_RUBY_VERSION = "3.25.0"

@ -7,4 +7,4 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '4.24.0'
__version__ = '4.25.0'

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.24.0"
s.version = "3.25.0"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
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.24.0</version>
<version>3.25.0</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.24.0</version>
<version>3.25.0</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>

@ -117,6 +117,7 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_database.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_legacy.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_visitor.h
${protobuf_SOURCE_DIR}/src/google/protobuf/dynamic_message.h
${protobuf_SOURCE_DIR}/src/google/protobuf/endian.h
@ -242,6 +243,7 @@ set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_cleanup.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arenastring.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arenaz_sampler.h
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_lite.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

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,9 +11,12 @@
#include "google/protobuf/compiler/cpp/extension.h"
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
@ -77,97 +80,134 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["scope"] = scope;
variables_["scoped_name"] = ExtensionName(descriptor_);
variables_["number"] = absl::StrCat(descriptor_->number());
bool add_verify_fn =
// Only verify msgs.
descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
// Options say to verify.
ShouldVerify(descriptor_->message_type(), options_, scc_analyzer_) &&
ShouldVerify(descriptor_->containing_type(), options_, scc_analyzer_);
variables_["verify_fn"] =
add_verify_fn
? absl::StrCat("&", FieldMessageTypeName(descriptor_, options_),
"::InternalVerify")
: "nullptr";
}
ExtensionGenerator::~ExtensionGenerator() {}
ExtensionGenerator::~ExtensionGenerator() = default;
bool ExtensionGenerator::IsScoped() const {
return descriptor_->extension_scope() != nullptr;
}
void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) const {
Formatter format(printer, variables_);
// If this is a class member, it needs to be declared "static". Otherwise,
// it needs to be "extern". In the latter case, it also needs the DLL
// export/import specifier.
std::string qualifier;
if (!IsScoped()) {
qualifier = "extern";
if (!options_.dllexport_decl.empty()) {
qualifier = absl::StrCat(options_.dllexport_decl, " ", qualifier);
}
} else {
qualifier = "static";
}
format(
"static const int $constant_name$ = $number$;\n"
"$1$ ::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
" ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n"
" ${2$$name$$}$;\n",
qualifier, descriptor_);
void ExtensionGenerator::GenerateDeclaration(io::Printer* p) const {
auto var = p->WithVars(variables_);
auto annotate = p->WithAnnotations({{"name", descriptor_}});
p->Emit({{"qualifier",
// If this is a class member, it needs to be declared "static".
// Otherwise, it needs to be "extern". In the latter case, it
// also needs the DLL export/import specifier.
IsScoped() ? "static"
: options_.dllexport_decl.empty()
? "extern"
: absl::StrCat(options_.dllexport_decl, " extern")}},
R"cc(
static const int $constant_name$ = $number$;
$qualifier$ ::$proto_ns$::internal::ExtensionIdentifier<
$extendee$, ::$proto_ns$::internal::$type_traits$, $field_type$,
$packed$>
$name$;
)cc");
}
void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
Formatter format(printer, variables_);
std::string default_str;
// If this is a class member, it needs to be declared in its class scope.
if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
// We need to declare a global string which will contain the default value.
// We cannot declare it at class scope because that would require exposing
// it in the header which would be annoying for other reasons. So we
// replace :: with _ in the name and declare it as a global.
default_str =
absl::StrReplaceAll(variables_["scoped_name"], {{"::", "_"}}) +
"_default";
format("const std::string $1$($2$);\n", default_str,
DefaultValue(options_, descriptor_));
} else if (descriptor_->message_type()) {
// We have to initialize the default instance for extensions at registration
// time.
default_str = absl::StrCat(FieldMessageTypeName(descriptor_, options_),
"::default_instance()");
} else {
default_str = DefaultValue(options_, descriptor_);
}
// Likewise, class members need to declare the field constant variable.
if (IsScoped()) {
format(
"#if !defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)\n"
"const int $scope$$constant_name$;\n"
"#endif\n");
}
if (IsLazilyInitializedFile(descriptor_->file()->name())) {
format(
"PROTOBUF_CONSTINIT$ dllexport_decl$ "
"PROTOBUF_ATTRIBUTE_INIT_PRIORITY2\n"
"::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
" ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$>\n"
" $scoped_name$($constant_name$);\n");
} else {
format(
"$dllexport_decl $PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 "
"::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
" ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$>\n"
" $scoped_name$($constant_name$, $1$, $verify_fn$);\n",
default_str);
}
void ExtensionGenerator::GenerateDefinition(io::Printer* p) {
auto vars = p->WithVars(variables_);
auto generate_default_string = [&] {
if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
// We need to declare a global string which will contain the default
// value. We cannot declare it at class scope because that would require
// exposing it in the header which would be annoying for other reasons. So
// we replace :: with _ in the name and declare it as a global.
return absl::StrReplaceAll(variables_["scoped_name"], {{"::", "_"}}) +
"_default";
} else if (descriptor_->message_type()) {
// We have to initialize the default instance for extensions at
// registration time.
return absl::StrCat(FieldMessageTypeName(descriptor_, options_),
"::default_instance()");
} else {
return DefaultValue(options_, descriptor_);
}
};
auto local_var = p->WithVars({
{"default_str", generate_default_string()},
{"default_val", DefaultValue(options_, descriptor_)},
{"message_type", descriptor_->message_type() != nullptr
? FieldMessageTypeName(descriptor_, options_)
: ""},
});
p->Emit(
{
{"declare_default_str",
[&] {
if (descriptor_->cpp_type() != FieldDescriptor::CPPTYPE_STRING)
return;
// If this is a class member, it needs to be declared in its class
// scope.
p->Emit(R"cc(
const std::string $default_str$($default_val$);
)cc");
}},
{"declare_const_var",
[&] {
if (!IsScoped()) return;
// Likewise, class members need to declare the field constant
// variable.
p->Emit(R"cc(
#if !defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)
const int $scope$$constant_name$;
#endif
)cc");
}},
{"define_extension_id",
[&] {
if (IsLazilyInitializedFile(descriptor_->file()->name())) {
p->Emit(R"cc(
PROTOBUF_CONSTINIT$ dllexport_decl$
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::$proto_ns$::internal::
ExtensionIdentifier<
$extendee$, ::$proto_ns$::internal::$type_traits$,
$field_type$, $packed$>
$scoped_name$($constant_name$);
)cc");
return;
}
bool should_verify =
// Only verify msgs.
descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
// Options say to verify.
ShouldVerify(descriptor_->message_type(), options_,
scc_analyzer_) &&
ShouldVerify(descriptor_->containing_type(), options_,
scc_analyzer_);
if (should_verify) {
p->Emit(R"cc(
$dllexport_decl $PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::
$proto_ns$::internal::ExtensionIdentifier<
$extendee$, ::$proto_ns$::internal::$type_traits$,
$field_type$, $packed$>
$scoped_name$($constant_name$, $default_str$,
&$message_type$::InternalVerify);
)cc");
} else {
p->Emit(R"cc(
$dllexport_decl $PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::
$proto_ns$::internal::ExtensionIdentifier<
$extendee$, ::$proto_ns$::internal::$type_traits$,
$field_type$, $packed$>
$scoped_name$($constant_name$, $default_str$);
)cc");
}
}},
},
R"cc(
$declare_default_str$;
$declare_const_var$;
$define_extension_id$;
)cc");
}
} // namespace cpp

@ -51,10 +51,10 @@ class PROTOC_EXPORT ExtensionGenerator {
~ExtensionGenerator();
// Header stuff.
void GenerateDeclaration(io::Printer* printer) const;
void GenerateDeclaration(io::Printer* p) const;
// Source file stuff.
void GenerateDefinition(io::Printer* printer);
void GenerateDefinition(io::Printer* p);
bool IsScoped() const;

@ -375,9 +375,11 @@ void JavaFeatures::InternalSwap(JavaFeatures* PROTOBUF_RESTRICT other) {
&descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fjava_2fjava_5ffeatures_2eproto[0]);
}
PROTOC_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FeatureSet,
::google::protobuf::internal::MessageTypeTraits< ::pb::JavaFeatures >, 11, false>
java(kJavaFieldNumber, ::pb::JavaFeatures::default_instance(), nullptr);
PROTOC_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::
google::protobuf::internal::ExtensionIdentifier<
::google::protobuf::FeatureSet, ::google::protobuf::internal::MessageTypeTraits< ::pb::JavaFeatures >,
11, false>
java(kJavaFieldNumber, ::pb::JavaFeatures::default_instance());
// @@protoc_insertion_point(namespace_scope)
} // namespace pb
namespace google {

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."
@ -318,9 +318,10 @@ class PROTOC_EXPORT JavaFeatures final :
static const int kJavaFieldNumber = 1001;
PROTOC_EXPORT extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FeatureSet,
::google::protobuf::internal::MessageTypeTraits< ::pb::JavaFeatures >, 11, false >
java;
PROTOC_EXPORT extern ::google::protobuf::internal::ExtensionIdentifier<
::google::protobuf::FeatureSet, ::google::protobuf::internal::MessageTypeTraits< ::pb::JavaFeatures >, 11,
false>
java;
// ===================================================================

@ -342,7 +342,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" $on_changed$\n"
" return get$capitalized_name$FieldBuilder().getBuilder();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
printer->Annotate("{", "}", descriptor_, Semantic::kSet);
// FieldOrBuilder getFieldOrBuilder()
WriteFieldDocComment(printer, descriptor_, context_->options());
@ -692,7 +692,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
"${$get$capitalized_name$Builder$}$() {\n"
" return get$capitalized_name$FieldBuilder().getBuilder();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
printer->Annotate("{", "}", descriptor_, Semantic::kSet);
WriteFieldDocComment(printer, descriptor_, context_->options());
printer->Print(
variables_,
@ -730,7 +730,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" $on_changed$\n"
" return $name$Builder_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
printer->Annotate("{", "}", descriptor_, Semantic::kSet);
}
void ImmutableMessageOneofFieldGenerator::GenerateBuilderClearCode(
@ -1148,7 +1148,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" int index) {\n"
" return get$capitalized_name$FieldBuilder().getBuilder(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
printer->Annotate("{", "}", descriptor_, Semantic::kSet);
// FieldOrBuilder getRepeatedFieldOrBuilder(int index)
WriteFieldDocComment(printer, descriptor_, context_->options());
@ -1222,7 +1222,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
" return $name$Builder_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
printer->Annotate("{", "}", descriptor_, Semantic::kSet);
}
void RepeatedImmutableMessageFieldGenerator::

@ -69,25 +69,13 @@ ImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {}
void ImmutableMessageLiteGenerator::GenerateStaticVariables(
io::Printer* printer, int* bytecode_estimate) {
// Generate static members for all nested types.
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
// TODO: Reuse MessageGenerator objects?
ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
.GenerateStaticVariables(printer, bytecode_estimate);
}
// No-op for lite.
}
int ImmutableMessageLiteGenerator::GenerateStaticVariableInitializers(
io::Printer* printer) {
int bytecode_estimate = 0;
// Generate static member initializers for all nested types.
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
// TODO: Reuse MessageGenerator objects?
bytecode_estimate +=
ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
.GenerateStaticVariableInitializers(printer);
}
return bytecode_estimate;
// No-op for lite.
return 0;
}
// ===================================================================

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -23,7 +23,8 @@ namespace rust {
namespace {
std::unique_ptr<AccessorGenerator> AccessorGeneratorFor(
const FieldDescriptor& desc) {
Context<FieldDescriptor> field) {
const FieldDescriptor& desc = field.desc();
// TODO: We do not support [ctype=FOO] (used to set the field
// type in C++ to cord or string_piece) in V0.6 API.
if (desc.options().has_ctype()) {
@ -59,6 +60,12 @@ std::unique_ptr<AccessorGenerator> AccessorGeneratorFor(
if (desc.is_repeated()) {
return std::make_unique<UnsupportedField>("repeated msg not supported");
}
if (!field.generator_context().is_file_in_current_crate(
desc.message_type()->file())) {
return std::make_unique<UnsupportedField>(
"message fields that are imported from another proto_library"
" (defined in a separate Rust crate) are not supported");
}
return std::make_unique<SingularMessage>();
case FieldDescriptor::TYPE_ENUM:
@ -74,15 +81,15 @@ std::unique_ptr<AccessorGenerator> AccessorGeneratorFor(
} // namespace
void GenerateAccessorMsgImpl(Context<FieldDescriptor> field) {
AccessorGeneratorFor(field.desc())->GenerateMsgImpl(field);
AccessorGeneratorFor(field)->GenerateMsgImpl(field);
}
void GenerateAccessorExternC(Context<FieldDescriptor> field) {
AccessorGeneratorFor(field.desc())->GenerateExternC(field);
AccessorGeneratorFor(field)->GenerateExternC(field);
}
void GenerateAccessorThunkCc(Context<FieldDescriptor> field) {
AccessorGeneratorFor(field.desc())->GenerateThunkCc(field);
AccessorGeneratorFor(field)->GenerateThunkCc(field);
}
} // namespace rust

@ -5,7 +5,6 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/rust/accessors/accessor_generator.h"
@ -20,13 +19,9 @@ namespace rust {
void SingularMessage::InMsgImpl(Context<FieldDescriptor> field) const {
Context<Descriptor> d = field.WithDesc(field.desc().message_type());
auto prefix = "crate::" + GetCrateRelativeQualifiedPath(d);
// here we defer unit tests with messages that have import inside their
// pkg name e.g. unittest_import.proto
if (absl::StrContains(prefix, "import")) {
// TODO: Handle imports correctly, default to $Msg$View for now
prefix = field.desc().containing_type()->name();
}
if (field.is_cpp()) {
field.Emit({{"prefix", prefix},
{"field", field.desc().name()},

@ -8,10 +8,14 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_RUST_CONTEXT_H__
#define GOOGLE_PROTOBUF_COMPILER_RUST_CONTEXT_H__
#include <algorithm>
#include <vector>
#include "absl/log/absl_log.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h"
namespace google {
@ -43,6 +47,26 @@ struct Options {
static absl::StatusOr<Options> Parse(absl::string_view param);
};
class RustGeneratorContext {
public:
explicit RustGeneratorContext(
const std::vector<const FileDescriptor*>* files_in_current_crate)
: files_in_current_crate_(*files_in_current_crate) {}
const FileDescriptor* primary_file() const {
return files_in_current_crate_.front();
}
bool is_file_in_current_crate(const FileDescriptor* f) const {
return std::find(files_in_current_crate_.begin(),
files_in_current_crate_.end(),
f) != files_in_current_crate_.end();
}
private:
const std::vector<const FileDescriptor*>& files_in_current_crate_;
};
// A context for generating a particular kind of definition.
// This type acts as an options struct (as in go/totw/173) for most of the
// generator.
@ -52,14 +76,22 @@ struct Options {
template <typename Descriptor>
class Context {
public:
Context(const Options* opts, const Descriptor* desc, io::Printer* printer)
: opts_(opts), desc_(desc), printer_(printer) {}
Context(const Options* opts, const Descriptor* desc,
const RustGeneratorContext* rust_generator_context,
io::Printer* printer)
: opts_(opts),
desc_(desc),
rust_generator_context_(rust_generator_context),
printer_(printer) {}
Context(const Context&) = default;
Context& operator=(const Context&) = default;
const Descriptor& desc() const { return *desc_; }
const Options& opts() const { return *opts_; }
const RustGeneratorContext& generator_context() const {
return *rust_generator_context_;
}
bool is_cpp() const { return opts_->kernel == Kernel::kCpp; }
bool is_upb() const { return opts_->kernel == Kernel::kUpb; }
@ -70,16 +102,16 @@ class Context {
// Creates a new context over a different descriptor.
template <typename D>
Context<D> WithDesc(const D& desc) const {
return Context<D>(opts_, &desc, printer_);
return Context<D>(opts_, &desc, rust_generator_context_, printer_);
}
template <typename D>
Context<D> WithDesc(const D* desc) const {
return Context<D>(opts_, desc, printer_);
return Context<D>(opts_, desc, rust_generator_context_, printer_);
}
Context WithPrinter(io::Printer* printer) const {
return Context(opts_, desc_, printer);
return Context(opts_, desc_, rust_generator_context_, printer);
}
// Forwards to Emit(), which will likely be called all the time.
@ -97,6 +129,7 @@ class Context {
private:
const Options* opts_;
const Descriptor* desc_;
const RustGeneratorContext* rust_generator_context_;
io::Printer* printer_;
};
} // namespace rust

@ -123,11 +123,7 @@ void EmitPubUseForImportedMessages(Context<FileDescriptor>& primary_file,
}
// Emits all public imports of the current file
void EmitPublicImports(
Context<FileDescriptor>& primary_file,
const std::vector<const FileDescriptor*>& files_in_current_crate) {
absl::flat_hash_set<const FileDescriptor*> files(
files_in_current_crate.begin(), files_in_current_crate.end());
void EmitPublicImports(Context<FileDescriptor>& primary_file) {
for (int i = 0; i < primary_file.desc().public_dependency_count(); ++i) {
auto dep_file = primary_file.desc().public_dependency(i);
// If the publicly imported file is a src of the current `proto_library`
@ -137,7 +133,8 @@ void EmitPublicImports(
// TODO: Handle the case where a non-primary src with the same
// declared package as the primary src publicly imports a file that the
// primary doesn't.
if (files.contains(dep_file)) continue;
if (primary_file.generator_context().is_file_in_current_crate(dep_file))
continue;
auto dep = primary_file.WithDesc(dep_file);
EmitPubUseForImportedMessages(primary_file, dep);
}
@ -206,7 +203,13 @@ bool RustGenerator::Generate(const FileDescriptor* file_desc,
return false;
}
Context<FileDescriptor> file(&*opts, file_desc, nullptr);
std::vector<const FileDescriptor*> files_in_current_crate;
generator_context->ListParsedFiles(&files_in_current_crate);
RustGeneratorContext rust_generator_context(&files_in_current_crate);
Context<FileDescriptor> file(&*opts, file_desc, &rust_generator_context,
nullptr);
auto outfile = absl::WrapUnique(generator_context->Open(GetRsFile(file)));
io::Printer printer(outfile.get());
@ -228,15 +231,13 @@ bool RustGenerator::Generate(const FileDescriptor* file_desc,
)rs");
std::vector<const FileDescriptor*> files_in_current_crate;
generator_context->ListParsedFiles(&files_in_current_crate);
std::vector<Context<FileDescriptor>> file_contexts;
for (const FileDescriptor* f : files_in_current_crate) {
file_contexts.push_back(file.WithDesc(*f));
}
// Generating the primary file?
if (file_desc == files_in_current_crate.front()) {
if (file_desc == rust_generator_context.primary_file()) {
auto non_primary_srcs = absl::MakeConstSpan(file_contexts).subspan(1);
DeclareSubmodulesForNonPrimarySrcs(file, non_primary_srcs);
@ -252,7 +253,7 @@ bool RustGenerator::Generate(const FileDescriptor* file_desc,
}
}
EmitPublicImports(file, files_in_current_crate);
EmitPublicImports(file);
std::unique_ptr<io::ZeroCopyOutputStream> thunks_cc;
std::unique_ptr<io::Printer> thunks_printer;

@ -246,8 +246,7 @@ void GenerateOneofAccessors(Context<OneofDescriptor> oneof) {
if (rs_type.empty()) {
continue;
}
// TODO: Uncomment this to allow mut once
// _mut() on singular fields with presence is implemented.
// TODO: Allow mut.
/*oneof.Emit({
{"case", ToCamelCase(field->name())},
{"rs_getter", field->name() + "_mut"},

@ -298,10 +298,12 @@ void CppFeatures::InternalSwap(CppFeatures* PROTOBUF_RESTRICT other) {
&descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcpp_5ffeatures_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcpp_5ffeatures_2eproto[0]);
}
PROTOBUF_CONSTINIT PROTOBUF_EXPORT PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FeatureSet,
::google::protobuf::internal::MessageTypeTraits< ::pb::CppFeatures >, 11, false>
cpp(kCppFieldNumber);
PROTOBUF_CONSTINIT PROTOBUF_EXPORT
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 ::google::protobuf::internal::
ExtensionIdentifier<
::google::protobuf::FeatureSet, ::google::protobuf::internal::MessageTypeTraits< ::pb::CppFeatures >,
11, false>
cpp(kCppFieldNumber);
// @@protoc_insertion_point(namespace_scope)
} // namespace pb
namespace google {

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."
@ -253,9 +253,10 @@ class PROTOBUF_EXPORT CppFeatures final :
static const int kCppFieldNumber = 1000;
PROTOBUF_EXPORT extern ::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FeatureSet,
::google::protobuf::internal::MessageTypeTraits< ::pb::CppFeatures >, 11, false >
cpp;
PROTOBUF_EXPORT extern ::google::protobuf::internal::ExtensionIdentifier<
::google::protobuf::FeatureSet, ::google::protobuf::internal::MessageTypeTraits< ::pb::CppFeatures >, 11,
false>
cpp;
// ===================================================================

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,15 +11,19 @@
#include "google/protobuf/extension_set.h"
#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include "google/protobuf/stubs/common.h"
#include "absl/container/flat_hash_set.h"
#include "absl/hash/hash.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/extension_set_inl.h"
#include "google/protobuf/io/coded_stream.h"
@ -107,13 +111,11 @@ bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) {
void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed,
LazyEagerVerifyFnType verify_func) {
bool is_packed) {
ABSL_CHECK_NE(type, WireFormatLite::TYPE_ENUM);
ABSL_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);
ABSL_CHECK_NE(type, WireFormatLite::TYPE_GROUP);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed,
verify_func);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
Register(info);
}
@ -135,7 +137,7 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* extendee,
bool is_repeated, bool is_packed,
EnumValidityFunc* is_valid) {
ABSL_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed, nullptr);
ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
info.enum_validity_check.func = CallNoArgValidityFunc;
// See comment in CallNoArgValidityFunc() about why we use a c-style cast.
info.enum_validity_check.arg = (void*)is_valid;

@ -18,6 +18,8 @@
#include <algorithm>
#include <atomic>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <string>
#include <type_traits>
#include <utility>
@ -32,6 +34,7 @@
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/parse_context.h"
#include "google/protobuf/repeated_field.h"
#include "google/protobuf/repeated_ptr_field.h"
#include "google/protobuf/wire_format_lite.h"
// clang-format off
@ -90,6 +93,14 @@ typedef bool EnumValidityFuncWithArg(const void* arg, int number);
// Information about a registered extension.
struct ExtensionInfo {
constexpr ExtensionInfo() : enum_validity_check() {}
constexpr ExtensionInfo(const MessageLite* extendee, int param_number,
FieldType type_param, bool isrepeated, bool ispacked)
: message(extendee),
number(param_number),
type(type_param),
is_repeated(isrepeated),
is_packed(ispacked),
enum_validity_check() {}
constexpr ExtensionInfo(const MessageLite* extendee, int param_number,
FieldType type_param, bool isrepeated, bool ispacked,
LazyEagerVerifyFnType verify_func)
@ -190,8 +201,7 @@ class PROTOBUF_EXPORT ExtensionSet {
// methods do.
static void RegisterExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed,
LazyEagerVerifyFnType verify_func);
bool is_packed);
static void RegisterEnumExtension(const MessageLite* extendee, int number,
FieldType type, bool is_repeated,
bool is_packed, EnumValidityFunc* is_valid);
@ -1019,10 +1029,9 @@ class PrimitiveTypeTraits {
static inline void Set(int number, FieldType field_type, ConstType value,
ExtensionSet* set);
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType verify_func) {
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
type, false, is_packed, verify_func);
type, false, is_packed);
}
};
@ -1054,10 +1063,9 @@ class RepeatedPrimitiveTypeTraits {
static const RepeatedFieldType* GetDefaultRepeatedField();
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType verify_func) {
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
type, true, is_packed, verify_func);
type, true, is_packed);
}
};
@ -1178,10 +1186,9 @@ class PROTOBUF_EXPORT StringTypeTraits {
return set->MutableString(number, field_type, nullptr);
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType verify_func) {
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
type, false, is_packed, verify_func);
type, false, is_packed);
}
};
@ -1236,10 +1243,9 @@ class PROTOBUF_EXPORT RepeatedStringTypeTraits {
static const RepeatedFieldType* GetDefaultRepeatedField();
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterExtension(&ExtendeeT::default_instance(), number,
type, true, is_packed, fn);
type, true, is_packed);
}
private:
@ -1275,10 +1281,7 @@ class EnumTypeTraits {
set->SetEnum(number, field_type, value, nullptr);
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
// Avoid -Wunused-parameter
(void)fn;
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, false, is_packed, IsValid);
}
@ -1344,10 +1347,7 @@ class RepeatedEnumTypeTraits {
RepeatedPrimitiveTypeTraits<int32_t>::GetDefaultRepeatedField());
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
// Avoid -Wunused-parameter
(void)fn;
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterEnumExtension(&ExtendeeT::default_instance(), number,
type, true, is_packed, IsValid);
}
@ -1402,6 +1402,14 @@ class MessageTypeTraits {
return static_cast<Type*>(
set->UnsafeArenaReleaseMessage(number, Type::default_instance()));
}
// Some messages won't (can't) be verified; e.g. lite.
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
number, type, false, is_packed,
&Type::default_instance(), nullptr);
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
@ -1469,6 +1477,15 @@ class RepeatedMessageTypeTraits {
}
static const RepeatedFieldType* GetDefaultRepeatedField();
// Some messages won't (can't) be verified; e.g. lite.
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed) {
ExtensionSet::RegisterMessageExtension(&ExtendeeT::default_instance(),
number, type, true, is_packed,
&Type::default_instance(), nullptr);
}
template <typename ExtendeeT>
static void Register(int number, FieldType type, bool is_packed,
LazyEagerVerifyFnType fn) {
@ -1511,8 +1528,12 @@ class ExtensionIdentifier {
typedef TypeTraitsType TypeTraits;
typedef ExtendeeType Extendee;
ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value)
: number_(number), default_value_(default_value) {
Register(number);
}
ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value,
LazyEagerVerifyFnType verify_func = nullptr)
LazyEagerVerifyFnType verify_func)
: number_(number), default_value_(default_value) {
Register(number, verify_func);
}
@ -1521,6 +1542,10 @@ class ExtensionIdentifier {
return default_value_;
}
static void Register(int number) {
TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed);
}
static void Register(int number, LazyEagerVerifyFnType verify_func) {
TypeTraits::template Register<ExtendeeType>(number, field_type, is_packed,
verify_func);

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -204,17 +204,17 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined
#endif
#define PROTOBUF_VERSION 4024000
#define PROTOBUF_VERSION 4025000
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
#endif
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 4024000
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 4025000
#ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif
#define PROTOBUF_MIN_PROTOC_VERSION 4024000
#define PROTOBUF_MIN_PROTOC_VERSION 4025000
#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
@ -330,7 +330,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
// The minimum library version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 4024000
#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 4025000
#ifdef PROTOBUF_RTTI
#error PROTOBUF_RTTI was previously defined

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -44,7 +44,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 4024000
#define GOOGLE_PROTOBUF_VERSION 4025000
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@ -52,15 +52,15 @@ namespace internal {
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
static const int kMinHeaderVersionForLibrary = 4024000;
static const int kMinHeaderVersionForLibrary = 4025000;
// The minimum protoc version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 4024000
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 4025000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
static const int kMinHeaderVersionForProtoc = 4024000;
static const int kMinHeaderVersionForProtoc = 4025000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -11,13 +11,13 @@
#include <utility>
#include "google/protobuf/port_def.inc"
#if PROTOBUF_VERSION < 4024000
#if PROTOBUF_VERSION < 4025000
#error "This file was generated by a newer version of protoc which is"
#error "incompatible with your Protocol Buffer headers. Please update"
#error "your headers."
#endif // PROTOBUF_VERSION
#if 4024000 < PROTOBUF_MIN_PROTOC_VERSION
#if 4025000 < 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."

@ -110,17 +110,4 @@ target_include_directories(generated_cpp_support__only_for_generated_code_do_not
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINRARY_DIR}>
)
add_library(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
)
target_include_directories(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../cmake>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINRARY_DIR}>
)
target_link_libraries(generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
mem
mini_descriptor
reflection_internal)

@ -1,17 +1,17 @@
{
"main": {
"protoc_version": "26-dev",
"lts": false,
"date": "2023-10-16",
"languages": {
"cpp": "4.26-dev",
"csharp": "3.26-dev",
"java": "3.26-dev",
"javascript": "3.26-dev",
"objectivec": "3.26-dev",
"php": "3.26-dev",
"python": "4.26-dev",
"ruby": "3.26-dev"
}
"25.x": {
"protoc_version": "25.0-dev",
"lts": false,
"date": "2023-11-01",
"languages": {
"cpp": "4.25.0-dev",
"csharp": "3.25.0-dev",
"java": "3.25.0-dev",
"javascript": "3.25.0-dev",
"objectivec": "3.25.0-dev",
"php": "3.25.0-dev",
"python": "4.25.0-dev",
"ruby": "3.25.0-dev"
}
}
}
}

Loading…
Cancel
Save