Merge branch '21.x' into 21.x-php-add-previous-classname-to-descriptor-pool

pull/10041/head
Brent Shaffer 2 years ago
commit eeb16204e2
  1. 3
      BUILD.bazel
  2. 28
      CHANGES.txt
  3. 2
      Protobuf-C++.podspec
  4. 2
      Protobuf.podspec
  5. 2
      configure.ac
  6. 2
      csharp/Google.Protobuf.Tools.nuspec
  7. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  8. 6
      java/README.md
  9. 2
      java/bom/pom.xml
  10. 2
      java/core/pom.xml
  11. 2
      java/kotlin-lite/pom.xml
  12. 2
      java/kotlin/pom.xml
  13. 2
      java/lite.md
  14. 2
      java/lite/pom.xml
  15. 2
      java/pom.xml
  16. 2
      java/util/pom.xml
  17. 6
      kokoro/linux/dockerfile/test/php_32bit/Dockerfile
  18. 3
      kokoro/macos/php7.0_mac/build.sh
  19. 3
      kokoro/macos/php7.3_mac/build.sh
  20. 2
      php/composer.json
  21. 23
      php/ext/google/protobuf/package.xml
  22. 2
      php/ext/google/protobuf/protobuf.h
  23. 35
      php/src/Google/Protobuf/FieldDescriptor.php
  24. 38
      php/src/Google/Protobuf/Internal/FieldDescriptor.php
  25. 9
      php/src/Google/Protobuf/Internal/OneofDescriptor.php
  26. 9
      php/src/Google/Protobuf/OneofDescriptor.php
  27. 6
      protobuf_version.bzl
  28. 2
      protoc-artifacts/pom.xml
  29. 2
      python/google/protobuf/__init__.py
  30. 2
      ruby/google-protobuf.gemspec
  31. 4
      ruby/pom.xml
  32. 2
      src/Makefile.am
  33. 2
      src/google/protobuf/any.pb.h
  34. 2
      src/google/protobuf/api.pb.h
  35. 21
      src/google/protobuf/arena_impl.h
  36. 6
      src/google/protobuf/arenastring.cc
  37. 27
      src/google/protobuf/arenastring.h
  38. 2
      src/google/protobuf/compiler/plugin.pb.h
  39. 2
      src/google/protobuf/descriptor.pb.h
  40. 2
      src/google/protobuf/duration.pb.h
  41. 2
      src/google/protobuf/empty.pb.h
  42. 2
      src/google/protobuf/field_mask.pb.h
  43. 2
      src/google/protobuf/port_def.inc
  44. 2
      src/google/protobuf/source_context.pb.h
  45. 2
      src/google/protobuf/struct.pb.h
  46. 2
      src/google/protobuf/stubs/common.h
  47. 2
      src/google/protobuf/timestamp.pb.h
  48. 2
      src/google/protobuf/type.pb.h
  49. 2
      src/google/protobuf/wrappers.pb.h
  50. 20
      version.json

@ -929,7 +929,7 @@ py_proto_library(
default_runtime = "", default_runtime = "",
protoc = ":protoc", protoc = ":protoc",
srcs_version = "PY2AND3", srcs_version = "PY2AND3",
visibility = ["@upb//:__subpackages__"], visibility = ["//visibility:public"],
) )
py_library( py_library(
@ -941,6 +941,7 @@ py_library(
":python/google/protobuf/pyext/_message.so", ":python/google/protobuf/pyext/_message.so",
], ],
}), }),
visibility = ["//visibility:public"],
deps = [ deps = [
":python_srcs", ":python_srcs",
":well_known_types_py_pb2", ":well_known_types_py_pb2",

@ -1,13 +1,21 @@
2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
* ArenaString improvements (fix alignment issue)
PHP
* API changes for OneOf (#10102)
2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby) 2022-05-27 version 21.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++ C++
* cmake: Revert "Fix cmake install targets (#9822)" (#10060) * cmake: Revert "Fix cmake install targets (#9822)" (#10060)
* Remove Abseil dependency from CMake build (#10056) * Remove Abseil dependency from CMake build (#10056)
Python Python
* Update python wheel metadata with more information incl. required python version (#10058) * Update python wheel metadata with more information incl. required python version (#10058)
* Fix segmentation fault when instantiating field via repeated field assignment (#10066) * Fix segmentation fault when instantiating field via repeated field assignment (#10066)
2022-05-25 version 21.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby) 2022-05-25 version 21.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++ C++
@ -1099,11 +1107,11 @@ mistakenly tagged at the wrong commit.
2020-02-14 version 3.11.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2020-02-14 version 3.11.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C# C#
* Fix latest ArgumentException for C# extensions (#7188) * Fix latest ArgumentException for C# extensions (#7188)
* Enforce recursion depth checking for unknown fields (#7210) * Enforce recursion depth checking for unknown fields (#7210)
Ruby Ruby
* Fix wrappers with a zero value (#7195) * Fix wrappers with a zero value (#7195)
* Fix JSON serialization of 0/empty-valued wrapper types (#7198) * Fix JSON serialization of 0/empty-valued wrapper types (#7198)
@ -1116,13 +1124,13 @@ mistakenly tagged at the wrong commit.
PHP PHP
* Refactored ulong to zend_ulong for php7.4 compatibility (#7147) * Refactored ulong to zend_ulong for php7.4 compatibility (#7147)
* Call register_class before getClass from desc to fix segfault (#7077) * Call register_class before getClass from desc to fix segfault (#7077)
2019-12-10 version 3.11.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2019-12-10 version 3.11.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
PHP PHP
* Make c extension portable for php 7.4 (#6968) * Make c extension portable for php 7.4 (#6968)
2019-12-02 version 3.11.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) 2019-12-02 version 3.11.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
@ -1198,7 +1206,7 @@ mistakenly tagged at the wrong commit.
* Support 32 bit values for ProtoStreamObjectWriter to Struct. * Support 32 bit values for ProtoStreamObjectWriter to Struct.
* Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there. * Removed the internal-only header coded_stream_inl.h and the internal-only methods defined there.
* Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction). * Enforced no SWIG wrapping of descriptor_database.h (other headers already had this restriction).
* Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big. * Implementation of the equivalent of the MOMI parser for serialization. This removes one of the two serialization routines, by making the fast array serialization routine completely general. SerializeToCodedStream can now be implemented in terms of the much much faster array serialization. The array serialization regresses slightly, but when array serialization is not possible this wins big.
* Do not convert unknown field name to snake case to accurately report error. * Do not convert unknown field name to snake case to accurately report error.
* Fix a UBSAN warnings. (#6333) * Fix a UBSAN warnings. (#6333)
* Add podspec for C++ (#6404) * Add podspec for C++ (#6404)
@ -1232,7 +1240,7 @@ mistakenly tagged at the wrong commit.
* Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?). * Change the parameter types of binaryReaderFn in ExtensionFieldBinaryInfo to (number, ?, ?).
* Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively. * Create dates.ts and time_of_days.ts to mirror Java versions. This is a near-identical conversion of c.g.type.util.{Dates,TimeOfDays} respectively.
* Migrate moneys to TypeScript. * Migrate moneys to TypeScript.
PHP PHP
* Fix incorrect leap day for Timestamp (#6696) * Fix incorrect leap day for Timestamp (#6696)
* Initialize well known type values (#6713) * Initialize well known type values (#6713)
@ -1246,7 +1254,7 @@ mistakenly tagged at the wrong commit.
* Optimization for layout_init() (#6547) * Optimization for layout_init() (#6547)
* Fix for GC of Ruby map frames. (#6533) * Fix for GC of Ruby map frames. (#6533)
* Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695) * Fixed leap year handling by reworking upb_mktime() -> upb_timegm(). (#6695)
Objective C Objective C
* Remove OSReadLittle* due to alignment requirements (#6678) * Remove OSReadLittle* due to alignment requirements (#6678)
* Don't use unions and instead use memcpy for the type swaps. (#6672) * Don't use unions and instead use memcpy for the type swaps. (#6672)

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

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

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release # In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.) # the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.21.1],[protobuf@googlegroups.com],[protobuf]) AC_INIT([Protocol Buffers],[3.21.2],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable]) AM_MAINTAINER_MODE([enable])

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

@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description> <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright> <Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle> <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.21.1</VersionPrefix> <VersionPrefix>3.21.2</VersionPrefix>
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence --> <!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
<LangVersion>7.2</LangVersion> <LangVersion>7.2</LangVersion>
<Authors>Google Inc.</Authors> <Authors>Google Inc.</Authors>

@ -23,7 +23,7 @@ If you are using Maven, use the following:
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>
<version>3.21.1</version> <version>3.21.2</version>
</dependency> </dependency>
``` ```
@ -37,7 +37,7 @@ protobuf-java-util package:
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId> <artifactId>protobuf-java-util</artifactId>
<version>3.21.1</version> <version>3.21.2</version>
</dependency> </dependency>
``` ```
@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies: If you are using Gradle, add the following to your `build.gradle` file's dependencies:
``` ```
implementation 'com.google.protobuf:protobuf-java:3.21.1' implementation 'com.google.protobuf:protobuf-java:3.21.2'
``` ```
Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using. 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> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId> <artifactId>protobuf-bom</artifactId>
<version>3.21.1</version> <version>3.21.2</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Protocol Buffers [BOM]</name> <name>Protocol Buffers [BOM]</name>

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

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

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

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

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

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

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

@ -47,8 +47,10 @@ RUN cd /var/local \
&& make install && make install
# Install composer # Install composer
RUN curl -sS https://getcomposer.org/installer | php RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer RUN php composer-setup.php
RUN mv composer.phar /usr/bin/composer
RUN php -r "unlink('composer-setup.php');"
# Download php source code # Download php source code
RUN git clone https://github.com/php/php-src RUN git clone https://github.com/php/php-src

@ -8,4 +8,5 @@ cd $(dirname $0)/../../..
# Prepare worker environment to run tests # Prepare worker environment to run tests
source kokoro/macos/prepare_build_macos_rc source kokoro/macos/prepare_build_macos_rc
./tests.sh php7.0_mac # TODO(mkruskal) Re-enable this once we can get a working PHP 7.0 installed.
#./tests.sh php7.0_mac

@ -8,4 +8,5 @@ cd $(dirname $0)/../../..
# Prepare worker environment to run tests # Prepare worker environment to run tests
source kokoro/macos/prepare_build_macos_rc source kokoro/macos/prepare_build_macos_rc
./tests.sh php7.3_mac # TODO(mkruskal) Re-enable this once we can get a working PHP 7.0 installed.
#./tests.sh php7.3_mac

@ -9,7 +9,7 @@
"php": ">=7.0.0" "php": ">=7.0.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": ">=5.0.0" "phpunit/phpunit": ">=5.0.0 <8.5.27"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email> <email>protobuf-opensource@google.com</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2022-05-27</date> <date>2022-06-23</date>
<time>09:36:34</time> <time>12:12:44</time>
<version> <version>
<release>3.21.1</release> <release>3.21.2</release>
<api>3.21.1</api> <api>3.21.2</api>
</version> </version>
<stability> <stability>
<release>stable</release> <release>stable</release>
@ -1343,5 +1343,20 @@ G A release.
<notes> <notes>
</notes> </notes>
</release> </release>
<release>
<version>
<release>3.21.2</release>
<api>3.21.2</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2022-06-23</date>
<time>12:12:44</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
<notes>
</notes>
</release>
</changelog> </changelog>
</package> </package>

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

@ -39,6 +39,7 @@ class FieldDescriptor
{ {
use GetPublicDescriptorTrait; use GetPublicDescriptorTrait;
/** @var \Google\Protobuf\Internal\FieldDescriptor $internal_desc */
private $internal_desc; private $internal_desc;
/** /**
@ -81,6 +82,32 @@ class FieldDescriptor
return $this->internal_desc->getType(); return $this->internal_desc->getType();
} }
/**
* @return OneofDescriptor
*/
public function getContainingOneof()
{
return $this->getPublicDescriptor($this->internal_desc->getContainingOneof());
}
/**
* Gets the field's containing oneof, only if non-synthetic.
*
* @return null|OneofDescriptor
*/
public function getRealContainingOneof()
{
return $this->getPublicDescriptor($this->internal_desc->getRealContainingOneof());
}
/**
* @return boolean
*/
public function hasOptionalKeyword()
{
return $this->internal_desc->hasOptionalKeyword();
}
/** /**
* @return Descriptor Returns a descriptor for the field type if the field type is a message, otherwise throws \Exception * @return Descriptor Returns a descriptor for the field type if the field type is a message, otherwise throws \Exception
* @throws \Exception * @throws \Exception
@ -114,12 +141,4 @@ class FieldDescriptor
{ {
return $this->internal_desc->isMap(); return $this->internal_desc->isMap();
} }
/**
* @return boolean
*/
public function hasOptionalKeyword()
{
return $this->internal_desc->hasOptionalKeyword();
}
} }

@ -46,8 +46,11 @@ class FieldDescriptor
private $message_type; private $message_type;
private $enum_type; private $enum_type;
private $packed; private $packed;
private $is_map;
private $oneof_index = -1; private $oneof_index = -1;
private $proto3_optional;
/** @var OneofDescriptor $containing_oneof */
private $containing_oneof;
public function __construct() public function __construct()
{ {
@ -169,6 +172,32 @@ class FieldDescriptor
return $this->packed; return $this->packed;
} }
public function getProto3Optional()
{
return $this->proto3_optional;
}
public function setProto3Optional($proto3_optional)
{
$this->proto3_optional = $proto3_optional;
}
public function getContainingOneof()
{
return $this->containing_oneof;
}
public function setContainingOneof($containing_oneof)
{
$this->containing_oneof = $containing_oneof;
}
public function getRealContainingOneof()
{
return !is_null($this->containing_oneof) && !$this->containing_oneof->isSynthetic()
? $this->containing_oneof : null;
}
public function isPackable() public function isPackable()
{ {
return $this->isRepeated() && self::isTypePackable($this->type); return $this->isRepeated() && self::isTypePackable($this->type);
@ -214,6 +243,10 @@ class FieldDescriptor
$field_type !== GPBType::BYTES); $field_type !== GPBType::BYTES);
} }
/**
* @param FieldDescriptorProto $proto
* @return FieldDescriptor
*/
public static function getFieldDescriptor($proto) public static function getFieldDescriptor($proto)
{ {
$type_name = null; $type_name = null;
@ -248,8 +281,6 @@ class FieldDescriptor
$field = new FieldDescriptor(); $field = new FieldDescriptor();
$field->setName($proto->getName()); $field->setName($proto->getName());
$json_name = $proto->hasJsonName() ? $proto->getJsonName() :
lcfirst(implode('', array_map('ucwords', explode('_', $proto->getName()))));
if ($proto->hasJsonName()) { if ($proto->hasJsonName()) {
$json_name = $proto->getJsonName(); $json_name = $proto->getJsonName();
} else { } else {
@ -269,6 +300,7 @@ class FieldDescriptor
$field->setLabel($proto->getLabel()); $field->setLabel($proto->getLabel());
$field->setPacked($packed); $field->setPacked($packed);
$field->setOneofIndex($oneof_index); $field->setOneofIndex($oneof_index);
$field->setProto3Optional($proto->getProto3Optional());
// At this time, the message/enum type may have not been added to pool. // At this time, the message/enum type may have not been added to pool.
// So we use the type name as place holder and will replace it with the // So we use the type name as place holder and will replace it with the

@ -37,6 +37,7 @@ class OneofDescriptor
use HasPublicDescriptorTrait; use HasPublicDescriptorTrait;
private $name; private $name;
/** @var \Google\Protobuf\FieldDescriptor[] $fields */
private $fields; private $fields;
public function __construct() public function __construct()
@ -64,13 +65,21 @@ class OneofDescriptor
return $this->fields; return $this->fields;
} }
public function isSynthetic()
{
return !is_null($this->fields) && count($this->fields) === 1
&& $this->fields[0]->getProto3Optional();
}
public static function buildFromProto($oneof_proto, $desc, $index) public static function buildFromProto($oneof_proto, $desc, $index)
{ {
$oneof = new OneofDescriptor(); $oneof = new OneofDescriptor();
$oneof->setName($oneof_proto->getName()); $oneof->setName($oneof_proto->getName());
foreach ($desc->getField() as $field) { foreach ($desc->getField() as $field) {
/** @var FieldDescriptor $field */
if ($field->getOneofIndex() == $index) { if ($field->getOneofIndex() == $index) {
$oneof->addField($field); $oneof->addField($field);
$field->setContainingOneof($oneof);
} }
} }
return $oneof; return $oneof;

@ -38,6 +38,7 @@ class OneofDescriptor
{ {
use GetPublicDescriptorTrait; use GetPublicDescriptorTrait;
/** @var \Google\Protobuf\Internal\OneofDescriptor $internal_desc */
private $internal_desc; private $internal_desc;
/** /**
@ -62,6 +63,12 @@ class OneofDescriptor
*/ */
public function getField($index) public function getField($index)
{ {
if (
is_null($this->internal_desc->getFields())
|| !isset($this->internal_desc->getFields()[$index])
) {
return null;
}
return $this->getPublicDescriptor($this->internal_desc->getFields()[$index]); return $this->getPublicDescriptor($this->internal_desc->getFields()[$index]);
} }
@ -75,6 +82,6 @@ class OneofDescriptor
public function isSynthetic() public function isSynthetic()
{ {
return $this->internal_desc->isSynthetic(); return $this->internal_desc->isSynthetic();
} }
} }

@ -1,3 +1,3 @@
PROTOC_VERSION = '21.1' PROTOC_VERSION = '21.2'
PROTOBUF_JAVA_VERSION = '3.21.1' PROTOBUF_JAVA_VERSION = '3.21.2'
PROTOBUF_PYTHON_VERSION = '4.21.1' PROTOBUF_PYTHON_VERSION = '4.21.2'

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

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

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

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

@ -18,7 +18,7 @@ else
PTHREAD_DEF = PTHREAD_DEF =
endif endif
PROTOBUF_VERSION = 32:1:0 PROTOBUF_VERSION = 32:2:0
if GCC if GCC
# Turn on all warnings except for sign comparison (we ignore sign comparison # Turn on all warnings except for sign comparison (we ignore sign comparison

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

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

@ -55,6 +55,13 @@ namespace google {
namespace protobuf { namespace protobuf {
namespace internal { namespace internal {
// To prevent sharing cache lines between threads
#ifdef __cpp_aligned_new
enum { kCacheAlignment = 64 };
#else
enum { kCacheAlignment = alignof(max_align_t) }; // do the best we can
#endif
inline constexpr size_t AlignUpTo8(size_t n) { inline constexpr size_t AlignUpTo8(size_t n) {
// Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.) // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)
return (n + 7) & static_cast<size_t>(-8); return (n + 7) & static_cast<size_t>(-8);
@ -497,10 +504,10 @@ class PROTOBUF_EXPORT ThreadSafeArena {
// have fallback function calls in tail position. This substantially improves // have fallback function calls in tail position. This substantially improves
// code for the happy path. // code for the happy path.
PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) { PROTOBUF_NDEBUG_INLINE bool MaybeAllocateAligned(size_t n, void** out) {
SerialArena* a; SerialArena* arena;
if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() && if (PROTOBUF_PREDICT_TRUE(!alloc_policy_.should_record_allocs() &&
GetSerialArenaFromThreadCache(&a))) { GetSerialArenaFromThreadCache(&arena))) {
return a->MaybeAllocateAligned(n, out); return arena->MaybeAllocateAligned(n, out);
} }
return false; return false;
} }
@ -564,7 +571,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
// fast path optimizes the case where a single thread uses multiple arenas. // fast path optimizes the case where a single thread uses multiple arenas.
ThreadCache* tc = &thread_cache(); ThreadCache* tc = &thread_cache();
SerialArena* serial = hint_.load(std::memory_order_acquire); SerialArena* serial = hint_.load(std::memory_order_acquire);
if (PROTOBUF_PREDICT_TRUE(serial != NULL && serial->owner() == tc)) { if (PROTOBUF_PREDICT_TRUE(serial != nullptr && serial->owner() == tc)) {
*arena = serial; *arena = serial;
return true; return true;
} }
@ -602,7 +609,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4324) #pragma warning(disable : 4324)
#endif #endif
struct alignas(64) ThreadCache { struct alignas(kCacheAlignment) ThreadCache {
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL) #if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
// If we are using the ThreadLocalStorage class to store the ThreadCache, // If we are using the ThreadLocalStorage class to store the ThreadCache,
// then the ThreadCache's default constructor has to be responsible for // then the ThreadCache's default constructor has to be responsible for
@ -610,7 +617,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
ThreadCache() ThreadCache()
: next_lifecycle_id(0), : next_lifecycle_id(0),
last_lifecycle_id_seen(-1), last_lifecycle_id_seen(-1),
last_serial_arena(NULL) {} last_serial_arena(nullptr) {}
#endif #endif
// Number of per-thread lifecycle IDs to reserve. Must be power of two. // Number of per-thread lifecycle IDs to reserve. Must be power of two.
@ -633,7 +640,7 @@ class PROTOBUF_EXPORT ThreadSafeArena {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4324) #pragma warning(disable : 4324)
#endif #endif
struct alignas(64) CacheAlignedLifecycleIdGenerator { struct alignas(kCacheAlignment) CacheAlignedLifecycleIdGenerator {
std::atomic<LifecycleIdAtomic> id; std::atomic<LifecycleIdAtomic> id;
}; };
static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_; static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_;

@ -187,7 +187,7 @@ std::string* ArenaStringPtr::Release() {
if (IsDefault()) return nullptr; if (IsDefault()) return nullptr;
std::string* released = tagged_ptr_.Get(); std::string* released = tagged_ptr_.Get();
if (!tagged_ptr_.IsAllocated()) { if (tagged_ptr_.IsArena()) {
released = tagged_ptr_.IsMutable() ? new std::string(std::move(*released)) released = tagged_ptr_.IsMutable() ? new std::string(std::move(*released))
: new std::string(*released); : new std::string(*released);
} }
@ -216,9 +216,7 @@ void ArenaStringPtr::SetAllocated(std::string* value, Arena* arena) {
} }
void ArenaStringPtr::Destroy() { void ArenaStringPtr::Destroy() {
if (tagged_ptr_.IsAllocated()) { delete tagged_ptr_.GetIfAllocated();
delete tagged_ptr_.Get();
}
} }
void ArenaStringPtr::ClearToEmpty() { void ArenaStringPtr::ClearToEmpty() {

@ -96,13 +96,12 @@ class PROTOBUF_EXPORT LazyString {
class TaggedStringPtr { class TaggedStringPtr {
public: public:
// Bit flags qualifying string properties. We can use up to 3 bits as // Bit flags qualifying string properties. We can use 2 bits as
// ptr_ is guaranteed and enforced to be aligned on 8 byte boundaries. // ptr_ is guaranteed and enforced to be aligned on 4 byte boundaries.
enum Flags { enum Flags {
kArenaBit = 0x1, // ptr is arena allocated kArenaBit = 0x1, // ptr is arena allocated
kAllocatedBit = 0x2, // ptr is heap allocated kMutableBit = 0x2, // ptr contents are fully mutable
kMutableBit = 0x4, // ptr contents are fully mutable kMask = 0x3 // Bit mask
kMask = 0x7 // Bit mask
}; };
// Composed logical types // Composed logical types
@ -112,7 +111,7 @@ class TaggedStringPtr {
// Allocated strings are mutable and (as the name implies) owned. // Allocated strings are mutable and (as the name implies) owned.
// A heap allocated string must be deleted. // A heap allocated string must be deleted.
kAllocated = kAllocatedBit | kMutableBit, kAllocated = kMutableBit,
// Mutable arena strings are strings where the string instance is owned // Mutable arena strings are strings where the string instance is owned
// by the arena, but the string contents itself are owned by the string // by the arena, but the string contents itself are owned by the string
@ -166,8 +165,16 @@ class TaggedStringPtr {
// Returns true if the current string is an immutable default value. // Returns true if the current string is an immutable default value.
inline bool IsDefault() const { return (as_int() & kMask) == kDefault; } inline bool IsDefault() const { return (as_int() & kMask) == kDefault; }
// Returns true if the current string is a heap allocated mutable value. // If the current string is a heap-allocated mutable value, returns a pointer
inline bool IsAllocated() const { return as_int() & kAllocatedBit; } // to it. Returns nullptr otherwise.
inline std::string *GetIfAllocated() const {
auto allocated = as_int() ^ kAllocated;
if (allocated & kMask) return nullptr;
auto ptr = reinterpret_cast<std::string*>(allocated);
PROTOBUF_ASSUME(ptr != nullptr);
return ptr;
}
// Returns true if the current string is an arena allocated value. // Returns true if the current string is an arena allocated value.
// This means it's either a mutable or fixed size arena string. // This means it's either a mutable or fixed size arena string.
@ -224,8 +231,8 @@ static_assert(std::is_trivial<TaggedStringPtr>::value,
// Because ArenaStringPtr is used in oneof unions, its constructor is a NOP and // Because ArenaStringPtr is used in oneof unions, its constructor is a NOP and
// the field is always manually initialized via method calls. // the field is always manually initialized via method calls.
// //
// See TaggedPtr for more information about the types of string values being // See TaggedStringPtr for more information about the types of string values
// held, and the mutable and ownership invariants for each type. // being held, and the mutable and ownership invariants for each type.
struct PROTOBUF_EXPORT ArenaStringPtr { struct PROTOBUF_EXPORT ArenaStringPtr {
ArenaStringPtr() = default; ArenaStringPtr() = default;
constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value, constexpr ArenaStringPtr(ExplicitlyConstructedArenaString* default_value,

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

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

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

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

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

@ -178,7 +178,7 @@
#ifdef PROTOBUF_VERSION #ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined #error PROTOBUF_VERSION was previously defined
#endif #endif
#define PROTOBUF_VERSION 3021001 #define PROTOBUF_VERSION 3021002
#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined

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

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

@ -82,7 +82,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison // The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro // easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 3021001 #define GOOGLE_PROTOBUF_VERSION 3021002
// A suffix string for alpha, beta or rc releases. Empty for stable releases. // A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX "" #define GOOGLE_PROTOBUF_VERSION_SUFFIX ""

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

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

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

@ -1,17 +1,17 @@
{ {
"21.x": { "21.x": {
"protoc_version": "21.2-dev", "protoc_version": "21.2",
"lts": false, "lts": false,
"date": "2022-05-27", "date": "2022-06-23",
"languages": { "languages": {
"cpp": "3.21.2-dev", "cpp": "3.21.2",
"csharp": "3.21.2-dev", "csharp": "3.21.2",
"java": "3.21.2-dev", "java": "3.21.2",
"javascript": "3.21.2-dev", "javascript": "3.21.2",
"objectivec": "3.21.2-dev", "objectivec": "3.21.2",
"php": "3.21.2-dev", "php": "3.21.2",
"python": "4.21.2-dev", "python": "4.21.2",
"ruby": "3.21.2-dev" "ruby": "3.21.2"
} }
} }
} }
Loading…
Cancel
Save