From cd7b27be386290d9fbca89c7d52a51c2d1a8bf4c Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Fri, 15 Nov 2019 17:44:10 -0800 Subject: [PATCH 01/23] Update protobuf version (#6898) --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 20 ++++++++-- php/ext/google/protobuf/protobuf.h | 2 +- .../Protobuf/Internal/DescriptorProto.php | 4 +- .../DescriptorProto/ExtensionRange.php | 6 +-- .../DescriptorProto/ReservedRange.php | 4 +- .../Protobuf/Internal/EnumDescriptorProto.php | 4 +- .../EnumDescriptorProto/EnumReservedRange.php | 4 +- .../Google/Protobuf/Internal/EnumOptions.php | 4 +- .../Internal/EnumValueDescriptorProto.php | 6 +-- .../Protobuf/Internal/EnumValueOptions.php | 2 +- .../Internal/FieldDescriptorProto.php | 20 +++++----- .../Google/Protobuf/Internal/FieldOptions.php | 12 +++--- .../Protobuf/Internal/FileDescriptorProto.php | 10 ++--- .../Google/Protobuf/Internal/FileOptions.php | 40 +++++++++---------- .../Internal/GeneratedCodeInfo/Annotation.php | 6 +-- .../Protobuf/Internal/MessageOptions.php | 8 ++-- .../Internal/MethodDescriptorProto.php | 12 +++--- .../Protobuf/Internal/MethodOptions.php | 4 +- .../Internal/OneofDescriptorProto.php | 4 +- .../Internal/ServiceDescriptorProto.php | 4 +- .../Protobuf/Internal/ServiceOptions.php | 2 +- .../Internal/SourceCodeInfo/Location.php | 4 +- .../Protobuf/Internal/UninterpretedOption.php | 12 +++--- .../Internal/UninterpretedOption/NamePart.php | 4 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 38 files changed, 120 insertions(+), 106 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index d21d3cc7bb..63909d3c69 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.11.0-rc0' + s.version = '3.11.0-rc1' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index 11d0963a46..a4b3f4b5a6 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.11.0-rc0' + s.version = '3.11.0-rc1' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index f741fecdfa..af2d980bcf 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.11.0-rc-0],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.11.0-rc-1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 9357025f3d..d1a533842a 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.11.0-rc0 + 3.11.0-rc1 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index a81a52f769..837b5658ff 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.11.0-rc0 + 3.11.0-rc1 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 0adda2203f..59f0846b68 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.11.0-rc-0 + 3.11.0-rc-1 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 8c20b1f65e..737a9c167a 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-0 + 3.11.0-rc-1 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 3343eb91e1..fc91b2c333 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-0 + 3.11.0-rc-1 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index c53a9ee647..04443859f8 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-0 + 3.11.0-rc-1 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 54a35817c7..082c7ddafa 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-0 + 3.11.0-rc-1 protobuf-java-util diff --git a/js/package.json b/js/package.json index c9ea4de537..2cfba39ba8 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.11.0-rc.0", + "version": "3.11.0-rc.1", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index ba2521c2a8..bee8b035a4 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,10 +10,10 @@ protobuf-opensource@google.com yes - 2019-10-03 - + 2019-11-15 + - 3.11.0RC0 + 3.11.0RC1 3.11.0 @@ -431,5 +431,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.11.0RC1 + 3.11.0 + + + beta + beta + + 2019-11-15 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 6151ff4cd6..908134118f 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.11.0RC0" +#define PHP_PROTOBUF_VERSION "3.11.0RC1" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php index 3b215d52ae..7cc689d028 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php @@ -20,7 +20,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field repeated .google.protobuf.FieldDescriptorProto field = 2; @@ -55,7 +55,7 @@ class DescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional .google.protobuf.MessageOptions options = 7; */ - private $options = null; + protected $options = null; private $has_options = false; /** * Generated from protobuf field repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php index a2057fd5d1..82b5695efe 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php @@ -20,19 +20,19 @@ class ExtensionRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 start = 1; */ - private $start = 0; + protected $start = 0; private $has_start = false; /** * Exclusive. * * Generated from protobuf field optional int32 end = 2; */ - private $end = 0; + protected $end = 0; private $has_end = false; /** * Generated from protobuf field optional .google.protobuf.ExtensionRangeOptions options = 3; */ - private $options = null; + protected $options = null; private $has_options = false; /** diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php index 73c964faa0..8022151abf 100644 --- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php +++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php @@ -24,14 +24,14 @@ class ReservedRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 start = 1; */ - private $start = 0; + protected $start = 0; private $has_start = false; /** * Exclusive. * * Generated from protobuf field optional int32 end = 2; */ - private $end = 0; + protected $end = 0; private $has_end = false; /** diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php index da30fa9906..f5c7fe1482 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php @@ -20,7 +20,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field repeated .google.protobuf.EnumValueDescriptorProto value = 2; @@ -30,7 +30,7 @@ class EnumDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional .google.protobuf.EnumOptions options = 3; */ - private $options = null; + protected $options = null; private $has_options = false; /** * Range of reserved numeric values. Reserved numeric values may not be used diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php index e1079585ec..949dd89107 100644 --- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php +++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php @@ -26,14 +26,14 @@ class EnumReservedRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 start = 1; */ - private $start = 0; + protected $start = 0; private $has_start = false; /** * Inclusive. * * Generated from protobuf field optional int32 end = 2; */ - private $end = 0; + protected $end = 0; private $has_end = false; /** diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php index 3d74c81c21..e6500423b1 100644 --- a/php/src/Google/Protobuf/Internal/EnumOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumOptions.php @@ -21,7 +21,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool allow_alias = 2; */ - private $allow_alias = false; + protected $allow_alias = false; private $has_allow_alias = false; /** * Is this enum deprecated? @@ -31,7 +31,7 @@ class EnumOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php index 50bda008e8..3dd95583ac 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php @@ -20,17 +20,17 @@ class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field optional int32 number = 2; */ - private $number = 0; + protected $number = 0; private $has_number = false; /** * Generated from protobuf field optional .google.protobuf.EnumValueOptions options = 3; */ - private $options = null; + protected $options = null; private $has_options = false; /** diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php index a267c6d5e2..9f9fb3bec1 100644 --- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php +++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php @@ -23,7 +23,7 @@ class EnumValueOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 1 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php index e578197515..b231c9e102 100644 --- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php @@ -20,17 +20,17 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field optional int32 number = 3; */ - private $number = 0; + protected $number = 0; private $has_number = false; /** * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Label label = 4; */ - private $label = 0; + protected $label = 0; private $has_label = false; /** * If type_name is set, this need not be set. If both this and type_name @@ -38,7 +38,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.protobuf.FieldDescriptorProto.Type type = 5; */ - private $type = 0; + protected $type = 0; private $has_type = false; /** * For message and enum types, this is the name of the type. If the name @@ -49,7 +49,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string type_name = 6; */ - private $type_name = ''; + protected $type_name = ''; private $has_type_name = false; /** * For extensions, this is the name of the type being extended. It is @@ -57,7 +57,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string extendee = 2; */ - private $extendee = ''; + protected $extendee = ''; private $has_extendee = false; /** * For numeric types, contains the original text representation of the value. @@ -68,7 +68,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string default_value = 7; */ - private $default_value = ''; + protected $default_value = ''; private $has_default_value = false; /** * If set, gives the index of a oneof in the containing type's oneof_decl @@ -76,7 +76,7 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 oneof_index = 9; */ - private $oneof_index = 0; + protected $oneof_index = 0; private $has_oneof_index = false; /** * JSON name of this field. The value is set by protocol compiler. If the @@ -86,12 +86,12 @@ class FieldDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string json_name = 10; */ - private $json_name = ''; + protected $json_name = ''; private $has_json_name = false; /** * Generated from protobuf field optional .google.protobuf.FieldOptions options = 8; */ - private $options = null; + protected $options = null; private $has_options = false; /** diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php index 751c278d78..2ccc41825c 100644 --- a/php/src/Google/Protobuf/Internal/FieldOptions.php +++ b/php/src/Google/Protobuf/Internal/FieldOptions.php @@ -23,7 +23,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING]; */ - private $ctype = 0; + protected $ctype = 0; private $has_ctype = false; /** * The packed option can be enabled for repeated primitive fields to enable @@ -34,7 +34,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool packed = 2; */ - private $packed = false; + protected $packed = false; private $has_packed = false; /** * The jstype option determines the JavaScript type used for values of the @@ -50,7 +50,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL]; */ - private $jstype = 0; + protected $jstype = 0; private $has_jstype = false; /** * Should this field be parsed lazily? Lazy applies only to message-type @@ -80,7 +80,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool lazy = 5 [default = false]; */ - private $lazy = false; + protected $lazy = false; private $has_lazy = false; /** * Is this field deprecated? @@ -90,14 +90,14 @@ class FieldOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * For Google-internal migration only. Do not use. * * Generated from protobuf field optional bool weak = 10 [default = false]; */ - private $weak = false; + protected $weak = false; private $has_weak = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php index cb10aa7939..c9e3648c23 100644 --- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php @@ -22,14 +22,14 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * e.g. "foo", "foo.bar", etc. * * Generated from protobuf field optional string package = 2; */ - private $package = ''; + protected $package = ''; private $has_package = false; /** * Names of files imported by this file. @@ -78,7 +78,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional .google.protobuf.FileOptions options = 8; */ - private $options = null; + protected $options = null; private $has_options = false; /** * This field contains optional information about the original source code. @@ -88,7 +88,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.protobuf.SourceCodeInfo source_code_info = 9; */ - private $source_code_info = null; + protected $source_code_info = null; private $has_source_code_info = false; /** * The syntax of the proto file. @@ -96,7 +96,7 @@ class FileDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string syntax = 12; */ - private $syntax = ''; + protected $syntax = ''; private $has_syntax = false; /** diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php index 6fea195ec1..605d92bfda 100644 --- a/php/src/Google/Protobuf/Internal/FileOptions.php +++ b/php/src/Google/Protobuf/Internal/FileOptions.php @@ -23,7 +23,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string java_package = 1; */ - private $java_package = ''; + protected $java_package = ''; private $has_java_package = false; /** * If set, all the classes from the .proto file are wrapped in a single @@ -34,7 +34,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string java_outer_classname = 8; */ - private $java_outer_classname = ''; + protected $java_outer_classname = ''; private $has_java_outer_classname = false; /** * If set true, then the Java code generator will generate a separate .java @@ -46,14 +46,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool java_multiple_files = 10 [default = false]; */ - private $java_multiple_files = false; + protected $java_multiple_files = false; private $has_java_multiple_files = false; /** * This option does nothing. * * Generated from protobuf field optional bool java_generate_equals_and_hash = 20 [deprecated = true]; */ - private $java_generate_equals_and_hash = false; + protected $java_generate_equals_and_hash = false; private $has_java_generate_equals_and_hash = false; /** * If set true, then the Java2 code generator will generate code that @@ -65,12 +65,12 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool java_string_check_utf8 = 27 [default = false]; */ - private $java_string_check_utf8 = false; + protected $java_string_check_utf8 = false; private $has_java_string_check_utf8 = false; /** * Generated from protobuf field optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED]; */ - private $optimize_for = 0; + protected $optimize_for = 0; private $has_optimize_for = false; /** * Sets the Go package where structs generated from this .proto will be @@ -81,7 +81,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string go_package = 11; */ - private $go_package = ''; + protected $go_package = ''; private $has_go_package = false; /** * Should generic services be generated in each language? "Generic" services @@ -96,22 +96,22 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool cc_generic_services = 16 [default = false]; */ - private $cc_generic_services = false; + protected $cc_generic_services = false; private $has_cc_generic_services = false; /** * Generated from protobuf field optional bool java_generic_services = 17 [default = false]; */ - private $java_generic_services = false; + protected $java_generic_services = false; private $has_java_generic_services = false; /** * Generated from protobuf field optional bool py_generic_services = 18 [default = false]; */ - private $py_generic_services = false; + protected $py_generic_services = false; private $has_py_generic_services = false; /** * Generated from protobuf field optional bool php_generic_services = 42 [default = false]; */ - private $php_generic_services = false; + protected $php_generic_services = false; private $has_php_generic_services = false; /** * Is this file deprecated? @@ -121,7 +121,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 23 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * Enables the use of arenas for the proto messages in this file. This applies @@ -129,7 +129,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool cc_enable_arenas = 31 [default = false]; */ - private $cc_enable_arenas = false; + protected $cc_enable_arenas = false; private $has_cc_enable_arenas = false; /** * Sets the objective c class prefix which is prepended to all objective c @@ -137,14 +137,14 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string objc_class_prefix = 36; */ - private $objc_class_prefix = ''; + protected $objc_class_prefix = ''; private $has_objc_class_prefix = false; /** * Namespace for generated classes; defaults to the package. * * Generated from protobuf field optional string csharp_namespace = 37; */ - private $csharp_namespace = ''; + protected $csharp_namespace = ''; private $has_csharp_namespace = false; /** * By default Swift generators will take the proto package and CamelCase it @@ -154,7 +154,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string swift_prefix = 39; */ - private $swift_prefix = ''; + protected $swift_prefix = ''; private $has_swift_prefix = false; /** * Sets the php class prefix which is prepended to all php generated classes @@ -162,7 +162,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string php_class_prefix = 40; */ - private $php_class_prefix = ''; + protected $php_class_prefix = ''; private $has_php_class_prefix = false; /** * Use this option to change the namespace of php generated classes. Default @@ -171,7 +171,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string php_namespace = 41; */ - private $php_namespace = ''; + protected $php_namespace = ''; private $has_php_namespace = false; /** * Use this option to change the namespace of php generated metadata classes. @@ -180,7 +180,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string php_metadata_namespace = 44; */ - private $php_metadata_namespace = ''; + protected $php_metadata_namespace = ''; private $has_php_metadata_namespace = false; /** * Use this option to change the package of ruby generated classes. Default @@ -189,7 +189,7 @@ class FileOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string ruby_package = 45; */ - private $ruby_package = ''; + protected $ruby_package = ''; private $has_ruby_package = false; /** * The parser stores options it doesn't recognize here. diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php index 09f958d251..369fea4892 100644 --- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php +++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php @@ -28,7 +28,7 @@ class Annotation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string source_file = 2; */ - private $source_file = ''; + protected $source_file = ''; private $has_source_file = false; /** * Identifies the starting offset in bytes in the generated code @@ -36,7 +36,7 @@ class Annotation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 begin = 3; */ - private $begin = 0; + protected $begin = 0; private $has_begin = false; /** * Identifies the ending offset in bytes in the generated code that @@ -45,7 +45,7 @@ class Annotation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional int32 end = 4; */ - private $end = 0; + protected $end = 0; private $has_end = false; /** diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php index 4453942110..95bb706a5a 100644 --- a/php/src/Google/Protobuf/Internal/MessageOptions.php +++ b/php/src/Google/Protobuf/Internal/MessageOptions.php @@ -34,7 +34,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool message_set_wire_format = 1 [default = false]; */ - private $message_set_wire_format = false; + protected $message_set_wire_format = false; private $has_message_set_wire_format = false; /** * Disables the generation of the standard "descriptor()" accessor, which can @@ -43,7 +43,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool no_standard_descriptor_accessor = 2 [default = false]; */ - private $no_standard_descriptor_accessor = false; + protected $no_standard_descriptor_accessor = false; private $has_no_standard_descriptor_accessor = false; /** * Is this message deprecated? @@ -53,7 +53,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 3 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * Whether the message is an automatically generated map entry type for the @@ -77,7 +77,7 @@ class MessageOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool map_entry = 7; */ - private $map_entry = false; + protected $map_entry = false; private $has_map_entry = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php index 1bd5dd3e1c..f40f20f0d7 100644 --- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php @@ -20,7 +20,7 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Input and output type names. These are resolved in the same way as @@ -28,31 +28,31 @@ class MethodDescriptorProto extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string input_type = 2; */ - private $input_type = ''; + protected $input_type = ''; private $has_input_type = false; /** * Generated from protobuf field optional string output_type = 3; */ - private $output_type = ''; + protected $output_type = ''; private $has_output_type = false; /** * Generated from protobuf field optional .google.protobuf.MethodOptions options = 4; */ - private $options = null; + protected $options = null; private $has_options = false; /** * Identifies if client streams multiple client messages * * Generated from protobuf field optional bool client_streaming = 5 [default = false]; */ - private $client_streaming = false; + protected $client_streaming = false; private $has_client_streaming = false; /** * Identifies if server streams multiple server messages * * Generated from protobuf field optional bool server_streaming = 6 [default = false]; */ - private $server_streaming = false; + protected $server_streaming = false; private $has_server_streaming = false; /** diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php index a2c729a9bb..6a4c92de5e 100644 --- a/php/src/Google/Protobuf/Internal/MethodOptions.php +++ b/php/src/Google/Protobuf/Internal/MethodOptions.php @@ -23,12 +23,12 @@ class MethodOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 33 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * Generated from protobuf field optional .google.protobuf.MethodOptions.IdempotencyLevel idempotency_level = 34 [default = IDEMPOTENCY_UNKNOWN]; */ - private $idempotency_level = 0; + protected $idempotency_level = 0; private $has_idempotency_level = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php index 9ecfe5cbfe..413b8e55eb 100644 --- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php @@ -20,12 +20,12 @@ class OneofDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field optional .google.protobuf.OneofOptions options = 2; */ - private $options = null; + protected $options = null; private $has_options = false; /** diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php index 8de7afd0bc..aaeefbc9ea 100644 --- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php +++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php @@ -20,7 +20,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional string name = 1; */ - private $name = ''; + protected $name = ''; private $has_name = false; /** * Generated from protobuf field repeated .google.protobuf.MethodDescriptorProto method = 2; @@ -30,7 +30,7 @@ class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field optional .google.protobuf.ServiceOptions options = 3; */ - private $options = null; + protected $options = null; private $has_options = false; /** diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php index 67162f3764..0581efbafc 100644 --- a/php/src/Google/Protobuf/Internal/ServiceOptions.php +++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php @@ -23,7 +23,7 @@ class ServiceOptions extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional bool deprecated = 33 [default = false]; */ - private $deprecated = false; + protected $deprecated = false; private $has_deprecated = false; /** * The parser stores options it doesn't recognize here. See above. diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php index bad247a11f..0aeea61cae 100644 --- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php +++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php @@ -93,12 +93,12 @@ class Location extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string leading_comments = 3; */ - private $leading_comments = ''; + protected $leading_comments = ''; private $has_leading_comments = false; /** * Generated from protobuf field optional string trailing_comments = 4; */ - private $trailing_comments = ''; + protected $trailing_comments = ''; private $has_trailing_comments = false; /** * Generated from protobuf field repeated string leading_detached_comments = 6; diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php index 3b517ec552..6c871cc1ae 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php @@ -33,32 +33,32 @@ class UninterpretedOption extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string identifier_value = 3; */ - private $identifier_value = ''; + protected $identifier_value = ''; private $has_identifier_value = false; /** * Generated from protobuf field optional uint64 positive_int_value = 4; */ - private $positive_int_value = 0; + protected $positive_int_value = 0; private $has_positive_int_value = false; /** * Generated from protobuf field optional int64 negative_int_value = 5; */ - private $negative_int_value = 0; + protected $negative_int_value = 0; private $has_negative_int_value = false; /** * Generated from protobuf field optional double double_value = 6; */ - private $double_value = 0.0; + protected $double_value = 0.0; private $has_double_value = false; /** * Generated from protobuf field optional bytes string_value = 7; */ - private $string_value = ''; + protected $string_value = ''; private $has_string_value = false; /** * Generated from protobuf field optional string aggregate_value = 8; */ - private $aggregate_value = ''; + protected $aggregate_value = ''; private $has_aggregate_value = false; /** diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php index 92ee4b44b9..1956ba7f08 100644 --- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php +++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php @@ -24,12 +24,12 @@ class NamePart extends \Google\Protobuf\Internal\Message /** * Generated from protobuf field required string name_part = 1; */ - private $name_part = ''; + protected $name_part = ''; private $has_name_part = false; /** * Generated from protobuf field required bool is_extension = 2; */ - private $is_extension = false; + protected $is_extension = false; private $has_is_extension = false; /** diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 2931bb66bc..ab5209708f 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.11.0-rc-0 + 3.11.0-rc-1 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 5a025af1a6..f3e0a7152e 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.11.0rc0' +__version__ = '3.11.0rc1' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 302352d79c..1ba594d708 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.11.0.rc.0" + s.version = "3.11.0.rc.1" 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" From edda0c92f5fedec44a5b0ed0c376e15af655c410 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 18 Nov 2019 13:13:25 -0800 Subject: [PATCH 02/23] Persistent Descriptor Pool (#6899) * Make reserve names map persistent * Add DescriptorInternal to map * Use get_msgdef_desc in encode_decode.c * Add persistent map for ce=>def and enum=>def * Replace get_ce_obj * Remove get_proto_obj * Remove obsolete fields from Descriptor and EnumDescriptor * Add cache for descriptor php values * Add cache for descriptors * Fix bug * Avoid add generated file again if it has been added * Fix the bug upb depends on null-ended str for look up. * Initialize generated pool impl * Turn down old generated pool * Add init entry flag protobuf.keep_descriptor_pool_after_request By default, it's off. Add protobuf.keep_descriptor_pool_after_request=1 to php.ini to enable it * Fix zts build --- php/ext/google/protobuf/def.c | 244 +++++++++++++++------ php/ext/google/protobuf/encode_decode.c | 107 ++++----- php/ext/google/protobuf/message.c | 37 ++-- php/ext/google/protobuf/protobuf.c | 280 +++++++++++++++++++----- php/ext/google/protobuf/protobuf.h | 76 +++++-- php/ext/google/protobuf/storage.c | 37 ++-- php/ext/google/protobuf/upb.c | 7 + php/ext/google/protobuf/upb.h | 2 + php/tests/test.sh | 10 + 9 files changed, 554 insertions(+), 246 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 5df6802489..7c575c35cf 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -148,19 +148,15 @@ static zend_function_entry descriptor_methods[] = { DEFINE_CLASS(Descriptor, descriptor, "Google\\Protobuf\\Descriptor"); static void descriptor_free_c(Descriptor *self TSRMLS_DC) { - if (self->layout) { - free_layout(self->layout); - } } static void descriptor_init_c_instance(Descriptor *desc TSRMLS_DC) { - desc->msgdef = NULL; - desc->layout = NULL; - desc->klass = NULL; + desc->intern = NULL; } PHP_METHOD(Descriptor, getClass) { - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; #if PHP_MAJOR_VERSION < 7 const char* classname = intern->klass->name; #else @@ -170,7 +166,8 @@ PHP_METHOD(Descriptor, getClass) { } PHP_METHOD(Descriptor, getFullName) { - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; const char* fullname = upb_msgdef_fullname(intern->msgdef); PHP_PROTO_RETVAL_STRINGL(fullname, strlen(fullname), 1); } @@ -183,7 +180,8 @@ PHP_METHOD(Descriptor, getField) { return; } - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; int field_num = upb_msgdef_numfields(intern->msgdef); if (index < 0 || index >= field_num) { zend_error(E_USER_ERROR, "Cannot get element at %ld.\n", index); @@ -224,7 +222,8 @@ PHP_METHOD(Descriptor, getField) { } PHP_METHOD(Descriptor, getFieldCount) { - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; RETURN_LONG(upb_msgdef_numfields(intern->msgdef)); } @@ -236,7 +235,8 @@ PHP_METHOD(Descriptor, getOneofDecl) { return; } - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; int field_num = upb_msgdef_numoneofs(intern->msgdef); if (index < 0 || index >= field_num) { zend_error(E_USER_ERROR, "Cannot get element at %ld.\n", index); @@ -257,7 +257,8 @@ PHP_METHOD(Descriptor, getOneofDecl) { } PHP_METHOD(Descriptor, getOneofDeclCount) { - Descriptor *intern = UNBOX(Descriptor, getThis()); + Descriptor* desc = UNBOX(Descriptor, getThis()); + DescriptorInternal* intern = desc->intern; RETURN_LONG(upb_msgdef_numoneofs(intern->msgdef)); } @@ -278,8 +279,7 @@ static void enum_descriptor_free_c(EnumDescriptor *self TSRMLS_DC) { } static void enum_descriptor_init_c_instance(EnumDescriptor *self TSRMLS_DC) { - self->enumdef = NULL; - self->klass = NULL; + self->intern = NULL; } PHP_METHOD(EnumDescriptor, getValue) { @@ -290,7 +290,8 @@ PHP_METHOD(EnumDescriptor, getValue) { return; } - EnumDescriptor *intern = UNBOX(EnumDescriptor, getThis()); + EnumDescriptor *desc = UNBOX(EnumDescriptor, getThis()); + EnumDescriptorInternal *intern = desc->intern; int field_num = upb_enumdef_numvals(intern->enumdef); if (index < 0 || index >= field_num) { zend_error(E_USER_ERROR, "Cannot get element at %ld.\n", index); @@ -312,7 +313,8 @@ PHP_METHOD(EnumDescriptor, getValue) { } PHP_METHOD(EnumDescriptor, getValueCount) { - EnumDescriptor *intern = UNBOX(EnumDescriptor, getThis()); + EnumDescriptor *desc = UNBOX(EnumDescriptor, getThis()); + EnumDescriptorInternal *intern = desc->intern; RETURN_LONG(upb_enumdef_numvals(intern->enumdef)); } @@ -440,13 +442,32 @@ PHP_METHOD(FieldDescriptor, getEnumType) { return; } const upb_enumdef *enumdef = upb_fielddef_enumsubdef(intern->fielddef); - PHP_PROTO_HASHTABLE_VALUE desc = get_def_obj(enumdef); + PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj(enumdef); + + if (desc_php == NULL) { + EnumDescriptorInternal* intern = get_enumdef_enumdesc(enumdef); #if PHP_MAJOR_VERSION < 7 - RETURN_ZVAL(desc, 1, 0); + MAKE_STD_ZVAL(desc_php); + ZVAL_OBJ(desc_php, enum_descriptor_type->create_object( + enum_descriptor_type TSRMLS_CC)); + Z_DELREF_P(desc_php); #else - GC_ADDREF(desc); - RETURN_OBJ(desc); + desc_php = + enum_descriptor_type->create_object(enum_descriptor_type TSRMLS_CC); + GC_DELREF(desc_php); +#endif + EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(EnumDescriptor, desc_php); + desc->intern = intern; + add_def_obj(enumdef, desc_php); + add_ce_obj(intern->klass, desc_php); + } + +#if PHP_MAJOR_VERSION < 7 + RETURN_ZVAL(desc_php, 1, 0); +#else + GC_ADDREF(desc_php); + RETURN_OBJ(desc_php); #endif } @@ -459,13 +480,32 @@ PHP_METHOD(FieldDescriptor, getMessageType) { return; } const upb_msgdef *msgdef = upb_fielddef_msgsubdef(intern->fielddef); - PHP_PROTO_HASHTABLE_VALUE desc = get_def_obj(msgdef); + PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj(msgdef); + + if (desc_php == NULL) { + DescriptorInternal* intern = get_msgdef_desc(msgdef); + +#if PHP_MAJOR_VERSION < 7 + MAKE_STD_ZVAL(desc_php); + ZVAL_OBJ(desc_php, descriptor_type->create_object( + descriptor_type TSRMLS_CC)); + Z_DELREF_P(desc_php); +#else + desc_php = + descriptor_type->create_object(descriptor_type TSRMLS_CC); + GC_DELREF(desc_php); +#endif + Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); + desc->intern = intern; + add_def_obj(msgdef, desc_php); + add_ce_obj(intern->klass, desc_php); + } #if PHP_MAJOR_VERSION < 7 - RETURN_ZVAL(desc, 1, 0); + RETURN_ZVAL(desc_php, 1, 0); #else - GC_ADDREF(desc); - RETURN_OBJ(desc); + GC_ADDREF(desc_php); + RETURN_OBJ(desc_php); #endif } @@ -579,7 +619,8 @@ zval* internal_generated_pool_php; zend_object *generated_pool_php; zend_object *internal_generated_pool_php; #endif -InternalDescriptorPool *generated_pool; // The actual generated pool +InternalDescriptorPoolImpl *generated_pool; +InternalDescriptorPoolImpl generated_pool_impl; // The actual generated pool void init_generated_pool_once(TSRMLS_D) { if (generated_pool == NULL) { @@ -589,22 +630,29 @@ void init_generated_pool_once(TSRMLS_D) { ZVAL_OBJ(internal_generated_pool_php, internal_descriptor_pool_type->create_object( internal_descriptor_pool_type TSRMLS_CC)); - generated_pool = UNBOX(InternalDescriptorPool, internal_generated_pool_php); ZVAL_OBJ(generated_pool_php, descriptor_pool_type->create_object( descriptor_pool_type TSRMLS_CC)); #else internal_generated_pool_php = internal_descriptor_pool_type->create_object( internal_descriptor_pool_type TSRMLS_CC); - generated_pool = (InternalDescriptorPool *)((char *)internal_generated_pool_php - - XtOffsetOf(InternalDescriptorPool, std)); generated_pool_php = descriptor_pool_type->create_object(descriptor_pool_type TSRMLS_CC); #endif + generated_pool = &generated_pool_impl; } } static void internal_descriptor_pool_init_c_instance( InternalDescriptorPool *pool TSRMLS_DC) { + pool->intern = &generated_pool_impl; +} + +static void internal_descriptor_pool_free_c( + InternalDescriptorPool *pool TSRMLS_DC) { +} + +void internal_descriptor_pool_impl_init( + InternalDescriptorPoolImpl *pool TSRMLS_DC) { pool->symtab = upb_symtab_new(); pool->fill_handler_cache = upb_handlercache_new(add_handlers_for_message, NULL); @@ -615,8 +663,8 @@ static void internal_descriptor_pool_init_c_instance( pool->json_fill_method_cache = upb_json_codecache_new(); } -static void internal_descriptor_pool_free_c( - InternalDescriptorPool *pool TSRMLS_DC) { +void internal_descriptor_pool_impl_destroy( + InternalDescriptorPoolImpl *pool TSRMLS_DC) { upb_symtab_free(pool->symtab); upb_handlercache_free(pool->fill_handler_cache); upb_handlercache_free(pool->pb_serialize_handler_cache); @@ -837,7 +885,8 @@ static void fill_classname(const char *fullname, static zend_class_entry *register_class(const upb_filedef *file, const char *fullname, PHP_PROTO_HASHTABLE_VALUE desc_php, - bool use_nested_submsg TSRMLS_DC) { + bool use_nested_submsg, + bool is_enum TSRMLS_DC) { // Prepend '.' to package name to make it absolute. In the 5 additional // bytes allocated, one for '.', one for trailing 0, and 3 for 'GPB' if // given message is google.protobuf.Empty. @@ -866,7 +915,15 @@ static zend_class_entry *register_class(const upb_filedef *file, } ret = PHP_PROTO_CE_UNREF(pce); add_ce_obj(ret, desc_php); - add_proto_obj(fullname, desc_php); + if (is_enum) { + EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(EnumDescriptor, desc_php); + add_ce_enumdesc(ret, desc->intern); + add_proto_enumdesc(fullname, desc->intern); + } else { + Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); + add_ce_desc(ret, desc->intern); + add_proto_desc(fullname, desc->intern); + } stringsink_uninit(&namesink); return ret; } @@ -888,7 +945,7 @@ bool depends_on_descriptor(const google_protobuf_FileDescriptorProto* file) { const upb_filedef *parse_and_add_descriptor(const char *data, PHP_PROTO_SIZE data_len, - InternalDescriptorPool *pool, + InternalDescriptorPoolImpl *pool, upb_arena *arena) { size_t n; google_protobuf_FileDescriptorSet *set; @@ -901,14 +958,22 @@ const upb_filedef *parse_and_add_descriptor(const char *data, if (!set) { zend_error(E_ERROR, "Failed to parse binary descriptor\n"); - return false; + return NULL; } files = google_protobuf_FileDescriptorSet_file(set, &n); if (n != 1) { zend_error(E_ERROR, "Serialized descriptors should have exactly one file"); - return false; + return NULL; + } + + // Check whether file has already been added. + upb_strview name = google_protobuf_FileDescriptorProto_name(files[0]); + // TODO(teboring): Needs another look up method which takes data and length. + file = upb_symtab_lookupfile2(pool->symtab, name.data, name.size); + if (file != NULL) { + return NULL; } // The PHP code generator currently special-cases descriptor.proto. It @@ -919,7 +984,7 @@ const upb_filedef *parse_and_add_descriptor(const char *data, NULL) { if (!parse_and_add_descriptor((char *)descriptor_proto, descriptor_proto_len, pool, arena)) { - return false; + return NULL; } } @@ -930,7 +995,7 @@ const upb_filedef *parse_and_add_descriptor(const char *data, } void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, - InternalDescriptorPool *pool, + InternalDescriptorPoolImpl *pool, bool use_nested_submsg TSRMLS_DC) { int i; upb_arena *arena; @@ -949,9 +1014,14 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, for (i = 0; i < upb_filedef_msgcount(file); i++) { const upb_msgdef *msgdef = upb_filedef_msg(file, i); CREATE_HASHTABLE_VALUE(desc, desc_php, Descriptor, descriptor_type); - desc->msgdef = msgdef; - desc->pool = pool; - add_def_obj(desc->msgdef, desc_php); + desc->intern = SYS_MALLOC(DescriptorInternal); + desc->intern->msgdef = msgdef; + desc->intern->pool = pool; + desc->intern->layout = NULL; + desc->intern->klass = NULL; + + add_def_obj(desc->intern->msgdef, desc_php); + add_msgdef_desc(desc->intern->msgdef, desc->intern); // Unlike other messages, MapEntry is shared by all map fields and doesn't // have generated PHP class. @@ -959,10 +1029,11 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, continue; } - desc->klass = register_class(file, upb_msgdef_fullname(msgdef), desc_php, - use_nested_submsg TSRMLS_CC); + desc->intern->klass = + register_class(file, upb_msgdef_fullname(msgdef), desc_php, + use_nested_submsg, false TSRMLS_CC); - if (desc->klass == NULL) { + if (desc->intern->klass == NULL) { return; } @@ -972,12 +1043,17 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, for (i = 0; i < upb_filedef_enumcount(file); i++) { const upb_enumdef *enumdef = upb_filedef_enum(file, i); CREATE_HASHTABLE_VALUE(desc, desc_php, EnumDescriptor, enum_descriptor_type); - desc->enumdef = enumdef; - add_def_obj(desc->enumdef, desc_php); - desc->klass = register_class(file, upb_enumdef_fullname(enumdef), desc_php, - use_nested_submsg TSRMLS_CC); + desc->intern = SYS_MALLOC(EnumDescriptorInternal); + desc->intern->enumdef = enumdef; + desc->intern->klass = NULL; + + add_def_obj(desc->intern->enumdef, desc_php); + add_enumdef_enumdesc(desc->intern->enumdef, desc->intern); + desc->intern->klass = + register_class(file, upb_enumdef_fullname(enumdef), desc_php, + use_nested_submsg, true TSRMLS_CC); - if (desc->klass == NULL) { + if (desc->intern->klass == NULL) { return; } } @@ -997,14 +1073,11 @@ PHP_METHOD(InternalDescriptorPool, internalAddGeneratedFile) { } InternalDescriptorPool *pool = UNBOX(InternalDescriptorPool, getThis()); - internal_add_generated_file(data, data_len, pool, + internal_add_generated_file(data, data_len, pool->intern, use_nested_submsg TSRMLS_CC); } PHP_METHOD(DescriptorPool, getDescriptorByClassName) { - DescriptorPool *public_pool = UNBOX(DescriptorPool, getThis()); - InternalDescriptorPool *pool = public_pool->intern; - char *classname = NULL; PHP_PROTO_SIZE classname_len; @@ -1019,29 +1092,44 @@ PHP_METHOD(DescriptorPool, getDescriptorByClassName) { RETURN_NULL(); } - PHP_PROTO_HASHTABLE_VALUE desc = get_ce_obj(PHP_PROTO_CE_UNREF(pce)); - if (desc == NULL) { - RETURN_NULL(); + PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(PHP_PROTO_CE_UNREF(pce)); + if (desc_php == NULL) { + DescriptorInternal* intern = get_ce_desc(PHP_PROTO_CE_UNREF(pce)); + if (intern == NULL) { + RETURN_NULL(); + } + +#if PHP_MAJOR_VERSION < 7 + MAKE_STD_ZVAL(desc_php); + ZVAL_OBJ(desc_php, descriptor_type->create_object( + descriptor_type TSRMLS_CC)); + Z_DELREF_P(desc_php); +#else + desc_php = + descriptor_type->create_object(descriptor_type TSRMLS_CC); + GC_DELREF(desc_php); +#endif + Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); + desc->intern = intern; + add_def_obj(intern->msgdef, desc_php); + add_ce_obj(PHP_PROTO_CE_UNREF(pce), desc_php); } - zend_class_entry* instance_ce = HASHTABLE_VALUE_CE(desc); + zend_class_entry* instance_ce = HASHTABLE_VALUE_CE(desc_php); if (!instanceof_function(instance_ce, descriptor_type TSRMLS_CC)) { RETURN_NULL(); } #if PHP_MAJOR_VERSION < 7 - RETURN_ZVAL(desc, 1, 0); + RETURN_ZVAL(desc_php, 1, 0); #else - GC_ADDREF(desc); - RETURN_OBJ(desc); + GC_ADDREF(desc_php); + RETURN_OBJ(desc_php); #endif } PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) { - DescriptorPool *public_pool = UNBOX(DescriptorPool, getThis()); - InternalDescriptorPool *pool = public_pool->intern; - char *classname = NULL; PHP_PROTO_SIZE classname_len; @@ -1056,21 +1144,39 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) { RETURN_NULL(); } - PHP_PROTO_HASHTABLE_VALUE desc = get_ce_obj(PHP_PROTO_CE_UNREF(pce)); - if (desc == NULL) { - RETURN_NULL(); + PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(PHP_PROTO_CE_UNREF(pce)); + if (desc_php == NULL) { + EnumDescriptorInternal* intern = get_ce_enumdesc(PHP_PROTO_CE_UNREF(pce)); + if (intern == NULL) { + RETURN_NULL(); + } + +#if PHP_MAJOR_VERSION < 7 + MAKE_STD_ZVAL(desc_php); + ZVAL_OBJ(desc_php, enum_descriptor_type->create_object( + enum_descriptor_type TSRMLS_CC)); + Z_DELREF_P(desc_php); +#else + desc_php = + enum_descriptor_type->create_object(enum_descriptor_type TSRMLS_CC); + GC_DELREF(desc_php); +#endif + EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(EnumDescriptor, desc_php); + desc->intern = intern; + add_def_obj(intern->enumdef, desc_php); + add_ce_obj(PHP_PROTO_CE_UNREF(pce), desc_php); } - zend_class_entry* instance_ce = HASHTABLE_VALUE_CE(desc); + zend_class_entry* instance_ce = HASHTABLE_VALUE_CE(desc_php); if (!instanceof_function(instance_ce, enum_descriptor_type TSRMLS_CC)) { RETURN_NULL(); } #if PHP_MAJOR_VERSION < 7 - RETURN_ZVAL(desc, 1, 0); + RETURN_ZVAL(desc_php, 1, 0); #else - GC_ADDREF(desc); - RETURN_OBJ(desc); + GC_ADDREF(desc_php); + RETURN_OBJ(desc_php); #endif } diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 2612d22d66..14808eb1ae 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -428,8 +428,7 @@ static void *appendsubmsg_handler(void *closure, const void *hd) { RepeatedField* intern = UNBOX(RepeatedField, array); const submsg_handlerdata_t *submsgdata = hd; - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; @@ -456,8 +455,7 @@ static void *appendwrappersubmsg_handler(void *closure, const void *hd) { RepeatedField* intern = UNBOX(RepeatedField, array); const submsg_handlerdata_t *submsgdata = hd; - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; wrapperfields_parseframe_t* frame = @@ -488,8 +486,7 @@ static void *submsg_handler(void *closure, const void *hd) { MessageHeader* msg = closure; const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -522,8 +519,7 @@ static void *map_submsg_handler(void *closure, const void *hd) { MessageHeader* msg = closure; const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -557,8 +553,7 @@ static void *map_wrapper_submsg_handler(void *closure, const void *hd) { MessageHeader* msg = closure; const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -645,8 +640,7 @@ static void map_slot_init( break; } case UPB_TYPE_MESSAGE: { - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(value_msg)); + DescriptorInternal* subdesc = get_msgdef_desc(value_msg); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; #if PHP_MAJOR_VERSION < 7 @@ -802,8 +796,7 @@ static bool endmap_handler(void* closure, const void* hd, upb_status* s) { // pass the handlerdata down to the sub-message handler setup. static map_handlerdata_t* new_map_handlerdata( const upb_fielddef* field, - const upb_msgdef* mapentry_def, - Descriptor* desc) { + const upb_msgdef* mapentry_def) { const upb_fielddef* key_field; const upb_fielddef* value_field; // TODO(teboring): Use emalloc and efree. @@ -944,8 +937,7 @@ static void* oneofsubmsg_handler(void* closure, const void* hd) { const oneof_handlerdata_t *oneofdata = hd; uint32_t oldcase = DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)oneofdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -983,8 +975,7 @@ static void* wrapper_submsg_handler(void* closure, const void* hd) { MessageHeader* msg = closure; const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)submsgdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -1015,8 +1006,7 @@ static void* wrapper_oneofsubmsg_handler(void* closure, const void* hd) { const oneof_handlerdata_t *oneofdata = hd; uint32_t oldcase = DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); TSRMLS_FETCH(); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)oneofdata->md)); + DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md); zend_class_entry* subklass = subdesc->klass; wrapperfields_parseframe_t* frame = (wrapperfields_parseframe_t*)malloc(sizeof(wrapperfields_parseframe_t)); @@ -1164,10 +1154,9 @@ static void add_handlers_for_singular_field(upb_handlers *h, // Adds handlers to a map field. static void add_handlers_for_mapfield(upb_handlers* h, const upb_fielddef* fielddef, - size_t offset, - Descriptor* desc) { + size_t offset) { const upb_msgdef* map_msgdef = upb_fielddef_msgsubdef(fielddef); - map_handlerdata_t* hd = new_map_handlerdata(fielddef, map_msgdef, desc); + map_handlerdata_t* hd = new_map_handlerdata(fielddef, map_msgdef); upb_handlerattr attr = UPB_HANDLERATTR_INIT; upb_handlers_addcleanup(h, hd, free); @@ -1176,11 +1165,11 @@ static void add_handlers_for_mapfield(upb_handlers* h, } // Adds handlers to a map-entry msgdef. -static void add_handlers_for_mapentry(const upb_msgdef* msgdef, upb_handlers* h, - Descriptor* desc) { +static void add_handlers_for_mapentry( + const upb_msgdef* msgdef, upb_handlers* h) { const upb_fielddef* key_field = map_entry_key(msgdef); const upb_fielddef* value_field = map_entry_value(msgdef); - map_handlerdata_t* hd = new_map_handlerdata(0, msgdef, desc); + map_handlerdata_t* hd = new_map_handlerdata(0, msgdef); upb_handlerattr attr = UPB_HANDLERATTR_INIT; upb_handlers_addcleanup(h, hd, free); @@ -1294,11 +1283,11 @@ static bool strwrapper_end_handler(void *closure, const void *hd) { static void add_handlers_for_wrapper(const upb_msgdef* msgdef, upb_handlers* h) { const upb_fielddef* f = upb_msgdef_itof(msgdef, 1); - Descriptor* desc; + DescriptorInternal* desc; size_t offset; TSRMLS_FETCH(); - desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)msgdef)); + desc = get_msgdef_desc(msgdef); offset = desc->layout->fields[upb_fielddef_index(f)].offset; switch (upb_msgdef_wellknowntype(msgdef)) { @@ -1357,14 +1346,13 @@ static bool add_unknown_handler(void* closure, const void* hd, const char* buf, void add_handlers_for_message(const void* closure, upb_handlers* h) { const upb_msgdef* msgdef = upb_handlers_msgdef(h); TSRMLS_FETCH(); - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)msgdef)); + DescriptorInternal* desc = get_msgdef_desc(msgdef); upb_msg_field_iter i; // If this is a mapentry message type, set up a special set of handlers and // bail out of the normal (user-defined) message type handling. if (upb_msgdef_mapentry(msgdef)) { - add_handlers_for_mapentry(msgdef, h, desc); + add_handlers_for_mapentry(msgdef, h); return; } @@ -1402,7 +1390,7 @@ void add_handlers_for_message(const void* closure, upb_handlers* h) { add_handlers_for_oneof_field(h, desc->msgdef, f, offset, oneof_case_offset, property_cache_index); } else if (is_map_field(f)) { - add_handlers_for_mapfield(h, f, offset, desc); + add_handlers_for_mapfield(h, f, offset); } else if (upb_fielddef_isseq(f)) { add_handlers_for_repeated_field(h, f, offset); } else { @@ -1413,15 +1401,15 @@ void add_handlers_for_message(const void* closure, upb_handlers* h) { // Constructs the handlers for filling a message's data into an in-memory // object. -const upb_handlers* get_fill_handlers(Descriptor* desc) { +const upb_handlers* get_fill_handlers(DescriptorInternal* desc) { return upb_handlercache_get(desc->pool->fill_handler_cache, desc->msgdef); } -static const upb_pbdecodermethod *msgdef_decodermethod(Descriptor* desc) { +static const upb_pbdecodermethod *msgdef_decodermethod(DescriptorInternal* desc) { return upb_pbcodecache_get(desc->pool->fill_method_cache, desc->msgdef); } -static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) { +static const upb_json_parsermethod *msgdef_jsonparsermethod(DescriptorInternal* desc) { return upb_json_codecache_get(desc->pool->json_fill_method_cache, desc->msgdef); } @@ -1429,21 +1417,21 @@ static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) { // Serializing. // ----------------------------------------------------------------------------- -static void putmsg(zval* msg, const Descriptor* desc, upb_sink sink, +static void putmsg(zval* msg, const DescriptorInternal* desc, upb_sink sink, int depth, bool is_json TSRMLS_DC); -static void putrawmsg(MessageHeader* msg, const Descriptor* desc, +static void putrawmsg(MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth, bool is_json, bool open_msg TSRMLS_DC); static void putwrappervalue( zval* value, const upb_fielddef* f, upb_sink sink, int depth, bool is_json TSRMLS_DC); -static void putjsonany(MessageHeader* msg, const Descriptor* desc, +static void putjsonany(MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC); static void putjsonlistvalue( - MessageHeader* msg, const Descriptor* desc, + MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC); static void putjsonstruct( - MessageHeader* msg, const Descriptor* desc, + MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC); static void putstr(zval* str, const upb_fielddef* f, upb_sink sink, @@ -1590,16 +1578,16 @@ static void putmap(zval* map, const upb_fielddef* f, upb_sink sink, upb_sink_endseq(sink, getsel(f, UPB_HANDLER_ENDSEQ)); } -static void putmsg(zval* msg_php, const Descriptor* desc, upb_sink sink, +static void putmsg(zval* msg_php, const DescriptorInternal* desc, upb_sink sink, int depth, bool is_json TSRMLS_DC) { MessageHeader* msg = UNBOX(MessageHeader, msg_php); putrawmsg(msg, desc, sink, depth, is_json, true TSRMLS_CC); } static const upb_handlers* msgdef_json_serialize_handlers( - Descriptor* desc, bool preserve_proto_fieldnames); + DescriptorInternal* desc, bool preserve_proto_fieldnames); -static void putjsonany(MessageHeader* msg, const Descriptor* desc, +static void putjsonany(MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC) { upb_status status; const upb_fielddef* type_field = upb_msgdef_itof(desc->msgdef, UPB_ANY_TYPE); @@ -1646,8 +1634,7 @@ static void putjsonany(MessageHeader* msg, const Descriptor* desc, value_len = Z_STRLEN_P(value_php_str); if (value_len > 0) { - Descriptor* payload_desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj((void*)payload_type)); + DescriptorInternal* payload_desc = get_msgdef_desc(payload_type); zend_class_entry* payload_klass = payload_desc->klass; zval val; upb_sink subsink; @@ -1682,7 +1669,7 @@ static void putjsonany(MessageHeader* msg, const Descriptor* desc, } static void putjsonlistvalue( - MessageHeader* msg, const Descriptor* desc, + MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC) { upb_status status; upb_sink subsink; @@ -1716,7 +1703,7 @@ static void putjsonlistvalue( } static void putjsonstruct( - MessageHeader* msg, const Descriptor* desc, + MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth TSRMLS_DC) { upb_status status; upb_sink subsink; @@ -1747,7 +1734,7 @@ static void putjsonstruct( upb_sink_endmsg(sink, &status); } -static void putrawmsg(MessageHeader* msg, const Descriptor* desc, +static void putrawmsg(MessageHeader* msg, const DescriptorInternal* desc, upb_sink sink, int depth, bool is_json, bool open_msg TSRMLS_DC) { upb_msg_field_iter i; @@ -1976,8 +1963,8 @@ static void putrawsubmsg(MessageHeader* submsg, const upb_fielddef* f, upb_sink sink, int depth, bool is_json TSRMLS_DC) { upb_sink subsink; - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(upb_fielddef_msgsubdef(f))); + const upb_msgdef* m = upb_fielddef_msgsubdef(f); + DescriptorInternal* subdesc = get_msgdef_desc(m); upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink); putrawmsg(submsg, subdesc, subsink, depth + 1, is_json, true TSRMLS_CC); @@ -2051,13 +2038,13 @@ static void putarray(zval* array, const upb_fielddef* f, upb_sink sink, upb_sink_endseq(sink, getsel(f, UPB_HANDLER_ENDSEQ)); } -static const upb_handlers* msgdef_pb_serialize_handlers(Descriptor* desc) { +static const upb_handlers* msgdef_pb_serialize_handlers(DescriptorInternal* desc) { return upb_handlercache_get(desc->pool->pb_serialize_handler_cache, desc->msgdef); } static const upb_handlers* msgdef_json_serialize_handlers( - Descriptor* desc, bool preserve_proto_fieldnames) { + DescriptorInternal* desc, bool preserve_proto_fieldnames) { if (preserve_proto_fieldnames) { return upb_handlercache_get( desc->pool->json_serialize_handler_preserve_cache, desc->msgdef); @@ -2072,8 +2059,7 @@ static const upb_handlers* msgdef_json_serialize_handlers( // ----------------------------------------------------------------------------- void serialize_to_string(zval* val, zval* return_value TSRMLS_DC) { - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(val))); + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(val)); stringsink sink; stringsink_init(&sink); @@ -2100,7 +2086,7 @@ PHP_METHOD(Message, serializeToString) { serialize_to_string(getThis(), return_value TSRMLS_CC); } -void merge_from_string(const char* data, int data_len, Descriptor* desc, +void merge_from_string(const char* data, int data_len, DescriptorInternal* desc, MessageHeader* msg) { const upb_pbdecodermethod* method = msgdef_decodermethod(desc); const upb_handlers* h = upb_pbdecodermethod_desthandlers(method); @@ -2133,8 +2119,7 @@ void merge_from_string(const char* data, int data_len, Descriptor* desc, } PHP_METHOD(Message, mergeFromString) { - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(getThis())); MessageHeader* msg = UNBOX(MessageHeader, getThis()); char *data = NULL; @@ -2149,8 +2134,7 @@ PHP_METHOD(Message, mergeFromString) { } PHP_METHOD(Message, serializeToJsonString) { - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(getThis())); zend_bool preserve_proto_fieldnames = false; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", @@ -2180,8 +2164,7 @@ PHP_METHOD(Message, serializeToJsonString) { } PHP_METHOD(Message, mergeFromJsonString) { - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(getThis()))); + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(getThis())); MessageHeader* msg = UNBOX(MessageHeader, getThis()); char *data = NULL; @@ -2244,7 +2227,7 @@ static void discard_unknown_fields(MessageHeader* msg) { } // Recursively discard unknown fields of submessages. - Descriptor* desc = msg->descriptor; + DescriptorInternal* desc = msg->descriptor; TSRMLS_FETCH(); for (upb_msg_field_begin(&it, desc->msgdef); !upb_msg_field_done(&it); diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 291c2e5dfe..e80ec4ec37 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -255,7 +255,7 @@ void* message_data(MessageHeader* msg) { void custom_data_init(const zend_class_entry* ce, MessageHeader* intern PHP_PROTO_TSRMLS_DC) { - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(ce)); + DescriptorInternal* desc = get_ce_desc(ce); intern->data = ALLOC_N(uint8_t, desc->layout->size); // We wrap first so that everything in the message object is GC-rooted in // case a collection happens during object creation in layout_init(). @@ -279,15 +279,15 @@ void build_class_from_descriptor( Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, php_descriptor); // Map entries don't have existing php class. - if (upb_msgdef_mapentry(desc->msgdef)) { + if (upb_msgdef_mapentry(desc->intern->msgdef)) { return; } - zend_class_entry* registered_ce = desc->klass; + zend_class_entry* registered_ce = desc->intern->klass; - if (desc->layout == NULL) { - MessageLayout* layout = create_layout(desc->msgdef); - desc->layout = layout; + if (desc->intern->layout == NULL) { + MessageLayout* layout = create_layout(desc->intern->msgdef); + desc->intern->layout = layout; } registered_ce->create_object = message_create; @@ -395,8 +395,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { is_wrapper = is_wrapper_msg(submsgdef); if (is_wrapper) { - PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj(submsgdef); - Descriptor* subdesc = UNBOX_HASHTABLE_VALUE(Descriptor, subdesc_php); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); subklass = subdesc->klass; } } @@ -435,8 +434,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { is_wrapper = is_wrapper_msg(submsgdef); if (is_wrapper) { - PHP_PROTO_HASHTABLE_VALUE subdesc_php = get_def_obj(submsgdef); - Descriptor* subdesc = UNBOX_HASHTABLE_VALUE(Descriptor, subdesc_php); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); subklass = subdesc->klass; } } @@ -459,8 +457,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { } } else if (upb_fielddef_issubmsg(field)) { const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field); - PHP_PROTO_HASHTABLE_VALUE desc_php = get_def_obj(submsgdef); - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); + DescriptorInternal* desc = get_msgdef_desc(submsgdef); CACHED_VALUE* cached = NULL; if (upb_fielddef_containingoneof(field)) { @@ -530,7 +527,7 @@ PHP_METHOD(Message, __construct) { PHP_METHOD(Message, clear) { MessageHeader* msg = UNBOX(MessageHeader, getThis()); - Descriptor* desc = msg->descriptor; + DescriptorInternal* desc = msg->descriptor; zend_class_entry* ce = desc->klass; zend_object_std_dtor(&msg->std TSRMLS_CC); @@ -1536,14 +1533,13 @@ PHP_METHOD(Any, unpack) { } const char* fully_qualified_name = type_url + url_prefix_len; - PHP_PROTO_HASHTABLE_VALUE desc_php = get_proto_obj(fully_qualified_name); - if (desc_php == NULL) { + DescriptorInternal* desc = get_proto_desc(fully_qualified_name); + if (desc == NULL) { zend_throw_exception( NULL, "Specified message in any hasn't been added to descriptor pool", 0 TSRMLS_CC); return; } - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); zend_class_entry* klass = desc->klass; ZVAL_OBJ(return_value, klass->create_object(klass TSRMLS_CC)); MessageHeader* msg = UNBOX(MessageHeader, return_value); @@ -1589,8 +1585,7 @@ PHP_METHOD(Any, pack) { PHP_PROTO_FAKE_SCOPE_END; // Set type url. - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(Z_OBJCE_P(val))); + DescriptorInternal* desc = get_ce_desc(Z_OBJCE_P(val)); const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); size_t type_url_len = strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; @@ -1617,14 +1612,12 @@ PHP_METHOD(Any, is) { return; } - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(klass); - if (desc_php == NULL) { + DescriptorInternal* desc = get_ce_desc(klass); + if (desc == NULL) { RETURN_BOOL(false); } // Create corresponded type url. - Descriptor* desc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_ce_obj(klass)); const char* fully_qualified_name = upb_msgdef_fullname(desc->msgdef); size_t type_url_len = strlen(TYPE_URL_PREFIX) + strlen(fully_qualified_name) + 1; diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 19cc5efb4e..fd97c89bd7 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -32,7 +32,6 @@ #include -ZEND_DECLARE_MODULE_GLOBALS(protobuf) static PHP_GINIT_FUNCTION(protobuf); static PHP_GSHUTDOWN_FUNCTION(protobuf); static PHP_RINIT_FUNCTION(protobuf); @@ -43,13 +42,19 @@ static PHP_MSHUTDOWN_FUNCTION(protobuf); // Global map from upb {msg,enum}defs to wrapper Descriptor/EnumDescriptor // instances. static HashTable* upb_def_to_php_obj_map; +static upb_inttable upb_def_to_desc_map_persistent; +static upb_inttable upb_def_to_enumdesc_map_persistent; // Global map from message/enum's php class entry to corresponding wrapper // Descriptor/EnumDescriptor instances. static HashTable* ce_to_php_obj_map; +static upb_inttable ce_to_desc_map_persistent; +static upb_inttable ce_to_enumdesc_map_persistent; // Global map from message/enum's proto fully-qualified name to corresponding // wrapper Descriptor/EnumDescriptor instances. -static HashTable* proto_to_php_obj_map; -static HashTable* reserved_names; +static upb_strtable proto_to_desc_map_persistent; +static upb_strtable proto_to_enumdesc_map_persistent; + +upb_strtable reserved_names; // ----------------------------------------------------------------------------- // Global maps. @@ -78,12 +83,6 @@ static bool exist_in_table(const HashTable* t, const void* def) { (void**)&value) == SUCCESS); } -static void add_to_list(HashTable* t, void* value) { - zval* pDest = NULL; - php_proto_zend_hash_next_index_insert_mem(t, &value, sizeof(void*), - (void**)&pDest); -} - static void add_to_strtable(HashTable* t, const char* key, int key_size, void* value) { zval* pDest = NULL; @@ -113,6 +112,40 @@ PHP_PROTO_HASHTABLE_VALUE get_def_obj(const void* def) { return (PHP_PROTO_HASHTABLE_VALUE)get_from_table(upb_def_to_php_obj_map, def); } +void add_msgdef_desc(const upb_msgdef* m, DescriptorInternal* desc) { + upb_inttable_insertptr(&upb_def_to_desc_map_persistent, + m, upb_value_ptr(desc)); +} + +DescriptorInternal* get_msgdef_desc(const upb_msgdef* m) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_inttable_lookupptr(&upb_def_to_desc_map_persistent, m, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + +void add_enumdef_enumdesc(const upb_enumdef* e, EnumDescriptorInternal* desc) { + upb_inttable_insertptr(&upb_def_to_enumdesc_map_persistent, + e, upb_value_ptr(desc)); +} + +EnumDescriptorInternal* get_enumdef_enumdesc(const upb_enumdef* e) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_inttable_lookupptr(&upb_def_to_enumdesc_map_persistent, e, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + void add_ce_obj(const void* ce, PHP_PROTO_HASHTABLE_VALUE value) { #if PHP_MAJOR_VERSION < 7 Z_ADDREF_P(value); @@ -126,22 +159,77 @@ PHP_PROTO_HASHTABLE_VALUE get_ce_obj(const void* ce) { return (PHP_PROTO_HASHTABLE_VALUE)get_from_table(ce_to_php_obj_map, ce); } +void add_ce_desc(const zend_class_entry* ce, DescriptorInternal* desc) { + upb_inttable_insertptr(&ce_to_desc_map_persistent, + ce, upb_value_ptr(desc)); +} + +DescriptorInternal* get_ce_desc(const zend_class_entry* ce) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_inttable_lookupptr(&ce_to_desc_map_persistent, ce, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + +void add_ce_enumdesc(const zend_class_entry* ce, EnumDescriptorInternal* desc) { + upb_inttable_insertptr(&ce_to_enumdesc_map_persistent, + ce, upb_value_ptr(desc)); +} + +EnumDescriptorInternal* get_ce_enumdesc(const zend_class_entry* ce) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_inttable_lookupptr(&ce_to_enumdesc_map_persistent, ce, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + bool class_added(const void* ce) { return exist_in_table(ce_to_php_obj_map, ce); } -void add_proto_obj(const char* proto, PHP_PROTO_HASHTABLE_VALUE value) { -#if PHP_MAJOR_VERSION < 7 - Z_ADDREF_P(value); -#else - GC_ADDREF(value); +void add_proto_desc(const char* proto, DescriptorInternal* desc) { + upb_strtable_insert(&proto_to_desc_map_persistent, proto, + upb_value_ptr(desc)); +} + +DescriptorInternal* get_proto_desc(const char* proto) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; #endif - add_to_strtable(proto_to_php_obj_map, proto, strlen(proto), value); + if (!upb_strtable_lookup(&proto_to_desc_map_persistent, proto, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } } -PHP_PROTO_HASHTABLE_VALUE get_proto_obj(const char* proto) { - return (PHP_PROTO_HASHTABLE_VALUE)get_from_strtable(proto_to_php_obj_map, - proto, strlen(proto)); +void add_proto_enumdesc(const char* proto, EnumDescriptorInternal* desc) { + upb_strtable_insert2(&proto_to_enumdesc_map_persistent, proto, + strlen(proto), upb_value_ptr(desc)); +} + +EnumDescriptorInternal* get_proto_enumdesc(const char* proto) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_strtable_lookupptr(&proto_to_enumdesc_map_persistent, + proto, strlen(proto), &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } } // ----------------------------------------------------------------------------- @@ -184,9 +272,11 @@ const char *const kReservedNames[] = { const int kReservedNamesSize = 73; bool is_reserved_name(const char* name) { - void** value; - return (php_proto_zend_hash_find(reserved_names, name, strlen(name), - (void**)&value) == SUCCESS); + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_UINT64; +#endif + return upb_strtable_lookup2(&reserved_names, name, strlen(name), &v); } // ----------------------------------------------------------------------------- @@ -241,30 +331,21 @@ static void php_proto_hashtable_descriptor_release(zval* value) { } efree(ptr); } -#endif - -static PHP_RINIT_FUNCTION(protobuf) { - int i = 0; - - ALLOC_HASHTABLE(upb_def_to_php_obj_map); - zend_hash_init(upb_def_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0); - ALLOC_HASHTABLE(ce_to_php_obj_map); - zend_hash_init(ce_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0); +static void test_release(void* value) { + void* ptr = value; +} +#endif - ALLOC_HASHTABLE(proto_to_php_obj_map); - zend_hash_init(proto_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0); +static initialize_persistent_descriptor_pool(TSRMLS_D) { + upb_inttable_init(&upb_def_to_desc_map_persistent, UPB_CTYPE_PTR); + upb_inttable_init(&upb_def_to_enumdesc_map_persistent, UPB_CTYPE_PTR); + upb_inttable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR); + upb_inttable_init(&ce_to_enumdesc_map_persistent, UPB_CTYPE_PTR); + upb_strtable_init(&proto_to_desc_map_persistent, UPB_CTYPE_PTR); + upb_strtable_init(&proto_to_enumdesc_map_persistent, UPB_CTYPE_PTR); - ALLOC_HASHTABLE(reserved_names); - zend_hash_init(reserved_names, 16, NULL, NULL, 0); - for (i = 0; i < kReservedNamesSize; i++) { - php_proto_zend_hash_update(reserved_names, kReservedNames[i], - strlen(kReservedNames[i])); - } - - generated_pool = NULL; - generated_pool_php = NULL; - internal_generated_pool_php = NULL; + internal_descriptor_pool_impl_init(&generated_pool_impl TSRMLS_CC); is_inited_file_any = false; is_inited_file_api = false; @@ -276,10 +357,72 @@ static PHP_RINIT_FUNCTION(protobuf) { is_inited_file_timestamp = false; is_inited_file_type = false; is_inited_file_wrappers = false; +} + +static PHP_RINIT_FUNCTION(protobuf) { + ALLOC_HASHTABLE(upb_def_to_php_obj_map); + zend_hash_init(upb_def_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0); + + ALLOC_HASHTABLE(ce_to_php_obj_map); + zend_hash_init(ce_to_php_obj_map, 16, NULL, HASHTABLE_VALUE_DTOR, 0); + + generated_pool = NULL; + generated_pool_php = NULL; + internal_generated_pool_php = NULL; + + if (!PROTOBUF_G(keep_descriptor_pool_after_request)) { + initialize_persistent_descriptor_pool(TSRMLS_C); + } return 0; } +static void cleanup_desc_table(upb_inttable* t) { + upb_inttable_iter i; + upb_value v; + DescriptorInternal* desc; + for(upb_inttable_begin(&i, t); + !upb_inttable_done(&i); + upb_inttable_next(&i)) { + v = upb_inttable_iter_value(&i); + desc = upb_value_getptr(v); + if (desc->layout) { + free_layout(desc->layout); + } + SYS_FREE(desc); + } +} + +static void cleanup_enumdesc_table(upb_inttable* t) { + upb_inttable_iter i; + upb_value v; + EnumDescriptorInternal* desc; + for(upb_inttable_begin(&i, t); + !upb_inttable_done(&i); + upb_inttable_next(&i)) { + v = upb_inttable_iter_value(&i); + desc = upb_value_getptr(v); + SYS_FREE(desc); + } +} + +static cleanup_persistent_descriptor_pool(TSRMLS_D) { + // Clean up + + // Only needs to clean one map out of three (def=>desc, ce=>desc, proto=>desc) + cleanup_desc_table(&upb_def_to_desc_map_persistent); + cleanup_enumdesc_table(&upb_def_to_enumdesc_map_persistent); + + internal_descriptor_pool_impl_destroy(&generated_pool_impl TSRMLS_CC); + + upb_inttable_uninit(&upb_def_to_desc_map_persistent); + upb_inttable_uninit(&upb_def_to_enumdesc_map_persistent); + upb_inttable_uninit(&ce_to_desc_map_persistent); + upb_inttable_uninit(&ce_to_enumdesc_map_persistent); + upb_strtable_uninit(&proto_to_desc_map_persistent); + upb_strtable_uninit(&proto_to_enumdesc_map_persistent); +} + static PHP_RSHUTDOWN_FUNCTION(protobuf) { zend_hash_destroy(upb_def_to_php_obj_map); FREE_HASHTABLE(upb_def_to_php_obj_map); @@ -287,12 +430,6 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) { zend_hash_destroy(ce_to_php_obj_map); FREE_HASHTABLE(ce_to_php_obj_map); - zend_hash_destroy(proto_to_php_obj_map); - FREE_HASHTABLE(proto_to_php_obj_map); - - zend_hash_destroy(reserved_names); - FREE_HASHTABLE(reserved_names); - #if PHP_MAJOR_VERSION < 7 if (generated_pool_php != NULL) { zval_dtor(generated_pool_php); @@ -315,21 +452,42 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) { } #endif - is_inited_file_any = true; - is_inited_file_api = true; - is_inited_file_duration = true; - is_inited_file_field_mask = true; - is_inited_file_empty = true; - is_inited_file_source_context = true; - is_inited_file_struct = true; - is_inited_file_timestamp = true; - is_inited_file_type = true; - is_inited_file_wrappers = true; + if (!PROTOBUF_G(keep_descriptor_pool_after_request)) { + cleanup_persistent_descriptor_pool(TSRMLS_C); + } return 0; } +static void reserved_names_init() { + size_t i; + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_UINT64; +#endif + for (i = 0; i < kReservedNamesSize; i++) { + upb_strtable_insert2(&reserved_names, kReservedNames[i], + strlen(kReservedNames[i]), v); + } +} + +PHP_INI_BEGIN() +STD_PHP_INI_ENTRY("protobuf.keep_descriptor_pool_after_request", "0", + PHP_INI_SYSTEM, OnUpdateBool, + keep_descriptor_pool_after_request, zend_protobuf_globals, + protobuf_globals) +PHP_INI_END() + static PHP_MINIT_FUNCTION(protobuf) { + REGISTER_INI_ENTRIES(); + + upb_strtable_init(&reserved_names, UPB_CTYPE_UINT64); + reserved_names_init(); + + if (PROTOBUF_G(keep_descriptor_pool_after_request)) { + initialize_persistent_descriptor_pool(TSRMLS_C); + } + descriptor_pool_init(TSRMLS_C); descriptor_init(TSRMLS_C); enum_descriptor_init(TSRMLS_C); @@ -391,6 +549,12 @@ static PHP_MINIT_FUNCTION(protobuf) { } static PHP_MSHUTDOWN_FUNCTION(protobuf) { + if (PROTOBUF_G(keep_descriptor_pool_after_request)) { + cleanup_persistent_descriptor_pool(TSRMLS_C); + } + + upb_strtable_uninit(&reserved_names); + PEFREE(message_handlers); PEFREE(repeated_field_handlers); PEFREE(repeated_field_iter_handlers); diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 908134118f..1fd90f21af 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -171,7 +171,7 @@ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ LOWWERNAME##_type->create_object = LOWWERNAME##_create; \ - LOWWERNAME##_handlers = PEMALLOC(zend_object_handlers); \ + LOWWERNAME##_handlers = PEMALLOC(zend_object_handlers, 1); \ memcpy(LOWWERNAME##_handlers, zend_get_std_object_handlers(), \ sizeof(zend_object_handlers)); #define PHP_PROTO_INIT_CLASS_END \ @@ -440,7 +440,7 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ LOWWERNAME##_type->create_object = LOWWERNAME##_create; \ - LOWWERNAME##_handlers = PEMALLOC(zend_object_handlers); \ + LOWWERNAME##_handlers = PEMALLOC(zend_object_handlers, 1); \ memcpy(LOWWERNAME##_handlers, zend_get_std_object_handlers(), \ sizeof(zend_object_handlers)); \ LOWWERNAME##_handlers->free_obj = LOWWERNAME##_free; \ @@ -590,11 +590,13 @@ struct Api; struct BoolValue; struct BytesValue; struct Descriptor; +struct DescriptorInternal; struct DescriptorPool; struct DoubleValue; struct Duration; struct Enum; struct EnumDescriptor; +struct EnumDescriptorInternal; struct EnumValue; struct EnumValueDescriptor; struct Field; @@ -607,6 +609,7 @@ struct GPBEmpty; struct Int32Value; struct Int64Value; struct InternalDescriptorPool; +struct InternalDescriptorPoolImpl; struct ListValue; struct Map; struct MapIter; @@ -635,10 +638,12 @@ typedef struct Api Api; typedef struct BoolValue BoolValue; typedef struct BytesValue BytesValue; typedef struct Descriptor Descriptor; +typedef struct DescriptorInternal DescriptorInternal; typedef struct DescriptorPool DescriptorPool; typedef struct DoubleValue DoubleValue; typedef struct Duration Duration; typedef struct EnumDescriptor EnumDescriptor; +typedef struct EnumDescriptorInternal EnumDescriptorInternal; typedef struct Enum Enum; typedef struct EnumValueDescriptor EnumValueDescriptor; typedef struct EnumValue EnumValue; @@ -652,6 +657,7 @@ typedef struct GPBEmpty GPBEmpty; typedef struct Int32Value Int32Value; typedef struct Int64Value Int64Value; typedef struct InternalDescriptorPool InternalDescriptorPool; +typedef struct InternalDescriptorPoolImpl InternalDescriptorPoolImpl; typedef struct ListValue ListValue; typedef struct MapIter MapIter; typedef struct Map Map; @@ -680,8 +686,17 @@ typedef struct Value Value; // ----------------------------------------------------------------------------- ZEND_BEGIN_MODULE_GLOBALS(protobuf) + zend_bool keep_descriptor_pool_after_request; ZEND_END_MODULE_GLOBALS(protobuf) +ZEND_DECLARE_MODULE_GLOBALS(protobuf) + +#ifdef ZTS +#define PROTOBUF_G(v) TSRMG(protobuf_globals_id, zend_protobuf_globals *, v) +#else +#define PROTOBUF_G(v) (protobuf_globals.v) +#endif + // Init module and PHP classes. void any_init(TSRMLS_D); void api_init(TSRMLS_D); @@ -743,17 +758,27 @@ void gpb_metadata_wrappers_init(TSRMLS_D); // instances. void add_def_obj(const void* def, PHP_PROTO_HASHTABLE_VALUE value); PHP_PROTO_HASHTABLE_VALUE get_def_obj(const void* def); +void add_msgdef_desc(const upb_msgdef* m, DescriptorInternal* desc); +DescriptorInternal* get_msgdef_desc(const upb_msgdef* m); +void add_enumdef_enumdesc(const upb_enumdef* e, EnumDescriptorInternal* desc); +EnumDescriptorInternal* get_enumdef_enumdesc(const upb_enumdef* e); // Global map from PHP class entries to wrapper Descriptor/EnumDescriptor // instances. void add_ce_obj(const void* ce, PHP_PROTO_HASHTABLE_VALUE value); PHP_PROTO_HASHTABLE_VALUE get_ce_obj(const void* ce); bool class_added(const void* ce); +void add_ce_desc(const zend_class_entry* ce, DescriptorInternal* desc); +DescriptorInternal* get_ce_desc(const zend_class_entry* ce); +void add_ce_enumdesc(const zend_class_entry* ce, EnumDescriptorInternal* desc); +EnumDescriptorInternal* get_ce_enumdesc(const zend_class_entry* ce); // Global map from message/enum's proto fully-qualified name to corresponding // wrapper Descriptor/EnumDescriptor instances. -void add_proto_obj(const char* proto, PHP_PROTO_HASHTABLE_VALUE value); -PHP_PROTO_HASHTABLE_VALUE get_proto_obj(const char* proto); +void add_proto_desc(const char* proto, DescriptorInternal* desc); +DescriptorInternal* get_proto_desc(const char* proto); +void add_proto_enumdesc(const char* proto, EnumDescriptorInternal* desc); +EnumDescriptorInternal* get_proto_enumdesc(const char* proto); extern zend_class_entry* map_field_type; extern zend_class_entry* repeated_field_type; @@ -763,14 +788,14 @@ extern zend_class_entry* repeated_field_type; // ----------------------------------------------------------------------------- PHP_PROTO_WRAP_OBJECT_START(DescriptorPool) - InternalDescriptorPool* intern; + InternalDescriptorPoolImpl* intern; PHP_PROTO_WRAP_OBJECT_END PHP_METHOD(DescriptorPool, getGeneratedPool); PHP_METHOD(DescriptorPool, getDescriptorByClassName); PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName); -PHP_PROTO_WRAP_OBJECT_START(InternalDescriptorPool) +struct InternalDescriptorPoolImpl { upb_symtab* symtab; upb_handlercache* fill_handler_cache; upb_handlercache* pb_serialize_handler_cache; @@ -778,13 +803,17 @@ PHP_PROTO_WRAP_OBJECT_START(InternalDescriptorPool) upb_handlercache* json_serialize_handler_preserve_cache; upb_pbcodecache* fill_method_cache; upb_json_codecache* json_fill_method_cache; +}; + +PHP_PROTO_WRAP_OBJECT_START(InternalDescriptorPool) + InternalDescriptorPoolImpl* intern; PHP_PROTO_WRAP_OBJECT_END PHP_METHOD(InternalDescriptorPool, getGeneratedPool); PHP_METHOD(InternalDescriptorPool, internalAddGeneratedFile); void internal_add_generated_file(const char* data, PHP_PROTO_SIZE data_len, - InternalDescriptorPool* pool, + InternalDescriptorPoolImpl* pool, bool use_nested_submsg TSRMLS_DC); void init_generated_pool_once(TSRMLS_D); void add_handlers_for_message(const void* closure, upb_handlers* h); @@ -801,13 +830,24 @@ extern zend_object *internal_generated_pool_php; void descriptor_pool_free(zend_object* object); void internal_descriptor_pool_free(zend_object* object); #endif -extern InternalDescriptorPool* generated_pool; // The actual generated pool +extern InternalDescriptorPoolImpl* generated_pool; +// The actual generated pool +extern InternalDescriptorPoolImpl generated_pool_impl; -PHP_PROTO_WRAP_OBJECT_START(Descriptor) - InternalDescriptorPool* pool; +void internal_descriptor_pool_impl_init( + InternalDescriptorPoolImpl *pool TSRMLS_DC); +void internal_descriptor_pool_impl_destroy( + InternalDescriptorPoolImpl *pool TSRMLS_DC); + +struct DescriptorInternal { + InternalDescriptorPoolImpl* pool; const upb_msgdef* msgdef; MessageLayout* layout; zend_class_entry* klass; // begins as NULL +}; + +PHP_PROTO_WRAP_OBJECT_START(Descriptor) + DescriptorInternal* intern; PHP_PROTO_WRAP_OBJECT_END PHP_METHOD(Descriptor, getClass); @@ -835,9 +875,13 @@ PHP_METHOD(FieldDescriptor, getMessageType); extern zend_class_entry* field_descriptor_type; -PHP_PROTO_WRAP_OBJECT_START(EnumDescriptor) +struct EnumDescriptorInternal { const upb_enumdef* enumdef; zend_class_entry* klass; // begins as NULL +}; + +PHP_PROTO_WRAP_OBJECT_START(EnumDescriptor) + EnumDescriptorInternal* intern; PHP_PROTO_WRAP_OBJECT_END PHP_METHOD(EnumDescriptor, getValue); @@ -943,7 +987,8 @@ struct MessageLayout { PHP_PROTO_WRAP_OBJECT_START(MessageHeader) void* data; // Point to the real message data. // Place needs to be consistent with map_parse_frame_data_t. - Descriptor* descriptor; // Kept alive by self.class.descriptor reference. + DescriptorInternal* descriptor; // Kept alive by self.class.descriptor + // reference. PHP_PROTO_WRAP_OBJECT_END MessageLayout* create_layout(const upb_msgdef* msgdef); @@ -985,7 +1030,7 @@ PHP_METHOD(Message, __construct); const upb_pbdecodermethod *new_fillmsg_decodermethod(Descriptor *desc, const void *owner); void serialize_to_string(zval* val, zval* return_value TSRMLS_DC); -void merge_from_string(const char* data, int data_len, Descriptor* desc, +void merge_from_string(const char* data, int data_len, DescriptorInternal* desc, MessageHeader* msg); PHP_METHOD(Message, serializeToString); @@ -1491,8 +1536,11 @@ size_t stringsink_string(void *_sink, const void *hd, const char *ptr, // ----------------------------------------------------------------------------- // Memory management +#define SYS_MALLOC(class_name) (class_name*) malloc(sizeof(class_name)) +#define SYS_MALLOC_N(class_name, n) (class_name*) malloc(sizeof(class_name) * n) +#define SYS_FREE(ptr) free(ptr) #define ALLOC(class_name) (class_name*) emalloc(sizeof(class_name)) -#define PEMALLOC(class_name) (class_name*) pemalloc(sizeof(class_name), 1) +#define PEMALLOC(class_name, persistent) (class_name*) pemalloc(sizeof(class_name), persistent) #define ALLOC_N(class_name, n) (class_name*) emalloc(sizeof(class_name) * n) #define FREE(object) efree(object) #define PEFREE(object) pefree(object, 1) diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 4a8543f7b9..2521af5b2e 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -550,12 +550,11 @@ const upb_fielddef* map_entry_value(const upb_msgdef* msgdef) { const zend_class_entry* field_type_class( const upb_fielddef* field PHP_PROTO_TSRMLS_DC) { if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { - Descriptor* desc = UNBOX_HASHTABLE_VALUE( - Descriptor, get_def_obj(upb_fielddef_msgsubdef(field))); + DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field)); return desc->klass; } else if (upb_fielddef_type(field) == UPB_TYPE_ENUM) { - EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE( - EnumDescriptor, get_def_obj(upb_fielddef_enumsubdef(field))); + EnumDescriptorInternal* desc = + get_enumdef_enumdesc(upb_fielddef_enumsubdef(field)); return desc->klass; } return NULL; @@ -587,7 +586,7 @@ void* slot_memory(MessageLayout* layout, const void* storage, } MessageLayout* create_layout(const upb_msgdef* msgdef) { - MessageLayout* layout = ALLOC(MessageLayout); + MessageLayout* layout = SYS_MALLOC(MessageLayout); int nfields = upb_msgdef_numfields(msgdef); upb_msg_field_iter it; upb_msg_oneof_iter oit; @@ -600,8 +599,8 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { layout->empty_template = NULL; TSRMLS_FETCH(); - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(msgdef)); - layout->fields = ALLOC_N(MessageField, nfields); + DescriptorInternal* desc = get_msgdef_desc(msgdef); + layout->fields = SYS_MALLOC_N(MessageField, nfields); for (upb_msg_field_begin(&it, msgdef); !upb_msg_field_done(&it); upb_msg_field_next(&it)) { @@ -745,16 +744,16 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { layout->msgdef = msgdef; // Create the empty message template. - layout->empty_template = ALLOC_N(char, layout->size); + layout->empty_template = SYS_MALLOC_N(char, layout->size); memset(layout->empty_template, 0, layout->size); return layout; } void free_layout(MessageLayout* layout) { - FREE(layout->empty_template); - FREE(layout->fields); - FREE(layout); + SYS_FREE(layout->empty_template); + SYS_FREE(layout->fields); + SYS_FREE(layout); } void layout_init(MessageLayout* layout, void* storage, @@ -822,9 +821,7 @@ zval* layout_get(MessageLayout* layout, MessageHeader* header, const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field); const upb_fielddef* value_field = upb_msgdef_itof(submsgdef, 1); MessageHeader* submsg; - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE( - Descriptor, get_def_obj((void*)submsgdef)); + DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); zend_class_entry* subklass = subdesc->klass; #if PHP_MAJOR_VERSION < 7 zval* val = NULL; @@ -879,8 +876,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, if (upb_fielddef_descriptortype(valuefield) == UPB_DESCRIPTOR_TYPE_MESSAGE) { const upb_msgdef* submsg = upb_fielddef_msgsubdef(valuefield); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg)); + DescriptorInternal* subdesc = get_msgdef_desc(submsg); subce = subdesc->klass; } check_map_field(subce, upb_fielddef_descriptortype(keyfield), @@ -889,8 +885,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, } else { if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { const upb_msgdef* submsg = upb_fielddef_msgsubdef(field); - Descriptor* subdesc = - UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(submsg)); + DescriptorInternal* subdesc = get_msgdef_desc(submsg); subce = subdesc->klass; } @@ -912,7 +907,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, zend_class_entry *ce = NULL; if (type == UPB_TYPE_MESSAGE) { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(msg)); + DescriptorInternal* desc = get_msgdef_desc(msg); ce = desc->klass; } CACHED_VALUE* cache = find_zval_property(header, field); @@ -950,7 +945,7 @@ static void native_slot_merge( break; case UPB_TYPE_MESSAGE: { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(msg)); + DescriptorInternal* desc = get_msgdef_desc(msg); ce = desc->klass; if (native_slot_is_default(type, to_memory)) { #if PHP_MAJOR_VERSION < 7 @@ -996,7 +991,7 @@ static void native_slot_merge_by_array(const upb_fielddef* field, const void* fr } case UPB_TYPE_MESSAGE: { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, get_def_obj(msg)); + DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field)); zend_class_entry* ce = desc->klass; #if PHP_MAJOR_VERSION < 7 MAKE_STD_ZVAL(DEREF(to_memory, zval*)); diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c index 9ec5bdf289..e69544755b 100644 --- a/php/ext/google/protobuf/upb.c +++ b/php/ext/google/protobuf/upb.c @@ -4589,6 +4589,13 @@ const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name) : NULL; } +const upb_filedef *upb_symtab_lookupfile2( + const upb_symtab *s, const char *name, size_t len) { + upb_value v; + return upb_strtable_lookup2(&s->files, name, len, &v) ? + upb_value_getconstptr(v) : NULL; +} + const upb_filedef *upb_symtab_addfile( upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto, upb_status *status) { diff --git a/php/ext/google/protobuf/upb.h b/php/ext/google/protobuf/upb.h index 0587727416..1b0075c2a5 100644 --- a/php/ext/google/protobuf/upb.h +++ b/php/ext/google/protobuf/upb.h @@ -3760,6 +3760,8 @@ const upb_msgdef *upb_symtab_lookupmsg2( const upb_symtab *s, const char *sym, size_t len); const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym); const upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name); +const upb_filedef *upb_symtab_lookupfile2( + const upb_symtab *s, const char *name, size_t len); int upb_symtab_filecount(const upb_symtab *s); const upb_filedef *upb_symtab_addfile( upb_symtab *s, const google_protobuf_FileDescriptorProto *file, diff --git a/php/tests/test.sh b/php/tests/test.sh index be6e97fe85..9ef565c713 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -20,12 +20,22 @@ do echo "" done +for t in "${tests[@]}" +do + echo "****************************" + echo "* $t persistent" + echo "****************************" + php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so `which phpunit` --bootstrap autoload.php $t + echo "" +done + # # Make sure to run the memory test in debug mode. # php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php export ZEND_DONT_UNLOAD_MODULES=1 export USE_ZEND_ALLOC=0 valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php +valgrind --leak-check=yes php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php # TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by # regresssion test.) From 52b632cf27e0ac13a8d9b10a6bb9ecce1623f25c Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Wed, 20 Nov 2019 10:45:24 -0800 Subject: [PATCH 03/23] Update CHANGES.txt with 3.11.0-RC1 release notes (#6909) --- CHANGES.txt | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 5aaee72856..fc909c416b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,56 @@ +2019-11-19 version 3.11.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + C++ + * Make serialization method naming consistent + * Make proto runtime + generated code free of deprecation warnings + * Moved ShutdownProtobufLibrary() to message_lite.h. For backward compatibility a declaration is still available in stubs/common.h, but users should prefer message_lite.h + * Removed non-namespace macro EXPECT_OK() + * Removed mathlimits.h from stubs in favor of using std::numeric_limits from C++11 + * Fixed bug in parser when ending on a group tag + * Add a helper function to UnknownFieldSet to deal with the changing return value of message::unknown_fields() + * Fix incorrect use of string_view iterators + * Support direct pickling of nested messages + * Skip extension tag validation for MessageSet if unknown dependencies are allowed + * Updated deprecation macros to annotate deprecated code (#6612) + * Remove conversion warning in MapEntryFuncs::ByteSizeLong (#6766) + * Make shared libraries be able to link to MSVC static runtime libraries (#6780) + + Java + * Remove the usage of MethodHandle, so that Android users prior to API version 26 can use protobuf-java + * Publish ProGuard config for javalite + * Fix for StrictMode disk read violation in ExtensionRegistryLite + * Include part of the ByteString's content in its toString(). + * Include unknown fields when merging proto3 messages in Java lite builders + + Python + * Add float_precision option in json format printer + * Optionally print bytes fields as messages in unknown fields, if possible + * FieldPath: fix testing IsSet on root path '' + * Experimental code gen (fast import protobuf module) which only work with cpp generated code linked in + + JavaScript + * Remove guard for Symbol iterator for jspb.Map + + PHP + * Avoid too much overhead in layout_init (#6716) + * Lazily Create Singular Wrapper Message (#6833) + + Ruby + * Ruby lazy wrappers optimization (#6797) + + C# + * (RepeatedField): Capacity property to resize the internal array (#6530) + * Experimental proto2 support is now officially available (#4642, #5183, #5350, #5936) + * Getting started doc: https://github.com/protocolbuffers/protobuf/blob/master/docs/csharp/proto2.md + * Add length checks to ExtensionCollection (#6759) + * Optimize parsing of some primitive and wrapper types (#6843) + * Use 3 parameter Encoding.GetString for default string values (#6828) + * Change _Extensions property to normal body rather than expression (#6856) + + Objective C + * Fixed unaligned reads for 32bit arm with newer Xcode versions (#6678) + + 2019-09-03 version 3.10.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) C++ From 01425cb2620a492ad53e7e9f9da95a03c985c175 Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Wed, 20 Nov 2019 15:34:09 -0800 Subject: [PATCH 04/23] Revert "Make shared libraries be able to link to MSVC static runtime libraries, so that VC runtime is not required." (#6914) This reverts commit 129a7c875fc89309a2ab2fbbc940268bbf42b024. We are seeing the following error when building Python release artifacts in Windows: " error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in descriptor.obj". --- CHANGES.txt | 1 - cmake/CMakeLists.txt | 30 ++++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index fc909c416b..3b6da26d08 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,7 +13,6 @@ * Skip extension tag validation for MessageSet if unknown dependencies are allowed * Updated deprecation macros to annotate deprecated code (#6612) * Remove conversion warning in MapEntryFuncs::ByteSizeLong (#6766) - * Make shared libraries be able to link to MSVC static runtime libraries (#6780) Java * Remove the usage of MethodHandle, so that Android users prior to API version 26 can use protobuf-java diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 0ae5435676..8e5e68073b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -40,6 +40,8 @@ else (BUILD_SHARED_LIBS) endif (BUILD_SHARED_LIBS) option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT}) include(CMakeDependentOption) +cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON + "NOT protobuf_BUILD_SHARED_LIBS" OFF) set(protobuf_WITH_ZLIB_DEFAULT ON) option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT}) set(protobuf_DEBUG_POSTFIX "d" @@ -153,22 +155,22 @@ if (protobuf_BUILD_SHARED_LIBS) set(protobuf_SHARED_OR_STATIC "SHARED") else (protobuf_BUILD_SHARED_LIBS) set(protobuf_SHARED_OR_STATIC "STATIC") + # In case we are building static libraries, link also the runtime library statically + # so that MSVCR*.DLL is not required at runtime. + # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + # This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd + # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F + if (MSVC AND protobuf_MSVC_STATIC_RUNTIME) + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) + endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME) endif (protobuf_BUILD_SHARED_LIBS) -# In case we are linking the runtime library statically so that MSVCR*.DLL is not required at runtime. -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd -# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F -if (MSVC AND protobuf_MSVC_STATIC_RUNTIME) - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/MD") - endforeach(flag_var) -endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME) - if (MSVC) # Build with multiple processes add_definitions(/MP) From 51475bc4ea1a77df42a9eb9d53969d2be3a56dcf Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Wed, 20 Nov 2019 16:39:07 -0800 Subject: [PATCH 05/23] Marked update_compatibility_version.py as executable (#6916) --- update_compatibility_version.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 update_compatibility_version.py diff --git a/update_compatibility_version.py b/update_compatibility_version.py old mode 100644 new mode 100755 From 6220db4ec48021e69adee4926695e8b5e44d5a1d Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Thu, 21 Nov 2019 19:10:04 -0800 Subject: [PATCH 06/23] Update protobuf version (#6927) --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 20 ++++++++++++++++--- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 16 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index 63909d3c69..d2dd0f52d8 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.11.0-rc1' + s.version = '3.11.0-rc2' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index a4b3f4b5a6..60f9aae2b2 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.11.0-rc1' + s.version = '3.11.0-rc2' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index af2d980bcf..00f251422f 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.11.0-rc-1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.11.0-rc-2],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index d1a533842a..efd425f5d8 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.11.0-rc1 + 3.11.0-rc2 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 837b5658ff..b5797e7e59 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.11.0-rc1 + 3.11.0-rc2 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 59f0846b68..0c46bc79c2 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.11.0-rc-1 + 3.11.0-rc-2 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 737a9c167a..fd43c05085 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-1 + 3.11.0-rc-2 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index fc91b2c333..6b959e86f8 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-1 + 3.11.0-rc-2 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 04443859f8..fa3d51e60c 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-1 + 3.11.0-rc-2 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 082c7ddafa..37044e79c2 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-1 + 3.11.0-rc-2 protobuf-java-util diff --git a/js/package.json b/js/package.json index 2cfba39ba8..8393179a0e 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.11.0-rc.1", + "version": "3.11.0-rc.2", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index bee8b035a4..087c818636 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,10 +10,10 @@ protobuf-opensource@google.com yes - 2019-11-15 - + 2019-11-21 + - 3.11.0RC1 + 3.11.0RC2 3.11.0 @@ -445,5 +445,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.11.0RC2 + 3.11.0 + + + beta + beta + + 2019-11-21 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 1fd90f21af..c343c4f5d4 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.11.0RC1" +#define PHP_PROTOBUF_VERSION "3.11.0RC2" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index ab5209708f..b937048d97 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.11.0-rc-1 + 3.11.0-rc-2 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index f3e0a7152e..ae8ed66641 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.11.0rc1' +__version__ = '3.11.0rc2' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 1ba594d708..5a2df59d46 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.11.0.rc.1" + s.version = "3.11.0.rc.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 s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" From 391440e3dddb8de34dc7741f4b3170d8cde46215 Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Fri, 22 Nov 2019 10:06:45 -0800 Subject: [PATCH 07/23] Implement lazy loading of php class for proto messages (#6911) (#6925) * Implement lazy loading of php class for proto messages * Fix php 7.1 * Fix encode * Fix memory leak * Fix enum descriptor --- php/ext/google/protobuf/def.c | 136 +++++++++++++++++------- php/ext/google/protobuf/encode_decode.c | 20 ++-- php/ext/google/protobuf/message.c | 38 +++---- php/ext/google/protobuf/protobuf.c | 42 +++++++- php/ext/google/protobuf/protobuf.h | 15 +-- php/ext/google/protobuf/storage.c | 9 ++ 6 files changed, 181 insertions(+), 79 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 7c575c35cf..f134f4b82c 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -828,9 +828,11 @@ static void fill_segment(const char *segment, int length, static void fill_namespace(const char *package, const char *php_namespace, stringsink *classname) { if (php_namespace != NULL) { - stringsink_string(classname, NULL, php_namespace, strlen(php_namespace), - NULL); - stringsink_string(classname, NULL, "\\", 1, NULL); + if (strlen(php_namespace) != 0) { + stringsink_string(classname, NULL, php_namespace, strlen(php_namespace), + NULL); + stringsink_string(classname, NULL, "\\", 1, NULL); + } } else if (package != NULL) { int i = 0, j, offset = 0; size_t package_len = strlen(package); @@ -882,11 +884,23 @@ static void fill_classname(const char *fullname, } } -static zend_class_entry *register_class(const upb_filedef *file, - const char *fullname, - PHP_PROTO_HASHTABLE_VALUE desc_php, - bool use_nested_submsg, - bool is_enum TSRMLS_DC) { +static void fill_classname_for_desc(void *desc, bool is_enum) { + const upb_filedef *file; + const char *fullname; + bool use_nested_submsg; + + if (is_enum) { + EnumDescriptorInternal* enumdesc = desc; + file = upb_enumdef_file(enumdesc->enumdef); + fullname = upb_enumdef_fullname(enumdesc->enumdef); + use_nested_submsg = enumdesc->use_nested_submsg; + } else { + DescriptorInternal* msgdesc = desc; + file = upb_msgdef_file(msgdesc->msgdef); + fullname = upb_msgdef_fullname(msgdesc->msgdef); + use_nested_submsg = msgdesc->use_nested_submsg; + } + // Prepend '.' to package name to make it absolute. In the 5 additional // bytes allocated, one for '.', one for trailing 0, and 3 for 'GPB' if // given message is google.protobuf.Empty. @@ -896,7 +910,6 @@ static zend_class_entry *register_class(const upb_filedef *file, size_t classname_len = classname_len_max(fullname, package, php_namespace, prefix); char* after_package; - zend_class_entry* ret; stringsink namesink; stringsink_init(&namesink); @@ -904,28 +917,68 @@ static zend_class_entry *register_class(const upb_filedef *file, fill_classname(fullname, package, prefix, &namesink, use_nested_submsg); stringsink_string(&namesink, NULL, "\0", 1, NULL); + if (is_enum) { + EnumDescriptorInternal* enumdesc = desc; + enumdesc->classname = strdup(namesink.ptr); + } else { + DescriptorInternal* msgdesc = desc; + msgdesc->classname = strdup(namesink.ptr); + } + + stringsink_uninit(&namesink); +} + +void register_class(void *desc, bool is_enum TSRMLS_DC) { + const char *classname; + const char *fullname; + zend_class_entry* ret; + + if (is_enum) { + EnumDescriptorInternal* enumdesc = desc; + if (enumdesc->klass) { + return; + } + classname = enumdesc->classname; + fullname = upb_enumdef_fullname(enumdesc->enumdef); + } else { + DescriptorInternal* msgdesc = desc; + if (msgdesc->klass) { + return; + } + if (!msgdesc->classname) { + return; + } + classname = msgdesc->classname; + fullname = upb_msgdef_fullname(msgdesc->msgdef); + } + PHP_PROTO_CE_DECLARE pce; - if (php_proto_zend_lookup_class(namesink.ptr, namesink.len - 1, &pce) == + if (php_proto_zend_lookup_class(classname, strlen(classname), &pce) == FAILURE) { zend_error( E_ERROR, - "Generated message class %s hasn't been defined (%s, %s, %s, %s)", - namesink.ptr, fullname, package, php_namespace, prefix); - return NULL; + "Generated message class %s hasn't been defined (%s)", + classname); + return; } ret = PHP_PROTO_CE_UNREF(pce); - add_ce_obj(ret, desc_php); if (is_enum) { - EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(EnumDescriptor, desc_php); - add_ce_enumdesc(ret, desc->intern); - add_proto_enumdesc(fullname, desc->intern); + EnumDescriptorInternal* enumdesc = desc; + add_ce_enumdesc(ret, desc); + add_proto_enumdesc(fullname, desc); + enumdesc->klass = ret; } else { - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, desc_php); - add_ce_desc(ret, desc->intern); - add_proto_desc(fullname, desc->intern); + DescriptorInternal* msgdesc = desc; + add_ce_desc(ret, desc); + msgdesc->klass = ret; + // Map entries don't have existing php class. + if (!upb_msgdef_mapentry(msgdesc->msgdef)) { + if (msgdesc->layout == NULL) { + MessageLayout* layout = create_layout(msgdesc->msgdef); + msgdesc->layout = layout; + } + } } - stringsink_uninit(&namesink); - return ret; } bool depends_on_descriptor(const google_protobuf_FileDescriptorProto* file) { @@ -1019,6 +1072,8 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, desc->intern->pool = pool; desc->intern->layout = NULL; desc->intern->klass = NULL; + desc->intern->use_nested_submsg = use_nested_submsg; + desc->intern->classname = NULL; add_def_obj(desc->intern->msgdef, desc_php); add_msgdef_desc(desc->intern->msgdef, desc->intern); @@ -1029,15 +1084,9 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, continue; } - desc->intern->klass = - register_class(file, upb_msgdef_fullname(msgdef), desc_php, - use_nested_submsg, false TSRMLS_CC); - - if (desc->intern->klass == NULL) { - return; - } - - build_class_from_descriptor(desc_php TSRMLS_CC); + fill_classname_for_desc(desc->intern, false); + add_class_desc(desc->intern->classname, desc->intern); + add_proto_desc(upb_msgdef_fullname(desc->intern->msgdef), desc->intern); } for (i = 0; i < upb_filedef_enumcount(file); i++) { @@ -1046,16 +1095,13 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, desc->intern = SYS_MALLOC(EnumDescriptorInternal); desc->intern->enumdef = enumdef; desc->intern->klass = NULL; + desc->intern->use_nested_submsg = use_nested_submsg; + desc->intern->classname = NULL; add_def_obj(desc->intern->enumdef, desc_php); add_enumdef_enumdesc(desc->intern->enumdef, desc->intern); - desc->intern->klass = - register_class(file, upb_enumdef_fullname(enumdef), desc_php, - use_nested_submsg, true TSRMLS_CC); - - if (desc->intern->klass == NULL) { - return; - } + fill_classname_for_desc(desc->intern, true); + add_class_enumdesc(desc->intern->classname, desc->intern); } } @@ -1144,9 +1190,17 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) { RETURN_NULL(); } - PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(PHP_PROTO_CE_UNREF(pce)); + zend_class_entry* ce = PHP_PROTO_CE_UNREF(pce); + + PHP_PROTO_HASHTABLE_VALUE desc_php = get_ce_obj(ce); if (desc_php == NULL) { - EnumDescriptorInternal* intern = get_ce_enumdesc(PHP_PROTO_CE_UNREF(pce)); +#if PHP_MAJOR_VERSION < 7 + EnumDescriptorInternal* intern = get_class_enumdesc(ce->name); +#else + EnumDescriptorInternal* intern = get_class_enumdesc(ZSTR_VAL(ce->name)); +#endif + register_class(intern, true TSRMLS_CC); + if (intern == NULL) { RETURN_NULL(); } @@ -1164,7 +1218,7 @@ PHP_METHOD(DescriptorPool, getEnumDescriptorByClassName) { EnumDescriptor* desc = UNBOX_HASHTABLE_VALUE(EnumDescriptor, desc_php); desc->intern = intern; add_def_obj(intern->enumdef, desc_php); - add_ce_obj(PHP_PROTO_CE_UNREF(pce), desc_php); + add_ce_obj(ce, desc_php); } zend_class_entry* instance_ce = HASHTABLE_VALUE_CE(desc_php); diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 14808eb1ae..e4b3566b52 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -429,6 +429,7 @@ static void *appendsubmsg_handler(void *closure, const void *hd) { const submsg_handlerdata_t *submsgdata = hd; DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; @@ -456,6 +457,7 @@ static void *appendwrappersubmsg_handler(void *closure, const void *hd) { const submsg_handlerdata_t *submsgdata = hd; DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; wrapperfields_parseframe_t* frame = @@ -487,6 +489,7 @@ static void *submsg_handler(void *closure, const void *hd) { const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -520,6 +523,7 @@ static void *map_submsg_handler(void *closure, const void *hd) { const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -554,6 +558,7 @@ static void *map_wrapper_submsg_handler(void *closure, const void *hd) { const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -641,6 +646,7 @@ static void map_slot_init( } case UPB_TYPE_MESSAGE: { DescriptorInternal* subdesc = get_msgdef_desc(value_msg); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; MessageHeader* submsg; #if PHP_MAJOR_VERSION < 7 @@ -938,6 +944,7 @@ static void* oneofsubmsg_handler(void* closure, const void* hd) { uint32_t oldcase = DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -976,6 +983,7 @@ static void* wrapper_submsg_handler(void* closure, const void* hd) { const submsg_handlerdata_t* submsgdata = hd; TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; @@ -1007,6 +1015,7 @@ static void* wrapper_oneofsubmsg_handler(void* closure, const void* hd) { uint32_t oldcase = DEREF(message_data(msg), oneofdata->case_ofs, uint32_t); TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; wrapperfields_parseframe_t* frame = (wrapperfields_parseframe_t*)malloc(sizeof(wrapperfields_parseframe_t)); @@ -1347,6 +1356,7 @@ void add_handlers_for_message(const void* closure, upb_handlers* h) { const upb_msgdef* msgdef = upb_handlers_msgdef(h); TSRMLS_FETCH(); DescriptorInternal* desc = get_msgdef_desc(msgdef); + register_class(desc, false TSRMLS_CC); upb_msg_field_iter i; // If this is a mapentry message type, set up a special set of handlers and @@ -1356,15 +1366,6 @@ void add_handlers_for_message(const void* closure, upb_handlers* h) { return; } - // Ensure layout exists. We may be invoked to create handlers for a given - // message if we are included as a submsg of another message type before our - // class is actually built, so to work around this, we just create the layout - // (and handlers, in the class-building function) on-demand. - if (desc->layout == NULL) { - desc->layout = create_layout(desc->msgdef); - } - - // If this is a wrapper message type, set up a special set of handlers and // bail out of the normal (user-defined) message type handling. if (is_wrapper_msg(msgdef)) { @@ -1635,6 +1636,7 @@ static void putjsonany(MessageHeader* msg, const DescriptorInternal* desc, if (value_len > 0) { DescriptorInternal* payload_desc = get_msgdef_desc(payload_type); + register_class(payload_desc, false TSRMLS_CC); zend_class_entry* payload_klass = payload_desc->klass; zval val; upb_sink subsink; diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index e80ec4ec37..9adf3b0179 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -274,25 +274,6 @@ void custom_data_init(const zend_class_entry* ce, Message_construct(getThis(), array_wrapper); \ } -void build_class_from_descriptor( - PHP_PROTO_HASHTABLE_VALUE php_descriptor TSRMLS_DC) { - Descriptor* desc = UNBOX_HASHTABLE_VALUE(Descriptor, php_descriptor); - - // Map entries don't have existing php class. - if (upb_msgdef_mapentry(desc->intern->msgdef)) { - return; - } - - zend_class_entry* registered_ce = desc->intern->klass; - - if (desc->intern->layout == NULL) { - MessageLayout* layout = create_layout(desc->intern->msgdef); - desc->intern->layout = layout; - } - - registered_ce->create_object = message_create; -} - // ----------------------------------------------------------------------------- // PHP Methods // ----------------------------------------------------------------------------- @@ -346,11 +327,19 @@ void Message_construct(zval* msg, zval* array_wrapper) { TSRMLS_FETCH(); zend_class_entry* ce = Z_OBJCE_P(msg); MessageHeader* intern = NULL; - if (EXPECTED(class_added(ce))) { - intern = UNBOX(MessageHeader, msg); - custom_data_init(ce, intern PHP_PROTO_TSRMLS_CC); + + if (!class_added(ce)) { +#if PHP_MAJOR_VERSION < 7 + DescriptorInternal* desc = get_class_desc(ce->name); +#else + DescriptorInternal* desc = get_class_desc(ZSTR_VAL(ce->name)); +#endif + register_class(desc, false TSRMLS_CC); } + intern = UNBOX(MessageHeader, msg); + custom_data_init(ce, intern PHP_PROTO_TSRMLS_CC); + if (array_wrapper == NULL) { return; } @@ -396,6 +385,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { if (is_wrapper) { DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); + register_class(subdesc, false TSRMLS_CC); subklass = subdesc->klass; } } @@ -435,6 +425,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { if (is_wrapper) { DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); + register_class(subdesc, false TSRMLS_CC); subklass = subdesc->klass; } } @@ -458,6 +449,7 @@ void Message_construct(zval* msg, zval* array_wrapper) { } else if (upb_fielddef_issubmsg(field)) { const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field); DescriptorInternal* desc = get_msgdef_desc(submsgdef); + register_class(desc, false TSRMLS_CC); CACHED_VALUE* cached = NULL; if (upb_fielddef_containingoneof(field)) { @@ -528,6 +520,7 @@ PHP_METHOD(Message, __construct) { PHP_METHOD(Message, clear) { MessageHeader* msg = UNBOX(MessageHeader, getThis()); DescriptorInternal* desc = msg->descriptor; + register_class(desc, false TSRMLS_CC); zend_class_entry* ce = desc->klass; zend_object_std_dtor(&msg->std TSRMLS_CC); @@ -1540,6 +1533,7 @@ PHP_METHOD(Any, unpack) { 0 TSRMLS_CC); return; } + register_class(desc, false TSRMLS_CC); zend_class_entry* klass = desc->klass; ZVAL_OBJ(return_value, klass->create_object(klass TSRMLS_CC)); MessageHeader* msg = UNBOX(MessageHeader, return_value); diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index fd97c89bd7..3ceba7b856 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -53,6 +53,7 @@ static upb_inttable ce_to_enumdesc_map_persistent; // wrapper Descriptor/EnumDescriptor instances. static upb_strtable proto_to_desc_map_persistent; static upb_strtable proto_to_enumdesc_map_persistent; +static upb_strtable class_to_desc_map_persistent; upb_strtable reserved_names; @@ -194,7 +195,7 @@ EnumDescriptorInternal* get_ce_enumdesc(const zend_class_entry* ce) { } bool class_added(const void* ce) { - return exist_in_table(ce_to_php_obj_map, ce); + return get_ce_desc(ce) != NULL; } void add_proto_desc(const char* proto, DescriptorInternal* desc) { @@ -232,6 +233,40 @@ EnumDescriptorInternal* get_proto_enumdesc(const char* proto) { } } +void add_class_desc(const char* klass, DescriptorInternal* desc) { + upb_strtable_insert(&class_to_desc_map_persistent, klass, + upb_value_ptr(desc)); +} + +DescriptorInternal* get_class_desc(const char* klass) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_strtable_lookup(&class_to_desc_map_persistent, klass, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + +void add_class_enumdesc(const char* klass, EnumDescriptorInternal* desc) { + upb_strtable_insert(&class_to_desc_map_persistent, klass, + upb_value_ptr(desc)); +} + +EnumDescriptorInternal* get_class_enumdesc(const char* klass) { + upb_value v; +#ifndef NDEBUG + v.ctype = UPB_CTYPE_PTR; +#endif + if (!upb_strtable_lookup(&class_to_desc_map_persistent, klass, &v)) { + return NULL; + } else { + return upb_value_getptr(v); + } +} + // ----------------------------------------------------------------------------- // Well Known Types. // ----------------------------------------------------------------------------- @@ -344,6 +379,7 @@ static initialize_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_init(&ce_to_enumdesc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&proto_to_desc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&proto_to_enumdesc_map_persistent, UPB_CTYPE_PTR); + upb_strtable_init(&class_to_desc_map_persistent, UPB_CTYPE_PTR); internal_descriptor_pool_impl_init(&generated_pool_impl TSRMLS_CC); @@ -388,7 +424,9 @@ static void cleanup_desc_table(upb_inttable* t) { desc = upb_value_getptr(v); if (desc->layout) { free_layout(desc->layout); + desc->layout = NULL; } + free(desc->classname); SYS_FREE(desc); } } @@ -402,6 +440,7 @@ static void cleanup_enumdesc_table(upb_inttable* t) { upb_inttable_next(&i)) { v = upb_inttable_iter_value(&i); desc = upb_value_getptr(v); + free(desc->classname); SYS_FREE(desc); } } @@ -421,6 +460,7 @@ static cleanup_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_uninit(&ce_to_enumdesc_map_persistent); upb_strtable_uninit(&proto_to_desc_map_persistent); upb_strtable_uninit(&proto_to_enumdesc_map_persistent); + upb_strtable_uninit(&class_to_desc_map_persistent); } static PHP_RSHUTDOWN_FUNCTION(protobuf) { diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index c343c4f5d4..c497d38b8f 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -779,6 +779,10 @@ void add_proto_desc(const char* proto, DescriptorInternal* desc); DescriptorInternal* get_proto_desc(const char* proto); void add_proto_enumdesc(const char* proto, EnumDescriptorInternal* desc); EnumDescriptorInternal* get_proto_enumdesc(const char* proto); +void add_class_desc(const char* klass, DescriptorInternal* desc); +DescriptorInternal* get_class_desc(const char* klass); +void add_class_enumdesc(const char* klass, EnumDescriptorInternal* desc); +EnumDescriptorInternal* get_class_enumdesc(const char* klass); extern zend_class_entry* map_field_type; extern zend_class_entry* repeated_field_type; @@ -817,6 +821,7 @@ void internal_add_generated_file(const char* data, PHP_PROTO_SIZE data_len, bool use_nested_submsg TSRMLS_DC); void init_generated_pool_once(TSRMLS_D); void add_handlers_for_message(const void* closure, upb_handlers* h); +void register_class(void *desc, bool is_enum TSRMLS_DC); // wrapper of generated pool #if PHP_MAJOR_VERSION < 7 @@ -844,6 +849,8 @@ struct DescriptorInternal { const upb_msgdef* msgdef; MessageLayout* layout; zend_class_entry* klass; // begins as NULL + bool use_nested_submsg; + char* classname; }; PHP_PROTO_WRAP_OBJECT_START(Descriptor) @@ -878,6 +885,8 @@ extern zend_class_entry* field_descriptor_type; struct EnumDescriptorInternal { const upb_enumdef* enumdef; zend_class_entry* klass; // begins as NULL + bool use_nested_submsg; + char* classname; }; PHP_PROTO_WRAP_OBJECT_START(EnumDescriptor) @@ -907,12 +916,6 @@ void* message_data(MessageHeader* msg); void custom_data_init(const zend_class_entry* ce, MessageHeader* msg PHP_PROTO_TSRMLS_DC); -// Build PHP class for given descriptor. Instead of building from scratch, this -// function modifies existing class which has been partially defined in PHP -// code. -void build_class_from_descriptor( - PHP_PROTO_HASHTABLE_VALUE php_descriptor TSRMLS_DC); - extern zend_class_entry* message_type; extern zend_object_handlers* message_handlers; diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 2521af5b2e..235c5df8a8 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -551,10 +551,12 @@ const zend_class_entry* field_type_class( const upb_fielddef* field PHP_PROTO_TSRMLS_DC) { if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field)); + register_class(desc, false TSRMLS_CC); return desc->klass; } else if (upb_fielddef_type(field) == UPB_TYPE_ENUM) { EnumDescriptorInternal* desc = get_enumdef_enumdesc(upb_fielddef_enumsubdef(field)); + register_class(desc, false TSRMLS_CC); return desc->klass; } return NULL; @@ -600,6 +602,7 @@ MessageLayout* create_layout(const upb_msgdef* msgdef) { TSRMLS_FETCH(); DescriptorInternal* desc = get_msgdef_desc(msgdef); + register_class(desc, false TSRMLS_CC); layout->fields = SYS_MALLOC_N(MessageField, nfields); for (upb_msg_field_begin(&it, msgdef); !upb_msg_field_done(&it); @@ -822,6 +825,7 @@ zval* layout_get(MessageLayout* layout, MessageHeader* header, const upb_fielddef* value_field = upb_msgdef_itof(submsgdef, 1); MessageHeader* submsg; DescriptorInternal* subdesc = get_msgdef_desc(submsgdef); + register_class(subdesc, false TSRMLS_CC); zend_class_entry* subklass = subdesc->klass; #if PHP_MAJOR_VERSION < 7 zval* val = NULL; @@ -877,6 +881,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, UPB_DESCRIPTOR_TYPE_MESSAGE) { const upb_msgdef* submsg = upb_fielddef_msgsubdef(valuefield); DescriptorInternal* subdesc = get_msgdef_desc(submsg); + register_class(subdesc, false TSRMLS_CC); subce = subdesc->klass; } check_map_field(subce, upb_fielddef_descriptortype(keyfield), @@ -886,6 +891,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, if (upb_fielddef_type(field) == UPB_TYPE_MESSAGE) { const upb_msgdef* submsg = upb_fielddef_msgsubdef(field); DescriptorInternal* subdesc = get_msgdef_desc(submsg); + register_class(subdesc, false TSRMLS_CC); subce = subdesc->klass; } @@ -908,6 +914,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header, if (type == UPB_TYPE_MESSAGE) { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); DescriptorInternal* desc = get_msgdef_desc(msg); + register_class(desc, false TSRMLS_CC); ce = desc->klass; } CACHED_VALUE* cache = find_zval_property(header, field); @@ -946,6 +953,7 @@ static void native_slot_merge( case UPB_TYPE_MESSAGE: { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); DescriptorInternal* desc = get_msgdef_desc(msg); + register_class(desc, false TSRMLS_CC); ce = desc->klass; if (native_slot_is_default(type, to_memory)) { #if PHP_MAJOR_VERSION < 7 @@ -992,6 +1000,7 @@ static void native_slot_merge_by_array(const upb_fielddef* field, const void* fr case UPB_TYPE_MESSAGE: { const upb_msgdef* msg = upb_fielddef_msgsubdef(field); DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field)); + register_class(desc, false TSRMLS_CC); zend_class_entry* ce = desc->klass; #if PHP_MAJOR_VERSION < 7 MAKE_STD_ZVAL(DEREF(to_memory, zval*)); From b0386daa1968c3c7ace339fca10b73a3998071d3 Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Fri, 22 Nov 2019 11:40:56 -0800 Subject: [PATCH 08/23] Remove add_proto_enumdesc and get_proto_enumdesc (#6931) --- php/ext/google/protobuf/def.c | 1 - php/ext/google/protobuf/protobuf.c | 21 --------------------- php/ext/google/protobuf/protobuf.h | 2 -- 3 files changed, 24 deletions(-) diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index f134f4b82c..7a23105e9a 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -965,7 +965,6 @@ void register_class(void *desc, bool is_enum TSRMLS_DC) { if (is_enum) { EnumDescriptorInternal* enumdesc = desc; add_ce_enumdesc(ret, desc); - add_proto_enumdesc(fullname, desc); enumdesc->klass = ret; } else { DescriptorInternal* msgdesc = desc; diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 3ceba7b856..c635189d4c 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -52,7 +52,6 @@ static upb_inttable ce_to_enumdesc_map_persistent; // Global map from message/enum's proto fully-qualified name to corresponding // wrapper Descriptor/EnumDescriptor instances. static upb_strtable proto_to_desc_map_persistent; -static upb_strtable proto_to_enumdesc_map_persistent; static upb_strtable class_to_desc_map_persistent; upb_strtable reserved_names; @@ -215,24 +214,6 @@ DescriptorInternal* get_proto_desc(const char* proto) { } } -void add_proto_enumdesc(const char* proto, EnumDescriptorInternal* desc) { - upb_strtable_insert2(&proto_to_enumdesc_map_persistent, proto, - strlen(proto), upb_value_ptr(desc)); -} - -EnumDescriptorInternal* get_proto_enumdesc(const char* proto) { - upb_value v; -#ifndef NDEBUG - v.ctype = UPB_CTYPE_PTR; -#endif - if (!upb_strtable_lookupptr(&proto_to_enumdesc_map_persistent, - proto, strlen(proto), &v)) { - return NULL; - } else { - return upb_value_getptr(v); - } -} - void add_class_desc(const char* klass, DescriptorInternal* desc) { upb_strtable_insert(&class_to_desc_map_persistent, klass, upb_value_ptr(desc)); @@ -378,7 +359,6 @@ static initialize_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR); upb_inttable_init(&ce_to_enumdesc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&proto_to_desc_map_persistent, UPB_CTYPE_PTR); - upb_strtable_init(&proto_to_enumdesc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&class_to_desc_map_persistent, UPB_CTYPE_PTR); internal_descriptor_pool_impl_init(&generated_pool_impl TSRMLS_CC); @@ -459,7 +439,6 @@ static cleanup_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_uninit(&ce_to_desc_map_persistent); upb_inttable_uninit(&ce_to_enumdesc_map_persistent); upb_strtable_uninit(&proto_to_desc_map_persistent); - upb_strtable_uninit(&proto_to_enumdesc_map_persistent); upb_strtable_uninit(&class_to_desc_map_persistent); } diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index c497d38b8f..3ff126b2e0 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -777,8 +777,6 @@ EnumDescriptorInternal* get_ce_enumdesc(const zend_class_entry* ce); // wrapper Descriptor/EnumDescriptor instances. void add_proto_desc(const char* proto, DescriptorInternal* desc); DescriptorInternal* get_proto_desc(const char* proto); -void add_proto_enumdesc(const char* proto, EnumDescriptorInternal* desc); -EnumDescriptorInternal* get_proto_enumdesc(const char* proto); void add_class_desc(const char* klass, DescriptorInternal* desc); DescriptorInternal* get_class_desc(const char* klass); void add_class_enumdesc(const char* klass, EnumDescriptorInternal* desc); From 1d5375c6214384574eca20f24f660b7a9687f51c Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Mon, 25 Nov 2019 15:12:00 -0800 Subject: [PATCH 09/23] Update protobuf version to 3.11.0 (#6943) --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 24 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- 16 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index d2dd0f52d8..a6b0e3b000 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.11.0-rc2' + s.version = '3.11.0' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index 60f9aae2b2..bccc745acc 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.11.0-rc2' + s.version = '3.11.0' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 00f251422f..37cc74745d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.11.0-rc-2],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.11.0],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index efd425f5d8..bfe7ac3fa6 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.11.0-rc2 + 3.11.0 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index b5797e7e59..3081855a24 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.11.0-rc2 + 3.11.0 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 0c46bc79c2..a7be832966 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.11.0-rc-2 + 3.11.0 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index fd43c05085..52020c1bde 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-2 + 3.11.0 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 6b959e86f8..829f5adbdb 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-2 + 3.11.0 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index fa3d51e60c..d2f5724885 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-2 + 3.11.0 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 37044e79c2..228f8a27fc 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0-rc-2 + 3.11.0 protobuf-java-util diff --git a/js/package.json b/js/package.json index 8393179a0e..48f328ec3d 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.11.0-rc.2", + "version": "3.11.0", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 087c818636..26f4365bcc 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,15 +10,15 @@ protobuf-opensource@google.com yes - 2019-11-21 - + 2019-11-25 + - 3.11.0RC2 + 3.11.0 3.11.0 - beta - beta + stable + stable 3-Clause BSD License GA release. @@ -459,5 +459,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.11.0 + 3.11.0 + + + stable + stable + + 2019-11-25 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 3ff126b2e0..390e7368b4 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.11.0RC2" +#define PHP_PROTOBUF_VERSION "3.11.0" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index b937048d97..0ef2f407e6 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.11.0-rc-2 + 3.11.0 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index ae8ed66641..c6e567ad55 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.11.0rc2' +__version__ = '3.11.0' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 5a2df59d46..875bbeb180 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.11.0.rc.2" + s.version = "3.11.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" From ab5b61bf2f0fb1ac485be1b82fffca153c2509ed Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Mon, 25 Nov 2019 15:15:21 -0800 Subject: [PATCH 10/23] Update CHANGES.txt for 3.11.0 stable release (#6944) --- CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 3b6da26d08..4b2d4fdfac 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,7 @@ * Skip extension tag validation for MessageSet if unknown dependencies are allowed * Updated deprecation macros to annotate deprecated code (#6612) * Remove conversion warning in MapEntryFuncs::ByteSizeLong (#6766) + * Revert "Make shared libraries be able to link to MSVC static runtime libraries, so that VC runtime is not required." (#6914) Java * Remove the usage of MethodHandle, so that Android users prior to API version 26 can use protobuf-java @@ -33,6 +34,7 @@ PHP * Avoid too much overhead in layout_init (#6716) * Lazily Create Singular Wrapper Message (#6833) + * Implement lazy loading of php class for proto messages (#6911) Ruby * Ruby lazy wrappers optimization (#6797) From e69c939652b819631dea1070266258dbc70f9497 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 27 Nov 2019 01:00:51 -0800 Subject: [PATCH 11/23] Extern declare protobuf_globals (#6946) --- php/ext/google/protobuf/protobuf.c | 2 ++ php/ext/google/protobuf/protobuf.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index c635189d4c..52cdac8e2d 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -39,6 +39,8 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf); static PHP_MINIT_FUNCTION(protobuf); static PHP_MSHUTDOWN_FUNCTION(protobuf); +ZEND_DECLARE_MODULE_GLOBALS(protobuf) + // Global map from upb {msg,enum}defs to wrapper Descriptor/EnumDescriptor // instances. static HashTable* upb_def_to_php_obj_map; diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 390e7368b4..059ee55fa1 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -689,7 +689,7 @@ ZEND_BEGIN_MODULE_GLOBALS(protobuf) zend_bool keep_descriptor_pool_after_request; ZEND_END_MODULE_GLOBALS(protobuf) -ZEND_DECLARE_MODULE_GLOBALS(protobuf) +ZEND_EXTERN_MODULE_GLOBALS(protobuf) #ifdef ZTS #define PROTOBUF_G(v) TSRMG(protobuf_globals_id, zend_protobuf_globals *, v) From b78c53f935d5ac7c32a6fa469199dcbc51c8622a Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Mon, 2 Dec 2019 11:57:21 -0800 Subject: [PATCH 12/23] Update protobuf version to 3.11.1 (#6972) --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 22 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 48 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index a6b0e3b000..b10a48e41c 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.11.0' + s.version = '3.11.1' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index bccc745acc..36cb6bbe28 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.11.0' + s.version = '3.11.1' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 37cc74745d..85fb2280bd 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.11.0],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.11.1],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index bfe7ac3fa6..8cf70b260d 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.11.0 + 3.11.1 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index 3081855a24..b90e4e378a 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.11.0 + 3.11.1 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index a7be832966..78e36d50a9 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.11.0 + 3.11.1 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index 52020c1bde..f87039475e 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0 + 3.11.1 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 829f5adbdb..187580ed44 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0 + 3.11.1 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index d2f5724885..0d9f7c1ec7 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0 + 3.11.1 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 228f8a27fc..1f34625375 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.0 + 3.11.1 protobuf-java-util diff --git a/js/package.json b/js/package.json index 48f328ec3d..7ac806191d 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.11.0", + "version": "3.11.1", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index 26f4365bcc..b26860eb8e 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2019-11-25 - + 2019-12-02 + - 3.11.0 - 3.11.0 + 3.11.1 + 3.11.1 stable @@ -473,5 +473,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.11.1 + 3.11.1 + + + stable + stable + + 2019-12-02 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 059ee55fa1..6417b94a0f 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.11.0" +#define PHP_PROTOBUF_VERSION "3.11.1" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 0ef2f407e6..061c82b345 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.11.0 + 3.11.1 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index c6e567ad55..41eec7f3e8 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.11.0' +__version__ = '3.11.1' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index 875bbeb180..a621316007 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.11.0" + s.version = "3.11.1" 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" diff --git a/src/Makefile.am b/src/Makefile.am index 60bb445d9b..a8452e8df9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 22:0:0 +PROTOBUF_VERSION = 22:1:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 7ea175d4df..63fedf5928 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index 91bc34e2b4..af46e87f90 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 2dee810eca..a698b9f8f4 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 20912ff70d..3b473a1c55 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index 804361d37d..f12a1e9a8b 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 71d3d2029f..11923f52f3 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index cce1e1b80c..9a6f3a2141 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index a497f77ecd..555a2e7601 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -297,7 +297,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3011000 +#define PROTOBUF_VERSION 3011001 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3011000 #define PROTOBUF_MIN_PROTOC_VERSION 3011000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index 8a49008c93..c2e8de2400 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index 05a5f74453..d0f2e4fc72 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 2ee72f5ea8..c8c82a79f8 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -81,7 +81,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 3011000 +#define GOOGLE_PROTOBUF_VERSION 3011001 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index 497db63c7b..c3988996b1 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 679e132502..04af165f59 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 4ee66db9ae..5d04309d52 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011000 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011001 < 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. From c04d9c984fc2018e9a9979b24f18cc57ec200396 Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Mon, 2 Dec 2019 11:57:40 -0800 Subject: [PATCH 13/23] Update CHANGES.txt for 3.11.1 release (#6973) --- CHANGES.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 4b2d4fdfac..f4861dd2c5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +2019-12-02 version 3.11.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + PHP + * Extern declare protobuf_globals (#6946) + + 2019-11-19 version 3.11.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) C++ From 7bb8b108d16252d0ed053673d70ea6d2020ec7ff Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 2 Dec 2019 16:05:55 -0800 Subject: [PATCH 14/23] Add php 7.4 to docker image (#6971) (#6975) * Add php 7.4 to docker image * Use https links --- kokoro/linux/dockerfile/test/php/Dockerfile | 45 +++++++++++++++++++ .../dockerfile/test/php_32bit/Dockerfile | 45 ++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/kokoro/linux/dockerfile/test/php/Dockerfile b/kokoro/linux/dockerfile/test/php/Dockerfile index 276cb73a41..a540177c06 100644 --- a/kokoro/linux/dockerfile/test/php/Dockerfile +++ b/kokoro/linux/dockerfile/test/php/Dockerfile @@ -20,6 +20,9 @@ RUN apt-get update && apt-get install -y \ parallel \ time \ wget \ + re2c \ + sqlite3 \ + libsqlite3-dev \ && apt-get clean # Install php dependencies @@ -232,6 +235,48 @@ RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \ && cp phpunit /usr/local/php-7.3/bin \ && mv phpunit /usr/local/php-7.3-zts/bin +# php 7.4 +RUN wget https://ftp.gnu.org/gnu/bison/bison-3.0.1.tar.gz -O /var/local/bison-3.0.1.tar.gz +RUN cd /var/local \ + && tar -zxvf bison-3.0.1.tar.gz \ + && cd /var/local/bison-3.0.1 \ + && ./configure \ + && make \ + && make install + +RUN wget https://github.com/php/php-src/archive/php-7.4.0.tar.gz -O /var/local/php-7.4.0.tar.gz + +RUN cd /var/local \ + && tar -zxvf php-7.4.0.tar.gz + +RUN cd /var/local/php-src-php-7.4.0 \ + && ./buildconf --force \ + && ./configure \ + --enable-bcmath \ + --with-gmp \ + --with-openssl \ + --with-zlib \ + --prefix=/usr/local/php-7.4 \ + && make \ + && make install \ + && make clean +RUN cd /var/local/php-src-php-7.4.0 \ + && ./buildconf --force \ + && ./configure \ + --enable-maintainer-zts \ + --with-gmp \ + --with-openssl \ + --with-zlib \ + --prefix=/usr/local/php-7.4-zts \ + && make \ + && make install \ + && make clean + +RUN wget -O phpunit https://phar.phpunit.de/phpunit-8.phar \ + && chmod +x phpunit \ + && cp phpunit /usr/local/php-7.4/bin \ + && mv phpunit /usr/local/php-7.4-zts/bin + # Install php dependencies RUN apt-get clean && apt-get update && apt-get install -y --force-yes \ valgrind \ diff --git a/kokoro/linux/dockerfile/test/php_32bit/Dockerfile b/kokoro/linux/dockerfile/test/php_32bit/Dockerfile index f8027c48e7..b40cb70032 100644 --- a/kokoro/linux/dockerfile/test/php_32bit/Dockerfile +++ b/kokoro/linux/dockerfile/test/php_32bit/Dockerfile @@ -1,4 +1,4 @@ -FROM 32bit/debian:jessie +FROM i386/debian:jessie # Install dependencies. We start with the basic ones require to build protoc # and the C++ build @@ -20,6 +20,9 @@ RUN apt-get update && apt-get install -y \ parallel \ time \ wget \ + re2c \ + sqlite3 \ + libsqlite3-dev \ && apt-get clean # Install php dependencies @@ -218,6 +221,46 @@ RUN wget -O phpunit https://phar.phpunit.de/phpunit-7.phar \ && cp phpunit /usr/local/php-7.3/bin \ && mv phpunit /usr/local/php-7.3-zts/bin +# php 7.4 +RUN wget https://ftp.gnu.org/gnu/bison/bison-3.0.1.tar.gz -O /var/local/bison-3.0.1.tar.gz +RUN cd /var/local \ + && tar -zxvf bison-3.0.1.tar.gz \ + && cd /var/local/bison-3.0.1 \ + && ./configure \ + && make \ + && make install + +RUN wget https://github.com/php/php-src/archive/php-7.4.0.tar.gz -O /var/local/php-7.4.0.tar.gz + +RUN cd /var/local \ + && tar -zxvf php-7.4.0.tar.gz + +RUN cd /var/local/php-src-php-7.4.0 \ + && ./buildconf --force \ + && ./configure \ + --enable-bcmath \ + --with-openssl \ + --with-zlib \ + --prefix=/usr/local/php-7.4 \ + && make \ + && make install \ + && make clean +RUN cd /var/local/php-src-php-7.4.0 \ + && ./buildconf --force \ + && ./configure \ + --enable-maintainer-zts \ + --with-openssl \ + --with-zlib \ + --prefix=/usr/local/php-7.4-zts \ + && make \ + && make install \ + && make clean + +RUN wget -O phpunit https://phar.phpunit.de/phpunit-8.phar \ + && chmod +x phpunit \ + && cp phpunit /usr/local/php-7.4/bin \ + && mv phpunit /usr/local/php-7.4-zts/bin + # Install php dependencies RUN apt-get clean && apt-get update && apt-get install -y --force-yes \ valgrind \ From 2929bb373602801424f389b8a97e8199922943a4 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 3 Dec 2019 11:11:28 -0800 Subject: [PATCH 15/23] Initialize wrapper message during parsing (#6974) * Initialize wrapper message during parsing In case the internal value is default * Fix zts build --- php/ext/google/protobuf/encode_decode.c | 12 ++++++++++++ php/tests/encode_decode_test.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index e4b3566b52..17233275b8 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -999,6 +999,12 @@ static void* wrapper_submsg_handler(void* closure, const void* hd) { frame->submsg = submsg; frame->is_msg = true; } else { + if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(cached)) == IS_NULL) { + // Needs to initiate the wrapper message + const upb_msgdef* msgdef = subdesc->msgdef; + const upb_fielddef* f = upb_msgdef_itof(msgdef, 1); + native_slot_get_default(upb_fielddef_type(f), cached TSRMLS_CC); + } // In this case, wrapper message hasn't been created and value will be // stored in cache directly. frame->submsg = cached; @@ -1024,6 +1030,12 @@ static void* wrapper_oneofsubmsg_handler(void* closure, const void* hd) { if (oldcase != oneofdata->oneof_case_num) { oneof_cleanup(msg, oneofdata); + if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(cached)) == IS_NULL) { + // Needs to initiate the wrapper message + const upb_msgdef* msgdef = subdesc->msgdef; + const upb_fielddef* f = upb_msgdef_itof(msgdef, 1); + native_slot_get_default(upb_fielddef_type(f), cached TSRMLS_CC); + } frame->submsg = cached; frame->is_msg = false; } else if (Z_TYPE_P(CACHED_PTR_TO_ZVAL_PTR(cached)) == IS_OBJECT) { diff --git a/php/tests/encode_decode_test.php b/php/tests/encode_decode_test.php index 53cd526e4f..319e3321d2 100644 --- a/php/tests/encode_decode_test.php +++ b/php/tests/encode_decode_test.php @@ -1164,6 +1164,18 @@ class EncodeDecodeTest extends TestBase $m->serializeToJsonString()); } + public function testEncodeAnyWithDefaultWrapperMessagePacked() + { + $any = new Any(); + $any->pack(new TestInt32Value([ + 'field' => new Int32Value(['value' => 0]), + ])); + $this->assertSame( + "{\"@type\":\"type.googleapis.com/foo.TestInt32Value\"," . + "\"field\":0}", + $any->serializeToJsonString()); + } + public function testDecodeTopLevelFieldMask() { $m = new TestMessage(); From 0425fa932ce95a32bb9f88b2c09b995e9ff8207b Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 3 Dec 2019 13:06:31 -0800 Subject: [PATCH 16/23] Add a proto_lang_toolchain for javalite (#6882) (#6976) * Add a proto_lang_toolchain for javalite * fix toolchain. Swap javalite example to master repo --- BUILD | 7 +++++++ examples/WORKSPACE | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/BUILD b/BUILD index f887912765..1c5236d9d8 100644 --- a/BUILD +++ b/BUILD @@ -1001,6 +1001,13 @@ proto_lang_toolchain( visibility = ["//visibility:public"], ) +proto_lang_toolchain( + name = "javalite_toolchain", + command_line = "--java_out=lite:$(OUT)", + runtime = ":protobuf_javalite", + visibility = ["//visibility:public"], +) + alias( name = "objectivec", actual = ":protobuf_objc", diff --git a/examples/WORKSPACE b/examples/WORKSPACE index db86225bc4..fccda3b303 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -21,10 +21,9 @@ local_repository( # Similar to com_google_protobuf but for Java lite. If you are building # for Android, the lite version should be prefered because it has a much # smaller code size. -http_archive( +local_repository( name = "com_google_protobuf_javalite", - strip_prefix = "protobuf-javalite", - urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"], + path = "..", ) load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") From a66423f0fd046af2aff7eb6c48deeb8f95adfa29 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 9 Dec 2019 17:02:10 -0800 Subject: [PATCH 17/23] Make c extension portable for php 7.4 (#6968) * Make c extension portable for php 7.4 * Fix conformance tests * Fix comments * Fix 32-bit * Update conformance failure list * Fix compiler warnings * Cleanup configure created by phpize The file created in php 7.4 is not recognizable by previous versions * Fix conformance tests for 64-bit php * Fix conformance test * Fix compile warning * Fix compile warnings --- conformance/Makefile.am | 4 +- conformance/failure_list_php.txt | 1 - conformance/failure_list_php_c.txt | 62 ++--- conformance/failure_list_php_c_32.txt | 142 ++++++++++++ conformance/failure_list_php_zts_c.txt | 225 ------------------- php/ext/google/protobuf/array.c | 13 +- php/ext/google/protobuf/def.c | 113 +--------- php/ext/google/protobuf/encode_decode.c | 48 +--- php/ext/google/protobuf/map.c | 10 +- php/ext/google/protobuf/message.c | 72 +++--- php/ext/google/protobuf/protobuf.c | 37 +-- php/ext/google/protobuf/protobuf.h | 35 +-- php/ext/google/protobuf/storage.c | 13 +- php/ext/google/protobuf/type_check.c | 24 +- php/src/Google/Protobuf/Internal/Message.php | 16 ++ php/tests/compile_extension.sh | 2 +- tests.sh | 187 +++++++++++---- 17 files changed, 437 insertions(+), 567 deletions(-) create mode 100644 conformance/failure_list_php_c_32.txt delete mode 100644 conformance/failure_list_php_zts_c.txt diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 4eff3e1aec..698b110ad1 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -353,8 +353,8 @@ test_php: protoc_middleman conformance-test-runner conformance-php $(other_langu test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c -test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) - ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c +test_php_c_32: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs) + ./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c_32.txt --text_format_failure_list text_format_failure_list_php.txt ./conformance-php-c # These depend on library paths being properly set up. The easiest way to # run them is to just use "tox" from the python dir. diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt index d30fb3d8bb..7ee5b9aae1 100644 --- a/conformance/failure_list_php.txt +++ b/conformance/failure_list_php.txt @@ -64,7 +64,6 @@ Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOu Required.Proto3.JsonInput.DoubleFieldTooSmall Required.Proto3.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooSmall -Required.Proto3.JsonInput.Int32FieldLeadingSpace Required.Proto3.JsonInput.Int32FieldNotInteger Required.Proto3.JsonInput.Int64FieldNotInteger Required.Proto3.JsonInput.OneofFieldDuplicate diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt index 5950c5742e..6a6949fe40 100644 --- a/conformance/failure_list_php_c.txt +++ b/conformance/failure_list_php_c.txt @@ -18,33 +18,63 @@ Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[3].ProtobufOutput Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[4].ProtobufOutput Required.DurationProtoInputTooLarge.JsonOutput @@ -67,6 +97,7 @@ Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput @@ -76,34 +107,3 @@ Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput Required.TimestampProtoInputTooLarge.JsonOutput Required.TimestampProtoInputTooSmall.JsonOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput -Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput -Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput diff --git a/conformance/failure_list_php_c_32.txt b/conformance/failure_list_php_c_32.txt new file mode 100644 index 0000000000..f516f13ac3 --- /dev/null +++ b/conformance/failure_list_php_c_32.txt @@ -0,0 +1,142 @@ +Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput +Recommended.FieldMaskPathsDontRoundTrip.JsonOutput +Recommended.FieldMaskTooManyUnderscore.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput +Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput +Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHas9FractionalDigits.Validator +Recommended.Proto3.JsonInput.DurationHasZeroFractionalDigit.Validator +Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter +Recommended.Proto3.JsonInput.MapFieldValueIsNull +Recommended.Proto3.JsonInput.OneofZeroBytes.JsonOutput +Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull +Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull +Recommended.Proto3.JsonInput.StringEndsWithEscapeChar +Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder +Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate +Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate +Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHas9FractionalDigits.Validator +Recommended.Proto3.JsonInput.TimestampHasZeroFractionalDigit.Validator +Recommended.Proto3.JsonInput.TimestampZeroNormalized.Validator +Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.PackedInput.UnpackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.ENUM.UnpackedInput.UnpackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT32.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.INT64.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT32.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.SINT64.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT32.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.PackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.DefaultOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataRepeated.UINT64.UnpackedInput.PackedOutput.ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[3].ProtobufOutput +Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.ENUM[4].ProtobufOutput +Required.DurationProtoInputTooLarge.JsonOutput +Required.DurationProtoInputTooSmall.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput +Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput +Required.Proto3.JsonInput.DoubleFieldNan.JsonOutput +Required.Proto3.JsonInput.DurationMaxValue.JsonOutput +Required.Proto3.JsonInput.DurationMaxValue.ProtobufOutput +Required.Proto3.JsonInput.DurationMinValue.JsonOutput +Required.Proto3.JsonInput.DurationMinValue.ProtobufOutput +Required.Proto3.JsonInput.DurationRepeatedValue.JsonOutput +Required.Proto3.JsonInput.DurationRepeatedValue.ProtobufOutput +Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput +Required.Proto3.JsonInput.FloatFieldNan.JsonOutput +Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput +Required.Proto3.JsonInput.Int64FieldMaxValue.JsonOutput +Required.Proto3.JsonInput.Int64FieldMaxValue.ProtobufOutput +Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput +Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput +Required.Proto3.JsonInput.Int64FieldMinValue.JsonOutput +Required.Proto3.JsonInput.Int64FieldMinValue.ProtobufOutput +Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput +Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput +Required.Proto3.JsonInput.OneofFieldDuplicate +Required.Proto3.JsonInput.RejectTopLevelNull +Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput +Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput +Required.Proto3.JsonInput.TimestampLeap.JsonOutput +Required.Proto3.JsonInput.TimestampLeap.ProtobufOutput +Required.Proto3.JsonInput.TimestampMaxValue.JsonOutput +Required.Proto3.JsonInput.TimestampMaxValue.ProtobufOutput +Required.Proto3.JsonInput.TimestampMinValue.JsonOutput +Required.Proto3.JsonInput.TimestampMinValue.ProtobufOutput +Required.Proto3.JsonInput.TimestampRepeatedValue.JsonOutput +Required.Proto3.JsonInput.TimestampRepeatedValue.ProtobufOutput +Required.Proto3.JsonInput.TimestampWithNegativeOffset.JsonOutput +Required.Proto3.JsonInput.TimestampWithNegativeOffset.ProtobufOutput +Required.Proto3.JsonInput.TimestampWithPositiveOffset.JsonOutput +Required.Proto3.JsonInput.TimestampWithPositiveOffset.ProtobufOutput +Required.Proto3.JsonInput.Uint64FieldMaxValue.JsonOutput +Required.Proto3.JsonInput.Uint64FieldMaxValue.ProtobufOutput +Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput +Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput +Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput +Required.Proto3.ProtobufInput.ValidDataOneof.BYTES.DefaultValue.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.BYTES.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.PackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.UnpackedInput.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.JsonOutput +Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput +Required.Proto3.ProtobufInput.ValidDataScalar.FLOAT[2].JsonOutput +Required.TimestampProtoInputTooLarge.JsonOutput +Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/conformance/failure_list_php_zts_c.txt b/conformance/failure_list_php_zts_c.txt deleted file mode 100644 index d9a8fe36d9..0000000000 --- a/conformance/failure_list_php_zts_c.txt +++ /dev/null @@ -1,225 +0,0 @@ -Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput -Recommended.FieldMaskPathsDontRoundTrip.JsonOutput -Recommended.FieldMaskTooManyUnderscore.JsonOutput -Recommended.JsonInput.BoolFieldIntegerOne -Recommended.JsonInput.BoolFieldIntegerZero -Recommended.JsonInput.DurationHas3FractionalDigits.Validator -Recommended.JsonInput.DurationHas6FractionalDigits.Validator -Recommended.JsonInput.DurationHas9FractionalDigits.Validator -Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator -Recommended.JsonInput.Int64FieldBeString.Validator -Recommended.JsonInput.OneofZeroBytes.JsonOutput -Recommended.JsonInput.OneofZeroBytes.ProtobufOutput -Recommended.JsonInput.OneofZeroDouble.JsonOutput -Recommended.JsonInput.OneofZeroDouble.ProtobufOutput -Recommended.JsonInput.OneofZeroFloat.JsonOutput -Recommended.JsonInput.OneofZeroFloat.ProtobufOutput -Recommended.JsonInput.OneofZeroString.JsonOutput -Recommended.JsonInput.OneofZeroString.ProtobufOutput -Recommended.JsonInput.OneofZeroUint32.JsonOutput -Recommended.JsonInput.OneofZeroUint32.ProtobufOutput -Recommended.JsonInput.OneofZeroUint64.JsonOutput -Recommended.JsonInput.OneofZeroUint64.ProtobufOutput -Recommended.JsonInput.StringEndsWithEscapeChar -Recommended.JsonInput.StringFieldSurrogateInWrongOrder -Recommended.JsonInput.StringFieldUnpairedHighSurrogate -Recommended.JsonInput.StringFieldUnpairedLowSurrogate -Recommended.JsonInput.TimestampHas3FractionalDigits.Validator -Recommended.JsonInput.TimestampHas6FractionalDigits.Validator -Recommended.JsonInput.TimestampHas9FractionalDigits.Validator -Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator -Recommended.JsonInput.TimestampZeroNormalized.Validator -Recommended.JsonInput.Uint64FieldBeString.Validator -Recommended.ProtobufInput.OneofZeroBytes.JsonOutput -Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput -Recommended.ProtobufInput.OneofZeroString.JsonOutput -Recommended.ProtobufInput.OneofZeroString.ProtobufOutput -Required.DurationProtoInputTooLarge.JsonOutput -Required.DurationProtoInputTooSmall.JsonOutput -Required.JsonInput.AllFieldAcceptNull.ProtobufOutput -Required.JsonInput.Any.JsonOutput -Required.JsonInput.Any.ProtobufOutput -Required.JsonInput.AnyNested.JsonOutput -Required.JsonInput.AnyNested.ProtobufOutput -Required.JsonInput.AnyUnorderedTypeTag.JsonOutput -Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput -Required.JsonInput.AnyWithDuration.JsonOutput -Required.JsonInput.AnyWithDuration.ProtobufOutput -Required.JsonInput.AnyWithFieldMask.JsonOutput -Required.JsonInput.AnyWithFieldMask.ProtobufOutput -Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput -Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput -Required.JsonInput.AnyWithStruct.JsonOutput -Required.JsonInput.AnyWithStruct.ProtobufOutput -Required.JsonInput.AnyWithTimestamp.JsonOutput -Required.JsonInput.AnyWithTimestamp.ProtobufOutput -Required.JsonInput.AnyWithValueForInteger.JsonOutput -Required.JsonInput.AnyWithValueForInteger.ProtobufOutput -Required.JsonInput.AnyWithValueForJsonObject.JsonOutput -Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput -Required.JsonInput.BoolFieldFalse.ProtobufOutput -Required.JsonInput.BoolMapField.JsonOutput -Required.JsonInput.DoubleFieldInfinity.JsonOutput -Required.JsonInput.DoubleFieldInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput -Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput -Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput -Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput -Required.JsonInput.DoubleFieldNan.JsonOutput -Required.JsonInput.DoubleFieldNan.ProtobufOutput -Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput -Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.DoubleFieldQuotedValue.JsonOutput -Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput -Required.JsonInput.DurationMaxValue.JsonOutput -Required.JsonInput.DurationMaxValue.ProtobufOutput -Required.JsonInput.DurationMinValue.JsonOutput -Required.JsonInput.DurationMinValue.ProtobufOutput -Required.JsonInput.DurationRepeatedValue.JsonOutput -Required.JsonInput.DurationRepeatedValue.ProtobufOutput -Required.JsonInput.EnumField.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput -Required.JsonInput.EnumFieldNumericValueZero.JsonOutput -Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput -Required.JsonInput.EnumFieldUnknownValue.Validator -Required.JsonInput.FieldMask.JsonOutput -Required.JsonInput.FieldMask.ProtobufOutput -Required.JsonInput.FloatFieldInfinity.JsonOutput -Required.JsonInput.FloatFieldInfinity.ProtobufOutput -Required.JsonInput.FloatFieldNan.JsonOutput -Required.JsonInput.FloatFieldNan.ProtobufOutput -Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput -Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput -Required.JsonInput.FloatFieldQuotedValue.JsonOutput -Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput -Required.JsonInput.FloatFieldTooLarge -Required.JsonInput.FloatFieldTooSmall -Required.JsonInput.Int32FieldExponentialFormat.JsonOutput -Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput -Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput -Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput -Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldMinFloatValue.JsonOutput -Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValue.JsonOutput -Required.JsonInput.Int32FieldStringValue.ProtobufOutput -Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput -Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput -Required.JsonInput.Int32MapEscapedKey.JsonOutput -Required.JsonInput.Int32MapEscapedKey.ProtobufOutput -Required.JsonInput.Int32MapField.JsonOutput -Required.JsonInput.Int32MapField.ProtobufOutput -Required.JsonInput.Int64FieldMaxValue.JsonOutput -Required.JsonInput.Int64FieldMaxValue.ProtobufOutput -Required.JsonInput.Int64FieldMinValue.JsonOutput -Required.JsonInput.Int64FieldMinValue.ProtobufOutput -Required.JsonInput.Int64MapEscapedKey.JsonOutput -Required.JsonInput.Int64MapEscapedKey.ProtobufOutput -Required.JsonInput.Int64MapField.JsonOutput -Required.JsonInput.Int64MapField.ProtobufOutput -Required.JsonInput.MessageField.JsonOutput -Required.JsonInput.MessageField.ProtobufOutput -Required.JsonInput.MessageMapField.JsonOutput -Required.JsonInput.MessageMapField.ProtobufOutput -Required.JsonInput.MessageRepeatedField.JsonOutput -Required.JsonInput.MessageRepeatedField.ProtobufOutput -Required.JsonInput.OptionalBoolWrapper.JsonOutput -Required.JsonInput.OptionalBoolWrapper.ProtobufOutput -Required.JsonInput.OptionalBytesWrapper.JsonOutput -Required.JsonInput.OptionalBytesWrapper.ProtobufOutput -Required.JsonInput.OptionalDoubleWrapper.JsonOutput -Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput -Required.JsonInput.OptionalFloatWrapper.JsonOutput -Required.JsonInput.OptionalFloatWrapper.ProtobufOutput -Required.JsonInput.OptionalInt32Wrapper.JsonOutput -Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput -Required.JsonInput.OptionalInt64Wrapper.JsonOutput -Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput -Required.JsonInput.OptionalStringWrapper.JsonOutput -Required.JsonInput.OptionalStringWrapper.ProtobufOutput -Required.JsonInput.OptionalUint32Wrapper.JsonOutput -Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput -Required.JsonInput.OptionalUint64Wrapper.JsonOutput -Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput -Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput -Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput -Required.JsonInput.PrimitiveRepeatedField.JsonOutput -Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput -Required.JsonInput.RepeatedBoolWrapper.JsonOutput -Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput -Required.JsonInput.RepeatedBytesWrapper.JsonOutput -Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput -Required.JsonInput.RepeatedDoubleWrapper.JsonOutput -Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput -Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt -Required.JsonInput.RepeatedFloatWrapper.JsonOutput -Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput -Required.JsonInput.RepeatedInt32Wrapper.JsonOutput -Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput -Required.JsonInput.RepeatedInt64Wrapper.JsonOutput -Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput -Required.JsonInput.RepeatedStringWrapper.JsonOutput -Required.JsonInput.RepeatedStringWrapper.ProtobufOutput -Required.JsonInput.RepeatedUint32Wrapper.JsonOutput -Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput -Required.JsonInput.RepeatedUint64Wrapper.JsonOutput -Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput -Required.JsonInput.StringFieldEscape.JsonOutput -Required.JsonInput.StringFieldEscape.ProtobufOutput -Required.JsonInput.StringFieldNotAString -Required.JsonInput.StringFieldSurrogatePair.JsonOutput -Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscape.JsonOutput -Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput -Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput -Required.JsonInput.Struct.JsonOutput -Required.JsonInput.Struct.ProtobufOutput -Required.JsonInput.TimestampMaxValue.JsonOutput -Required.JsonInput.TimestampMaxValue.ProtobufOutput -Required.JsonInput.TimestampMinValue.JsonOutput -Required.JsonInput.TimestampMinValue.ProtobufOutput -Required.JsonInput.TimestampRepeatedValue.JsonOutput -Required.JsonInput.TimestampRepeatedValue.ProtobufOutput -Required.JsonInput.TimestampWithNegativeOffset.JsonOutput -Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput -Required.JsonInput.TimestampWithPositiveOffset.JsonOutput -Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput -Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput -Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput -Required.JsonInput.Uint32MapField.JsonOutput -Required.JsonInput.Uint32MapField.ProtobufOutput -Required.JsonInput.Uint64FieldMaxValue.JsonOutput -Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput -Required.JsonInput.Uint64MapField.JsonOutput -Required.JsonInput.Uint64MapField.ProtobufOutput -Required.JsonInput.ValueAcceptBool.JsonOutput -Required.JsonInput.ValueAcceptBool.ProtobufOutput -Required.JsonInput.ValueAcceptFloat.JsonOutput -Required.JsonInput.ValueAcceptFloat.ProtobufOutput -Required.JsonInput.ValueAcceptInteger.JsonOutput -Required.JsonInput.ValueAcceptInteger.ProtobufOutput -Required.JsonInput.ValueAcceptList.JsonOutput -Required.JsonInput.ValueAcceptList.ProtobufOutput -Required.JsonInput.ValueAcceptNull.JsonOutput -Required.JsonInput.ValueAcceptNull.ProtobufOutput -Required.JsonInput.ValueAcceptObject.JsonOutput -Required.JsonInput.ValueAcceptObject.ProtobufOutput -Required.JsonInput.ValueAcceptString.JsonOutput -Required.JsonInput.ValueAcceptString.ProtobufOutput -Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput -Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput -Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput -Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput -Required.TimestampProtoInputTooLarge.JsonOutput -Required.TimestampProtoInputTooSmall.JsonOutput diff --git a/php/ext/google/protobuf/array.c b/php/ext/google/protobuf/array.c index b52bdf62ca..aa862d9963 100644 --- a/php/ext/google/protobuf/array.c +++ b/php/ext/google/protobuf/array.c @@ -73,7 +73,6 @@ static int repeated_field_array_init(zval *array, upb_fieldtype_t type, uint size ZEND_FILE_LINE_DC); static void repeated_field_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC); -static int repeated_field_has_dimension(zval *object, zval *offset TSRMLS_DC); static HashTable *repeated_field_get_gc(zval *object, CACHED_VALUE **table, int *n TSRMLS_DC); #if PHP_MAJOR_VERSION < 7 @@ -102,7 +101,7 @@ php_proto_zval_ptr_dtor(&intern->array); #endif PHP_PROTO_OBJECT_FREE_END -PHP_PROTO_OBJECT_DTOR_START(RepeatedField, repeated_field) +PHP_PROTO_OBJECT_EMPTY_DTOR_START(RepeatedField, repeated_field) PHP_PROTO_OBJECT_DTOR_END // Define object create method. @@ -488,10 +487,10 @@ PHP_METHOD(RepeatedField, getIterator) { // ----------------------------------------------------------------------------- // Define object free method. -PHP_PROTO_OBJECT_FREE_START(RepeatedFieldIter, repeated_field_iter) +PHP_PROTO_OBJECT_EMPTY_FREE_START(RepeatedFieldIter, repeated_field_iter) PHP_PROTO_OBJECT_FREE_END -PHP_PROTO_OBJECT_DTOR_START(RepeatedFieldIter, repeated_field_iter) +PHP_PROTO_OBJECT_EMPTY_DTOR_START(RepeatedFieldIter, repeated_field_iter) PHP_PROTO_OBJECT_DTOR_END // Define object create method. @@ -519,7 +518,7 @@ PHP_METHOD(RepeatedFieldIter, current) { RepeatedFieldIter *intern = UNBOX(RepeatedFieldIter, getThis()); RepeatedField *repeated_field = intern->repeated_field; - long index; + long index = 0; void *memory; HashTable *table = PHP_PROTO_HASH_OF(repeated_field->array); @@ -527,13 +526,13 @@ PHP_METHOD(RepeatedFieldIter, current) { if (repeated_field->type == UPB_TYPE_MESSAGE) { if (php_proto_zend_hash_index_find_zval(table, intern->position, (void **)&memory) == FAILURE) { - zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index); + zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index); return; } } else { if (php_proto_zend_hash_index_find_mem(table, intern->position, (void **)&memory) == FAILURE) { - zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index); + zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index); return; } } diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 7a23105e9a..f10c37cd9b 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -69,31 +69,6 @@ static void check_upb_status(const upb_status* status, const char* msg) { } } -// Camel-case the field name and append "Entry" for generated map entry name. -// e.g. map foo_map => FooMapEntry -static void append_map_entry_name(char *result, const char *field_name, - int pos) { - bool cap_next = true; - int i; - - for (i = 0; i < strlen(field_name); ++i) { - if (field_name[i] == '_') { - cap_next = true; - } else if (cap_next) { - // Note: Do not use ctype.h due to locales. - if ('a' <= field_name[i] && field_name[i] <= 'z') { - result[pos++] = field_name[i] - 'a' + 'A'; - } else { - result[pos++] = field_name[i]; - } - cap_next = false; - } else { - result[pos++] = field_name[i]; - } - } - strcat(result, "Entry"); -} - // ----------------------------------------------------------------------------- // GPBType // ----------------------------------------------------------------------------- @@ -682,29 +657,6 @@ static void descriptor_pool_init_c_instance(DescriptorPool *pool TSRMLS_DC) { static void descriptor_pool_free_c(DescriptorPool *pool TSRMLS_DC) { } -static void validate_enumdef(const upb_enumdef *enumdef) { - // Verify that an entry exists with integer value 0. (This is the default - // value.) - const char *lookup = upb_enumdef_iton(enumdef, 0); - if (lookup == NULL) { - zend_error(E_USER_ERROR, - "Enum definition does not contain a value for '0'."); - } -} - -static void validate_msgdef(const upb_msgdef* msgdef) { - // Verify that no required fields exist. proto3 does not support these. - upb_msg_field_iter it; - for (upb_msg_field_begin(&it, msgdef); - !upb_msg_field_done(&it); - upb_msg_field_next(&it)) { - const upb_fielddef* field = upb_msg_iter_field(&it); - if (upb_fielddef_label(field) == UPB_LABEL_REQUIRED) { - zend_error(E_ERROR, "Required fields are unsupported in proto3."); - } - } -} - PHP_METHOD(DescriptorPool, getGeneratedPool) { init_generated_pool_once(TSRMLS_C); #if PHP_MAJOR_VERSION < 7 @@ -725,58 +677,6 @@ PHP_METHOD(InternalDescriptorPool, getGeneratedPool) { #endif } -static size_t classname_len_max(const char *fullname, - const char *package, - const char *php_namespace, - const char *prefix) { - size_t fullname_len = strlen(fullname); - size_t package_len = 0; - size_t prefix_len = 0; - size_t namespace_len = 0; - size_t length = fullname_len; - int i, segment, classname_start = 0; - - if (package != NULL) { - package_len = strlen(package); - } - if (prefix != NULL) { - prefix_len = strlen(prefix); - } - if (php_namespace != NULL) { - namespace_len = strlen(php_namespace); - } - - // Process package - if (package_len > 0) { - segment = 1; - for (i = 0; i < package_len; i++) { - if (package[i] == '.') { - segment++; - } - } - // In case of reserved name in package. - length += 3 * segment; - - classname_start = package_len + 1; - } - - // Process class name - segment = 1; - for (i = classname_start; i < fullname_len; i++) { - if (fullname[i] == '.') { - segment++; - } - } - if (prefix_len == 0) { - length += 3 * segment; - } else { - length += prefix_len * segment; - } - - // The additional 2, one is for preceding '.' and the other is for trailing 0. - return length + namespace_len + 2; -} - static bool is_reserved(const char *segment, int length) { bool result; char* lower = ALLOC_N(char, length + 1); @@ -797,8 +697,6 @@ static void fill_prefix(const char *segment, int length, const char *prefix_given, const char *package_name, stringsink *classname) { - size_t i; - if (prefix_given != NULL && strcmp(prefix_given, "") != 0) { stringsink_string(classname, NULL, prefix_given, strlen(prefix_given), NULL); @@ -834,7 +732,7 @@ static void fill_namespace(const char *package, const char *php_namespace, stringsink_string(classname, NULL, "\\", 1, NULL); } } else if (package != NULL) { - int i = 0, j, offset = 0; + int i = 0, j = 0; size_t package_len = strlen(package); while (i < package_len) { j = i; @@ -868,7 +766,7 @@ static void fill_classname(const char *fullname, while (j < fullname_len && fullname[j] != '.') { j++; } - if (use_nested_submsg || is_first_segment && j == fullname_len) { + if (use_nested_submsg || (is_first_segment && j == fullname_len)) { fill_prefix(fullname + i, j - i, prefix, package, classname); } is_first_segment = false; @@ -907,9 +805,6 @@ static void fill_classname_for_desc(void *desc, bool is_enum) { const char *package = upb_filedef_package(file); const char *php_namespace = upb_filedef_phpnamespace(file); const char *prefix = upb_filedef_phpprefix(file); - size_t classname_len = - classname_len_max(fullname, package, php_namespace, prefix); - char* after_package; stringsink namesink; stringsink_init(&namesink); @@ -958,7 +853,7 @@ void register_class(void *desc, bool is_enum TSRMLS_DC) { zend_error( E_ERROR, "Generated message class %s hasn't been defined (%s)", - classname); + classname, fullname); return; } ret = PHP_PROTO_CE_UNREF(pce); @@ -1107,9 +1002,7 @@ void internal_add_generated_file(const char *data, PHP_PROTO_SIZE data_len, PHP_METHOD(InternalDescriptorPool, internalAddGeneratedFile) { char *data = NULL; PHP_PROTO_SIZE data_len; - upb_filedef **files; zend_bool use_nested_submsg = false; - size_t i; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &data, &data_len, &use_nested_submsg) == diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c index 17233275b8..8eaa5d22ee 100644 --- a/php/ext/google/protobuf/encode_decode.c +++ b/php/ext/google/protobuf/encode_decode.c @@ -333,25 +333,6 @@ DEFINE_SINGULAR_HANDLER(double, double) #undef DEFINE_SINGULAR_HANDLER -#if PHP_MAJOR_VERSION < 7 -static void *empty_php_string(zval** value_ptr) { - SEPARATE_ZVAL_IF_NOT_REF(value_ptr); - if (Z_TYPE_PP(value_ptr) == IS_STRING && - !IS_INTERNED(Z_STRVAL_PP(value_ptr))) { - FREE(Z_STRVAL_PP(value_ptr)); - } - ZVAL_EMPTY_STRING(*value_ptr); - return (void*)(*value_ptr); -} -#else -static void *empty_php_string(zval* value_ptr) { - if (Z_TYPE_P(value_ptr) == IS_STRING) { - zend_string_release(Z_STR_P(value_ptr)); - } - ZVAL_EMPTY_STRING(value_ptr); - return value_ptr; -} -#endif #if PHP_MAJOR_VERSION < 7 static void new_php_string(zval** value_ptr, const char* str, size_t len) { SEPARATE_ZVAL_IF_NOT_REF(value_ptr); @@ -830,7 +811,6 @@ static map_handlerdata_t* new_map_handlerdata( static bool oneof##type##_handler(void* closure, const void* hd, \ ctype val) { \ const oneof_handlerdata_t* oneofdata = hd; \ - MessageHeader* msg = (MessageHeader*)closure; \ DEREF(message_data(closure), oneofdata->case_ofs, uint32_t) = \ oneofdata->oneof_case_num; \ DEREF(message_data(closure), oneofdata->ofs, ctype) = val; \ @@ -886,22 +866,6 @@ static void oneof_cleanup(MessageHeader* msg, } // Handlers for string/bytes in a oneof. -static void *oneofbytes_handler(void *closure, - const void *hd, - size_t size_hint) { - MessageHeader* msg = closure; - const oneof_handlerdata_t *oneofdata = hd; - - oneof_cleanup(msg, oneofdata); - - DEREF(message_data(msg), oneofdata->case_ofs, uint32_t) = - oneofdata->oneof_case_num; - DEREF(message_data(msg), oneofdata->ofs, CACHED_VALUE*) = - OBJ_PROP(&msg->std, oneofdata->property_ofs); - - return empty_php_string(DEREF( - message_data(msg), oneofdata->ofs, CACHED_VALUE*)); -} static bool oneofstr_end_handler(void *closure, const void *hd) { stringfields_parseframe_t* frame = closure; MessageHeader* msg = (MessageHeader*)frame->closure; @@ -984,7 +948,6 @@ static void* wrapper_submsg_handler(void* closure, const void* hd) { TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(submsgdata->md); register_class(subdesc, false TSRMLS_CC); - zend_class_entry* subklass = subdesc->klass; zval* submsg_php; MessageHeader* submsg; wrapperfields_parseframe_t* frame = @@ -1022,7 +985,6 @@ static void* wrapper_oneofsubmsg_handler(void* closure, const void* hd) { TSRMLS_FETCH(); DescriptorInternal* subdesc = get_msgdef_desc(oneofdata->md); register_class(subdesc, false TSRMLS_CC); - zend_class_entry* subklass = subdesc->klass; wrapperfields_parseframe_t* frame = (wrapperfields_parseframe_t*)malloc(sizeof(wrapperfields_parseframe_t)); CACHED_VALUE* cached = OBJ_PROP(&msg->std, oneofdata->property_ofs); @@ -1688,11 +1650,10 @@ static void putjsonlistvalue( upb_status status; upb_sink subsink; const upb_fielddef* f = upb_msgdef_itof(desc->msgdef, 1); - uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset; zval* array; RepeatedField* intern; HashTable *ht; - int size, i; + int size; upb_sink_startmsg(sink); @@ -1722,7 +1683,6 @@ static void putjsonstruct( upb_status status; upb_sink subsink; const upb_fielddef* f = upb_msgdef_itof(desc->msgdef, 1); - uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset; zval* map; Map* intern; int size; @@ -2247,8 +2207,6 @@ static void discard_unknown_fields(MessageHeader* msg) { !upb_msg_field_done(&it); upb_msg_field_next(&it)) { upb_fielddef* f = upb_msg_iter_field(&it); - uint32_t offset = desc->layout->fields[upb_fielddef_index(f)].offset; - bool containing_oneof = false; if (upb_fielddef_containingoneof(f)) { uint32_t oneof_case_offset = @@ -2261,12 +2219,11 @@ static void discard_unknown_fields(MessageHeader* msg) { } // Otherwise, fall through to the appropriate singular-field handler // below. - containing_oneof = true; } if (is_map_field(f)) { MapIter map_it; - int len, size; + int len; const upb_fielddef* value_field; value_field = map_field_value(f); @@ -2275,7 +2232,6 @@ static void discard_unknown_fields(MessageHeader* msg) { zval* map_php = CACHED_PTR_TO_ZVAL_PTR(find_zval_property(msg, f)); if (ZVAL_IS_NULL(map_php)) continue; - Map* intern = UNBOX(Map, map_php); for (map_begin(map_php, &map_it TSRMLS_CC); !map_done(&map_it); map_next(&map_it)) { upb_value value = map_iter_value(&map_it, &len); diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c index 2764788b46..f49afcbba7 100644 --- a/php/ext/google/protobuf/map.c +++ b/php/ext/google/protobuf/map.c @@ -222,7 +222,7 @@ for (map_begin_internal(intern, &it); !map_done(&it); map_next(&it)) { upb_strtable_uninit(&intern->table); PHP_PROTO_OBJECT_FREE_END -PHP_PROTO_OBJECT_DTOR_START(Map, map_field) +PHP_PROTO_OBJECT_EMPTY_DTOR_START(Map, map_field) PHP_PROTO_OBJECT_DTOR_END // Define object create method. @@ -383,7 +383,6 @@ static bool map_field_unset_dimension(zval *object, zval *key TSRMLS_DC) { char keybuf[TABLE_KEY_BUF_LENGTH]; const char* keyval = NULL; size_t length = 0; - upb_value v; if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) { return false; } @@ -454,7 +453,7 @@ PHP_METHOD(MapField, offsetExists) { } PHP_METHOD(MapField, offsetGet) { - zval *index, *value; + zval *index; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { return; @@ -495,7 +494,6 @@ PHP_METHOD(MapField, getIterator) { CREATE_OBJ_ON_ALLOCATED_ZVAL_PTR(return_value, map_field_iter_type); - Map *intern = UNBOX(Map, getThis()); MapIter *iter = UNBOX(MapIter, return_value); map_begin(getThis(), iter TSRMLS_CC); } @@ -544,10 +542,10 @@ static zend_function_entry map_field_iter_methods[] = { // ----------------------------------------------------------------------------- // Define object free method. -PHP_PROTO_OBJECT_FREE_START(MapIter, map_field_iter) +PHP_PROTO_OBJECT_EMPTY_FREE_START(MapIter, map_field_iter) PHP_PROTO_OBJECT_FREE_END -PHP_PROTO_OBJECT_DTOR_START(MapIter, map_field_iter) +PHP_PROTO_OBJECT_EMPTY_DTOR_START(MapIter, map_field_iter) PHP_PROTO_OBJECT_DTOR_END // Define object create method. diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 9adf3b0179..edd62d0074 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -75,8 +75,13 @@ static zval** message_get_property_ptr_ptr(zval* object, zval* member, int type, php_proto_zend_literal key TSRMLS_DC); static HashTable* message_get_gc(zval* object, zval*** table, int* n TSRMLS_DC); #else +#if PHP_VERSION_ID < 70400 static void message_set_property(zval* object, zval* member, zval* value, void** cache_slot); +#else +static zval* message_set_property(zval* object, zval* member, zval* value, + void** cache_slot); +#endif static zval* message_get_property(zval* object, zval* member, int type, void** cache_slot, zval* rv); static zval* message_get_property_ptr_ptr(zval* object, zval* member, int type, @@ -100,7 +105,7 @@ PHP_PROTO_OBJECT_FREE_START(MessageHeader, message) } PHP_PROTO_OBJECT_FREE_END -PHP_PROTO_OBJECT_DTOR_START(MessageHeader, message) +PHP_PROTO_OBJECT_EMPTY_DTOR_START(MessageHeader, message) PHP_PROTO_OBJECT_DTOR_END // Define object create method. @@ -140,13 +145,20 @@ static void message_set_property_internal(zval* object, zval* member, #if PHP_MAJOR_VERSION < 7 static void message_set_property(zval* object, zval* member, zval* value, php_proto_zend_literal key TSRMLS_DC) { -#else +#elif PHP_VERSION_ID < 70400 static void message_set_property(zval* object, zval* member, zval* value, void** cache_slot) { +#else +static zval* message_set_property(zval* object, zval* member, zval* value, + void** cache_slot) { #endif if (Z_TYPE_P(member) != IS_STRING) { zend_error(E_USER_ERROR, "Unexpected type for field name"); +#if PHP_VERSION_ID < 70400 return; +#else + return value; +#endif } #if PHP_MAJOR_VERSION < 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION == 0) @@ -156,10 +168,17 @@ static void message_set_property(zval* object, zval* member, zval* value, #endif // User cannot set property directly (e.g., $m->a = 1) zend_error(E_USER_ERROR, "Cannot access private property."); +#if PHP_VERSION_ID < 70400 return; +#else + return value; +#endif } message_set_property_internal(object, member, value TSRMLS_CC); +#if PHP_VERSION_ID >= 70400 + return value; +#endif } static zval* message_get_property_internal(zval* object, @@ -380,7 +399,6 @@ void Message_construct(zval* msg, zval* array_wrapper) { if (upb_fielddef_issubmsg(value_field)) { const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(value_field); - upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef); is_wrapper = is_wrapper_msg(submsgdef); if (is_wrapper) { @@ -420,7 +438,6 @@ void Message_construct(zval* msg, zval* array_wrapper) { if (upb_fielddef_issubmsg(field)) { const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field); - upb_wellknowntype_t type = upb_msgdef_wellknowntype(submsgdef); is_wrapper = is_wrapper_msg(submsgdef); if (is_wrapper) { @@ -646,6 +663,9 @@ PHP_METHOD(Message, writeWrapperValue) { CASE_TYPE(BOOL, bool, int8_t) #undef CASE_TYPE + case UPB_TYPE_MESSAGE: + zend_error(E_ERROR, "No wrapper for message."); + break; } } @@ -666,7 +686,6 @@ PHP_METHOD(Message, writeWrapperValue) { const upb_msgdef* submsgdef = upb_fielddef_msgsubdef(field); const upb_fielddef* value_field = upb_msgdef_itof(submsgdef, 1); MessageHeader* submsg = UNBOX(MessageHeader, cached_zval); - CACHED_VALUE* cached_value = find_zval_property(submsg, value_field); layout_set(submsg->descriptor->layout, submsg, value_field, value TSRMLS_CC); } else { @@ -1156,7 +1175,11 @@ PHP_METHOD(Field_Cardinality, name) { zend_throw_exception_ex( NULL, 0 TSRMLS_CC, "Enum Google\\Protobuf\\Field_Cardinality has no name " +#if PHP_MAJOR_VERSION < 7 "defined for value %d.", +#else + "defined for value " ZEND_LONG_FMT ".", +#endif value); } } @@ -1291,7 +1314,11 @@ PHP_METHOD(Field_Kind, name) { default: zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Enum Google\\Protobuf\\Field_Kind has no name " +#if PHP_MAJOR_VERSION < 7 "defined for value %d.", +#else + "defined for value " ZEND_LONG_FMT ".", +#endif value); } } @@ -1362,7 +1389,11 @@ PHP_METHOD(NullValue, name) { default: zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Enum Google\\Protobuf\\NullValue has no name " +#if PHP_MAJOR_VERSION < 7 "defined for value %d.", +#else + "defined for value " ZEND_LONG_FMT ".", +#endif value); } } @@ -1419,7 +1450,11 @@ PHP_METHOD(Syntax, name) { default: zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Enum Google\\Protobuf\\Syntax has no name " +#if PHP_MAJOR_VERSION < 7 "defined for value %d.", +#else + "defined for value " ZEND_LONG_FMT ".", +#endif value); } } @@ -1495,7 +1530,6 @@ static void hex_to_binary(const char* hex, char** binary, int* binary_len) { PHP_METHOD(Any, __construct) { init_file_any(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1660,7 +1694,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Duration, __construct) { init_file_duration(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1695,7 +1728,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Timestamp, __construct) { init_file_timestamp(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1704,7 +1736,6 @@ PHP_PROTO_FIELD_ACCESSORS(Timestamp, timestamp, Nanos, "nanos") PHP_METHOD(Timestamp, fromDateTime) { zval* datetime; - zval member; PHP_PROTO_CE_DECLARE date_interface_ce; if (php_proto_zend_lookup_class("\\DatetimeInterface", 18, @@ -1897,7 +1928,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Api, __construct) { init_file_api(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1931,7 +1961,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(BoolValue, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1959,7 +1988,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(BytesValue, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -1987,7 +2015,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(DoubleValue, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2031,7 +2058,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Enum, __construct) { init_file_type(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2071,7 +2097,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(EnumValue, __construct) { init_file_type(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2101,7 +2126,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(FieldMask, __construct) { init_file_field_mask(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2166,7 +2190,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Field, __construct) { init_file_type(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2203,7 +2226,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(FloatValue, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2227,7 +2249,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(GPBEmpty, __construct) { init_file_empty(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2254,7 +2275,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Int32Value, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2282,7 +2302,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Int64Value, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2310,7 +2329,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(ListValue, __construct) { init_file_struct(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2366,7 +2384,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Method, __construct) { init_file_api(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2404,7 +2421,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Mixin, __construct) { init_file_api(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2437,7 +2453,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Option, __construct) { init_file_type(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2467,7 +2482,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(SourceContext, __construct) { init_file_source_context(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2495,7 +2509,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(StringValue, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2523,7 +2536,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Struct, __construct) { init_file_struct(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2571,7 +2583,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Type, __construct) { init_file_type(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2604,7 +2615,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(UInt32Value, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2632,7 +2642,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(UInt64Value, __construct) { init_file_wrappers(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } @@ -2671,7 +2680,6 @@ PHP_PROTO_INIT_SUBMSGCLASS_END PHP_METHOD(Value, __construct) { init_file_struct(TSRMLS_C); - MessageHeader* intern = UNBOX(MessageHeader, getThis()); INIT_MESSAGE_WITH_ARRAY; } diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index 52cdac8e2d..fb4c20984b 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -63,8 +63,6 @@ upb_strtable reserved_names; // ----------------------------------------------------------------------------- static void add_to_table(HashTable* t, const void* def, void* value) { - uint nIndex = (ulong)def & t->nTableMask; - zval* pDest = NULL; php_proto_zend_hash_index_update_mem(t, (zend_ulong)def, &value, sizeof(zval*), (void**)&pDest); @@ -79,28 +77,6 @@ static void* get_from_table(const HashTable* t, const void* def) { return *value; } -static bool exist_in_table(const HashTable* t, const void* def) { - void** value; - return (php_proto_zend_hash_index_find_mem(t, (zend_ulong)def, - (void**)&value) == SUCCESS); -} - -static void add_to_strtable(HashTable* t, const char* key, int key_size, - void* value) { - zval* pDest = NULL; - php_proto_zend_hash_update_mem(t, key, key_size, &value, sizeof(void*), - (void**)&pDest); -} - -static void* get_from_strtable(const HashTable* t, const char* key, int key_size) { - void** value; - if (php_proto_zend_hash_find_mem(t, key, key_size, (void**)&value) == - FAILURE) { - return NULL; - } - return *value; -} - void add_def_obj(const void* def, PHP_PROTO_HASHTABLE_VALUE value) { #if PHP_MAJOR_VERSION < 7 Z_ADDREF_P(value); @@ -349,13 +325,9 @@ static void php_proto_hashtable_descriptor_release(zval* value) { } efree(ptr); } - -static void test_release(void* value) { - void* ptr = value; -} #endif -static initialize_persistent_descriptor_pool(TSRMLS_D) { +static void initialize_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_init(&upb_def_to_desc_map_persistent, UPB_CTYPE_PTR); upb_inttable_init(&upb_def_to_enumdesc_map_persistent, UPB_CTYPE_PTR); upb_inttable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR); @@ -427,7 +399,7 @@ static void cleanup_enumdesc_table(upb_inttable* t) { } } -static cleanup_persistent_descriptor_pool(TSRMLS_D) { +static void cleanup_persistent_descriptor_pool(TSRMLS_D) { // Clean up // Only needs to clean one map out of three (def=>desc, ce=>desc, proto=>desc) @@ -482,10 +454,7 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) { static void reserved_names_init() { size_t i; - upb_value v; -#ifndef NDEBUG - v.ctype = UPB_CTYPE_UINT64; -#endif + upb_value v = upb_value_bool(false); for (i = 0; i < kReservedNamesSize; i++) { upb_strtable_insert2(&reserved_names, kReservedNames[i], strlen(kReservedNames[i]), v); diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 6417b94a0f..786967c222 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -143,7 +143,6 @@ #define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class_ex( \ @@ -156,7 +155,6 @@ #define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); @@ -166,7 +164,6 @@ #define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ @@ -187,6 +184,9 @@ PHP_PROTO_FREE_CLASS_OBJECT(NAME, LOWWERNAME##_free, LOWWERNAME##_handlers); \ } +#define PHP_PROTO_OBJECT_EMPTY_FREE_START(classname, lowername) \ + void lowername##_free(void* object TSRMLS_DC) { \ + classname* intern = object; #define PHP_PROTO_OBJECT_FREE_START(classname, lowername) \ void lowername##_free(void* object TSRMLS_DC) { \ classname* intern = object; @@ -195,6 +195,7 @@ efree(intern); \ } +#define PHP_PROTO_OBJECT_EMPTY_DTOR_START(classname, lowername) #define PHP_PROTO_OBJECT_DTOR_START(classname, lowername) #define PHP_PROTO_OBJECT_DTOR_END @@ -410,32 +411,28 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, zend_object std; \ }; -#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ - void LOWWERNAME##_init(TSRMLS_D) { \ - zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ - INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ - LOWWERNAME##_methods); \ - LOWWERNAME##_type = zend_register_internal_class_ex( \ - &class_type, message_type TSRMLS_CC); \ - zend_do_inheritance(LOWWERNAME##_type, message_type TSRMLS_CC); +#define PHP_PROTO_INIT_SUBMSGCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ + void LOWWERNAME##_init(TSRMLS_D) { \ + zend_class_entry class_type; \ + INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ + LOWWERNAME##_methods); \ + LOWWERNAME##_type = zend_register_internal_class(&class_type); \ + zend_do_inheritance(LOWWERNAME##_type, message_type); #define PHP_PROTO_INIT_SUBMSGCLASS_END \ } #define PHP_PROTO_INIT_ENUMCLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ - LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); + LOWWERNAME##_type = zend_register_internal_class(&class_type); #define PHP_PROTO_INIT_ENUMCLASS_END \ } #define PHP_PROTO_INIT_CLASS_START(CLASSNAME, CAMELNAME, LOWWERNAME) \ void LOWWERNAME##_init(TSRMLS_D) { \ zend_class_entry class_type; \ - const char* class_name = CLASSNAME; \ INIT_CLASS_ENTRY_EX(class_type, CLASSNAME, strlen(CLASSNAME), \ LOWWERNAME##_methods); \ LOWWERNAME##_type = zend_register_internal_class(&class_type TSRMLS_CC); \ @@ -449,6 +446,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, #define PHP_PROTO_INIT_CLASS_END \ } +#define PHP_PROTO_OBJECT_EMPTY_FREE_START(classname, lowername) \ + void lowername##_free(zend_object* object) { #define PHP_PROTO_OBJECT_FREE_START(classname, lowername) \ void lowername##_free(zend_object* object) { \ classname* intern = \ @@ -456,6 +455,8 @@ static inline int php_proto_zend_hash_get_current_data_ex(HashTable* ht, #define PHP_PROTO_OBJECT_FREE_END \ } +#define PHP_PROTO_OBJECT_EMPTY_DTOR_START(classname, lowername) \ + void lowername##_dtor(zend_object* object) { #define PHP_PROTO_OBJECT_DTOR_START(classname, lowername) \ void lowername##_dtor(zend_object* object) { \ classname* intern = \ @@ -569,8 +570,8 @@ static inline int php_proto_zend_lookup_class( LOWERNAME##_free_c(intern TSRMLS_CC); \ PHP_PROTO_OBJECT_FREE_END -#define DEFINE_PROTOBUF_DTOR(CAMELNAME, LOWERNAME) \ - PHP_PROTO_OBJECT_DTOR_START(CAMELNAME, LOWERNAME) \ +#define DEFINE_PROTOBUF_DTOR(CAMELNAME, LOWERNAME) \ + PHP_PROTO_OBJECT_EMPTY_DTOR_START(CAMELNAME, LOWERNAME) \ PHP_PROTO_OBJECT_DTOR_END #define DEFINE_CLASS(NAME, LOWERNAME, string_name) \ diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c index 235c5df8a8..fec7335847 100644 --- a/php/ext/google/protobuf/storage.c +++ b/php/ext/google/protobuf/storage.c @@ -100,8 +100,10 @@ bool native_slot_set(upb_fieldtype_t type, const zend_class_entry* klass, if (EXPECTED(cached_zval != NULL)) { #if PHP_MAJOR_VERSION < 7 REPLACE_ZVAL_VALUE((zval**)memory, value, 1); -#else +#elif PHP_VERSION_ID < 70400 zend_assign_to_variable(cached_zval, value, IS_CV); +#else + zend_assign_to_variable(cached_zval, value, IS_CV, 0); #endif } break; @@ -272,7 +274,6 @@ bool native_slot_set_by_map(upb_fieldtype_t type, const zend_class_entry* klass, } void native_slot_init(upb_fieldtype_t type, void* memory, CACHED_VALUE* cache) { - zval* tmp = NULL; switch (type) { case UPB_TYPE_FLOAT: DEREF(memory, float) = 0.0; @@ -577,11 +578,6 @@ uint32_t* slot_oneof_case(MessageLayout* layout, const void* storage, layout->fields[upb_fielddef_index(field)].case_offset); } -static int slot_property_cache(MessageLayout* layout, const void* storage, - const upb_fielddef* field) { - return layout->fields[upb_fielddef_index(field)].cache_index; -} - void* slot_memory(MessageLayout* layout, const void* storage, const upb_fielddef* field) { return ((uint8_t*)storage) + layout->fields[upb_fielddef_index(field)].offset; @@ -998,7 +994,6 @@ static void native_slot_merge_by_array(const upb_fielddef* field, const void* fr break; } case UPB_TYPE_MESSAGE: { - const upb_msgdef* msg = upb_fielddef_msgsubdef(field); DescriptorInternal* desc = get_msgdef_desc(upb_fielddef_msgsubdef(field)); register_class(desc, false TSRMLS_CC); zend_class_entry* ce = desc->klass; @@ -1168,7 +1163,7 @@ void layout_merge(MessageLayout* layout, MessageHeader* from, const char* layout_get_oneof_case(MessageLayout* layout, const void* storage, const upb_oneofdef* oneof TSRMLS_DC) { upb_oneof_iter i; - const upb_fielddef* first_field; + const upb_fielddef* first_field = NULL; // Oneof is guaranteed to have at least one field. Get the first field. for(upb_oneof_begin(&i, oneof); !upb_oneof_done(&i); upb_oneof_next(&i)) { diff --git a/php/ext/google/protobuf/type_check.c b/php/ext/google/protobuf/type_check.c index af35b90318..84d06be7ef 100644 --- a/php/ext/google/protobuf/type_check.c +++ b/php/ext/google/protobuf/type_check.c @@ -407,8 +407,6 @@ bool protobuf_convert_to_bool(zval* from, int8_t* to) { *to = (int8_t)(Z_LVAL_P(from) != 0); break; case IS_STRING: { - char* strval = Z_STRVAL_P(from); - if (Z_STRLEN_P(from) == 0 || (Z_STRLEN_P(from) == 1 && Z_STRVAL_P(from)[0] == '0')) { *to = 0; @@ -496,7 +494,11 @@ PHP_METHOD(Util, checkMessage) { if (!instanceof_function(Z_OBJCE_P(val), klass TSRMLS_CC)) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Given value is not an instance of %s.", +#if PHP_MAJOR_VERSION < 7 klass->name); +#else + ZSTR_VAL(klass->name)); +#endif return; } RETURN_ZVAL(val, 1, 0); @@ -541,7 +543,11 @@ void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type, if (!instanceof_function(Z_OBJCE_P(val), repeated_field_type TSRMLS_CC)) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Given value is not an instance of %s.", +#if PHP_MAJOR_VERSION < 7 repeated_field_type->name); +#else + ZSTR_VAL(repeated_field_type->name)); +#endif return; } RepeatedField* intern = UNBOX(RepeatedField, val); @@ -553,7 +559,12 @@ void check_repeated_field(const zend_class_entry* klass, PHP_PROTO_LONG type, if (klass != NULL && intern->msg_ce != klass) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Expect a repeated field of %s, but %s is given.", +#if PHP_MAJOR_VERSION < 7 klass->name, intern->msg_ce->name); +#else + ZSTR_VAL(klass->name), + ZSTR_VAL(intern->msg_ce->name)); +#endif return; } RETURN_ZVAL(val, 1, 0); @@ -617,7 +628,11 @@ void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type, if (!instanceof_function(Z_OBJCE_P(val), map_field_type TSRMLS_CC)) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Given value is not an instance of %s.", +#if PHP_MAJOR_VERSION < 7 map_field_type->name); +#else + ZSTR_VAL(map_field_type->name)); +#endif return; } Map* intern = UNBOX(Map, val); @@ -636,7 +651,12 @@ void check_map_field(const zend_class_entry* klass, PHP_PROTO_LONG key_type, if (klass != NULL && intern->msg_ce != klass) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Expect a map field of %s, but %s is given.", +#if PHP_MAJOR_VERSION < 7 klass->name, intern->msg_ce->name); +#else + ZSTR_VAL(klass->name), + ZSTR_VAL(intern->msg_ce->name)); +#endif return; } RETURN_ZVAL(val, 1, 0); diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php index 1ffb24501c..91313336cf 100644 --- a/php/src/Google/Protobuf/Internal/Message.php +++ b/php/src/Google/Protobuf/Internal/Message.php @@ -933,6 +933,10 @@ class Message throw new GPBDecodeException( "Invalid data type for int32 field"); } + if (is_string($value) && trim($value) !== $value) { + throw new GPBDecodeException( + "Invalid data type for int32 field"); + } if (bccomp($value, "2147483647") > 0) { throw new GPBDecodeException( "Int32 too large"); @@ -951,6 +955,10 @@ class Message throw new GPBDecodeException( "Invalid data type for uint32 field"); } + if (is_string($value) && trim($value) !== $value) { + throw new GPBDecodeException( + "Invalid data type for int32 field"); + } if (bccomp($value, 4294967295) > 0) { throw new GPBDecodeException( "Uint32 too large"); @@ -966,6 +974,10 @@ class Message throw new GPBDecodeException( "Invalid data type for int64 field"); } + if (is_string($value) && trim($value) !== $value) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } if (bccomp($value, "9223372036854775807") > 0) { throw new GPBDecodeException( "Int64 too large"); @@ -984,6 +996,10 @@ class Message throw new GPBDecodeException( "Invalid data type for int64 field"); } + if (is_string($value) && trim($value) !== $value) { + throw new GPBDecodeException( + "Invalid data type for int64 field"); + } if (bccomp($value, "18446744073709551615") > 0) { throw new GPBDecodeException( "Uint64 too large"); diff --git a/php/tests/compile_extension.sh b/php/tests/compile_extension.sh index bbd669684c..24367dcc90 100755 --- a/php/tests/compile_extension.sh +++ b/php/tests/compile_extension.sh @@ -6,5 +6,5 @@ pushd $EXTENSION_PATH make clean || true set -e # Add following in configure for debug: --enable-debug CFLAGS='-g -O0' -phpize && ./configure CFLAGS='-g -O0' && make +phpize && ./configure CFLAGS='-g -O0 -Wall' && make popd diff --git a/tests.sh b/tests.sh index abe184ba61..7605e64778 100755 --- a/tests.sh +++ b/tests.sh @@ -514,14 +514,19 @@ build_php5.5() { } build_php5.5_c() { + IS_64BIT=$1 use_php 5.5 pushd php/tests /bin/bash ./test.sh 5.5 popd - # TODO(teboring): Add it back - # pushd conformance - # make test_php_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php5.5_mixed() { @@ -535,12 +540,17 @@ build_php5.5_mixed() { } build_php5.5_zts_c() { + IS_64BIT=$1 use_php_zts 5.5 cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_zts_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php5.6() { @@ -556,12 +566,17 @@ build_php5.6() { } build_php5.6_c() { + IS_64BIT=$1 use_php 5.6 cd php/tests && /bin/bash ./test.sh 5.6 && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php5.6_mixed() { @@ -575,12 +590,17 @@ build_php5.6_mixed() { } build_php5.6_zts_c() { + IS_64BIT=$1 use_php_zts 5.6 cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_zts_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php5.6_mac() { @@ -602,10 +622,9 @@ build_php5.6_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_c - # popd + pushd conformance + make test_php_c + popd } build_php7.0() { @@ -621,12 +640,17 @@ build_php7.0() { } build_php7.0_c() { + IS_64BIT=$1 use_php 7.0 cd php/tests && /bin/bash ./test.sh 7.0 && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php7.0_mixed() { @@ -640,12 +664,17 @@ build_php7.0_mixed() { } build_php7.0_zts_c() { + IS_64BIT=$1 use_php_zts 7.0 cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../.. - # TODO(teboring): Add it back. - # pushd conformance - # make test_php_zts_c - # popd + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd } build_php7.0_mac() { @@ -667,10 +696,9 @@ build_php7.0_mac() { # Test cd php/tests && /bin/bash ./test.sh && cd ../.. - # TODO(teboring): Add it back - # pushd conformance - # make test_php_c - # popd + pushd conformance + make test_php_c + popd } build_php_compatibility() { @@ -691,15 +719,17 @@ build_php7.1() { } build_php7.1_c() { - ENABLE_CONFORMANCE_TEST=$1 + IS_64BIT=$1 use_php 7.1 cd php/tests && /bin/bash ./test.sh 7.1 && cd ../.. - if [ "$ENABLE_CONFORMANCE_TEST" = "true" ] + pushd conformance + if [ "$IS_64BIT" = "true" ] then - pushd conformance make test_php_c - popd + else + make test_php_c_32 fi + popd } build_php7.1_mixed() { @@ -713,10 +743,75 @@ build_php7.1_mixed() { } build_php7.1_zts_c() { + IS_64BIT=$1 use_php_zts 7.1 cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../.. pushd conformance - # make test_php_c + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd +} + +build_php7.4() { + use_php 7.4 + pushd php + rm -rf vendor + composer update + ./vendor/bin/phpunit + popd + pushd conformance + make test_php + popd +} + +build_php7.4_c() { + IS_64BIT=$1 + use_php 7.4 + cd php/tests && /bin/bash ./test.sh 7.4 && cd ../.. + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd + pushd php/ext/google/protobuf + phpize --clean + popd +} + +build_php7.4_mixed() { + use_php 7.4 + pushd php + rm -rf vendor + composer update + /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit + popd + pushd php/ext/google/protobuf + phpize --clean + popd +} + +build_php7.4_zts_c() { + IS_64BIT=$1 + use_php_zts 7.4 + cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../.. + pushd conformance + if [ "$IS_64BIT" = "true" ] + then + make test_php_c + else + make test_php_c_32 + fi + popd + pushd php/ext/google/protobuf + phpize --clean popd } @@ -725,18 +820,22 @@ build_php_all_32() { build_php5.6 build_php7.0 build_php7.1 - build_php5.5_c - build_php5.6_c - build_php7.0_c + build_php7.4 + build_php5.5_c $1 + build_php5.6_c $1 + build_php7.0_c $1 build_php7.1_c $1 + build_php7.4_c $1 build_php5.5_mixed build_php5.6_mixed build_php7.0_mixed build_php7.1_mixed - build_php5.5_zts_c - build_php5.6_zts_c - build_php7.0_zts_c - build_php7.1_zts_c + build_php7.4_mixed + build_php5.5_zts_c $1 + build_php5.6_zts_c $1 + build_php7.0_zts_c $1 + build_php7.1_zts_c $1 + build_php7.4_zts_c $1 } build_php_all() { From b58896e53c3b3f81d46fb0c771f42dbd211a1fec Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Tue, 10 Dec 2019 11:22:24 -0800 Subject: [PATCH 18/23] Update CHANGES.txt for 3.11.2 release (#7002) --- CHANGES.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index f4861dd2c5..fd65e60deb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +2019-12-10 version 3.11.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript) + + PHP + * 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) PHP From 39492b68d8e190b5aeb3c806ac9476dac82d398a Mon Sep 17 00:00:00 2001 From: Rafi Kamal Date: Tue, 10 Dec 2019 17:50:28 -0800 Subject: [PATCH 19/23] Update protobuf version to 3.11.2 (#7004) --- Protobuf-C++.podspec | 2 +- Protobuf.podspec | 2 +- configure.ac | 2 +- csharp/Google.Protobuf.Tools.nuspec | 2 +- .../Google.Protobuf/Google.Protobuf.csproj | 2 +- java/bom/pom.xml | 2 +- java/core/pom.xml | 2 +- java/lite/pom.xml | 2 +- java/pom.xml | 2 +- java/util/pom.xml | 2 +- js/package.json | 2 +- php/ext/google/protobuf/package.xml | 22 +++++++++++++++---- php/ext/google/protobuf/protobuf.h | 2 +- protoc-artifacts/pom.xml | 2 +- python/google/protobuf/__init__.py | 2 +- ruby/google-protobuf.gemspec | 2 +- src/Makefile.am | 2 +- src/google/protobuf/any.pb.h | 2 +- src/google/protobuf/api.pb.h | 2 +- src/google/protobuf/compiler/plugin.pb.h | 2 +- src/google/protobuf/descriptor.pb.h | 2 +- src/google/protobuf/duration.pb.h | 2 +- src/google/protobuf/empty.pb.h | 2 +- src/google/protobuf/field_mask.pb.h | 2 +- src/google/protobuf/port_def.inc | 2 +- src/google/protobuf/source_context.pb.h | 2 +- src/google/protobuf/struct.pb.h | 2 +- src/google/protobuf/stubs/common.h | 2 +- src/google/protobuf/timestamp.pb.h | 2 +- src/google/protobuf/type.pb.h | 2 +- src/google/protobuf/wrappers.pb.h | 2 +- 31 files changed, 48 insertions(+), 34 deletions(-) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index b10a48e41c..1359d0294d 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Protobuf-C++' - s.version = '3.11.1' + s.version = '3.11.2' s.summary = 'Protocol Buffers v3 runtime library for C++.' s.homepage = 'https://github.com/google/protobuf' s.license = '3-Clause BSD License' diff --git a/Protobuf.podspec b/Protobuf.podspec index 36cb6bbe28..6de36e05ac 100644 --- a/Protobuf.podspec +++ b/Protobuf.podspec @@ -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.11.1' + s.version = '3.11.2' s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.' s.homepage = 'https://github.com/protocolbuffers/protobuf' s.license = '3-Clause BSD License' diff --git a/configure.ac b/configure.ac index 85fb2280bd..df39c05ea5 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ AC_PREREQ(2.59) # 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 # the size of one file name in the dist tarfile over the 99-char limit.) -AC_INIT([Protocol Buffers],[3.11.1],[protobuf@googlegroups.com],[protobuf]) +AC_INIT([Protocol Buffers],[3.11.2],[protobuf@googlegroups.com],[protobuf]) AM_MAINTAINER_MODE([enable]) diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec index 8cf70b260d..3823e20583 100644 --- a/csharp/Google.Protobuf.Tools.nuspec +++ b/csharp/Google.Protobuf.Tools.nuspec @@ -5,7 +5,7 @@ Google Protocol Buffers tools Tools for Protocol Buffers - Google's data interchange format. See project site for more info. - 3.11.1 + 3.11.2 Google Inc. protobuf-packages https://github.com/protocolbuffers/protobuf/blob/master/LICENSE diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index b90e4e378a..e8e33e27e6 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -4,7 +4,7 @@ C# runtime library for Protocol Buffers - Google's data interchange format. Copyright 2015, Google Inc. Google Protocol Buffers - 3.11.1 + 3.11.2 6 Google Inc. netstandard1.0;netstandard2.0;net45 diff --git a/java/bom/pom.xml b/java/bom/pom.xml index 78e36d50a9..ea15d48190 100644 --- a/java/bom/pom.xml +++ b/java/bom/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-bom - 3.11.1 + 3.11.2 pom Protocol Buffers [BOM] diff --git a/java/core/pom.xml b/java/core/pom.xml index f87039475e..a57f2aa43c 100644 --- a/java/core/pom.xml +++ b/java/core/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.1 + 3.11.2 protobuf-java diff --git a/java/lite/pom.xml b/java/lite/pom.xml index 187580ed44..81e052104f 100644 --- a/java/lite/pom.xml +++ b/java/lite/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.1 + 3.11.2 protobuf-javalite diff --git a/java/pom.xml b/java/pom.xml index 0d9f7c1ec7..89aeb632c5 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.1 + 3.11.2 pom Protocol Buffers [Parent] diff --git a/java/util/pom.xml b/java/util/pom.xml index 1f34625375..c4f0e5499d 100644 --- a/java/util/pom.xml +++ b/java/util/pom.xml @@ -4,7 +4,7 @@ com.google.protobuf protobuf-parent - 3.11.1 + 3.11.2 protobuf-java-util diff --git a/js/package.json b/js/package.json index 7ac806191d..a2fb371742 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "google-protobuf", - "version": "3.11.1", + "version": "3.11.2", "description": "Protocol Buffers for JavaScript", "main": "google-protobuf.js", "files": [ diff --git a/php/ext/google/protobuf/package.xml b/php/ext/google/protobuf/package.xml index b26860eb8e..99080b750f 100644 --- a/php/ext/google/protobuf/package.xml +++ b/php/ext/google/protobuf/package.xml @@ -10,11 +10,11 @@ protobuf-opensource@google.com yes - 2019-12-02 - + 2019-12-10 + - 3.11.1 - 3.11.1 + 3.11.2 + 3.11.2 stable @@ -487,5 +487,19 @@ G A release. 3-Clause BSD License GA release. + + + 3.11.2 + 3.11.2 + + + stable + stable + + 2019-12-10 + + 3-Clause BSD License + GA release. + diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h index 786967c222..4e6d56a358 100644 --- a/php/ext/google/protobuf/protobuf.h +++ b/php/ext/google/protobuf/protobuf.h @@ -37,7 +37,7 @@ #include "upb.h" #define PHP_PROTOBUF_EXTNAME "protobuf" -#define PHP_PROTOBUF_VERSION "3.11.1" +#define PHP_PROTOBUF_VERSION "3.11.2" #define MAX_LENGTH_OF_INT64 20 #define SIZEOF_INT64 8 diff --git a/protoc-artifacts/pom.xml b/protoc-artifacts/pom.xml index 061c82b345..924fb5d42b 100644 --- a/protoc-artifacts/pom.xml +++ b/protoc-artifacts/pom.xml @@ -8,7 +8,7 @@ com.google.protobuf protoc - 3.11.1 + 3.11.2 pom Protobuf Compiler diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 41eec7f3e8..25d2445ff9 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -30,7 +30,7 @@ # Copyright 2007 Google Inc. All Rights Reserved. -__version__ = '3.11.1' +__version__ = '3.11.2' if __name__ != '__main__': try: diff --git a/ruby/google-protobuf.gemspec b/ruby/google-protobuf.gemspec index a621316007..ba7acbc2ac 100644 --- a/ruby/google-protobuf.gemspec +++ b/ruby/google-protobuf.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "google-protobuf" - s.version = "3.11.1" + s.version = "3.11.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 s.licenses = ["BSD-3-Clause"] s.summary = "Protocol Buffers" diff --git a/src/Makefile.am b/src/Makefile.am index a8452e8df9..5ac489b6bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ else PTHREAD_DEF = endif -PROTOBUF_VERSION = 22:1:0 +PROTOBUF_VERSION = 22:2:0 if GCC # Turn on all warnings except for sign comparison (we ignore sign comparison diff --git a/src/google/protobuf/any.pb.h b/src/google/protobuf/any.pb.h index 63fedf5928..f551818e61 100644 --- a/src/google/protobuf/any.pb.h +++ b/src/google/protobuf/any.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/api.pb.h b/src/google/protobuf/api.pb.h index af46e87f90..b00b88dc24 100644 --- a/src/google/protobuf/api.pb.h +++ b/src/google/protobuf/api.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index a698b9f8f4..0fdf8c6ec9 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 3b473a1c55..30e85cca72 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/duration.pb.h b/src/google/protobuf/duration.pb.h index f12a1e9a8b..7b34a4bf02 100644 --- a/src/google/protobuf/duration.pb.h +++ b/src/google/protobuf/duration.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/empty.pb.h b/src/google/protobuf/empty.pb.h index 11923f52f3..66312bc1cc 100644 --- a/src/google/protobuf/empty.pb.h +++ b/src/google/protobuf/empty.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/field_mask.pb.h b/src/google/protobuf/field_mask.pb.h index 9a6f3a2141..f3f83194d8 100644 --- a/src/google/protobuf/field_mask.pb.h +++ b/src/google/protobuf/field_mask.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 555a2e7601..887a372696 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -297,7 +297,7 @@ // Shared google3/opensource definitions. ////////////////////////////////////// -#define PROTOBUF_VERSION 3011001 +#define PROTOBUF_VERSION 3011002 #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3011000 #define PROTOBUF_MIN_PROTOC_VERSION 3011000 #define PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/source_context.pb.h b/src/google/protobuf/source_context.pb.h index c2e8de2400..c9c70c8052 100644 --- a/src/google/protobuf/source_context.pb.h +++ b/src/google/protobuf/source_context.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/struct.pb.h b/src/google/protobuf/struct.pb.h index d0f2e4fc72..9d2ccb2016 100644 --- a/src/google/protobuf/struct.pb.h +++ b/src/google/protobuf/struct.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index c8c82a79f8..3301a4f1b8 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -81,7 +81,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 3011001 +#define GOOGLE_PROTOBUF_VERSION 3011002 // A suffix string for alpha, beta or rc releases. Empty for stable releases. #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" diff --git a/src/google/protobuf/timestamp.pb.h b/src/google/protobuf/timestamp.pb.h index c3988996b1..338a1e707b 100644 --- a/src/google/protobuf/timestamp.pb.h +++ b/src/google/protobuf/timestamp.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/type.pb.h b/src/google/protobuf/type.pb.h index 04af165f59..40d2cd4f0f 100644 --- a/src/google/protobuf/type.pb.h +++ b/src/google/protobuf/type.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. diff --git a/src/google/protobuf/wrappers.pb.h b/src/google/protobuf/wrappers.pb.h index 5d04309d52..ebde03a63f 100644 --- a/src/google/protobuf/wrappers.pb.h +++ b/src/google/protobuf/wrappers.pb.h @@ -13,7 +13,7 @@ #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3011001 < PROTOBUF_MIN_PROTOC_VERSION +#if 3011002 < 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. From fe1790ca0df67173702f70d5646b82f48f412b99 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 12 Dec 2019 13:59:51 -0800 Subject: [PATCH 20/23] Fix Multiple Request for PHP (#7008) * Add scripts to test multirequest * chmod ug+x multirequest.sh * Add continuous test * Compile c extension * Class entry is obsolete in the second request 1) Needes to use class name in persistent map 2) Invalidate class entry stored in descriptor * Add new files to dist * Fix compile_extension * Cleanup outputs for phpize --- .gitignore | 2 + Makefile.am | 2 + php/ext/google/protobuf/protobuf.c | 70 ++++++++++++++++++++++++------ php/tests/compile_extension.sh | 8 +++- php/tests/multirequest.php | 8 ++++ php/tests/multirequest.sh | 34 +++++++++++++++ php/tests/test.sh | 2 +- tests.sh | 28 +++++++++--- 8 files changed, 133 insertions(+), 21 deletions(-) create mode 100644 php/tests/multirequest.php create mode 100755 php/tests/multirequest.sh diff --git a/.gitignore b/.gitignore index 4e909aecea..5e38bbf7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -141,6 +141,8 @@ php/tests/old_protoc php/tests/protobuf/ php/tests/core php/tests/vgcore* +php/tests/multirequest.result +php/tests/nohup.out php/ext/google/protobuf/.libs/ php/ext/google/protobuf/Makefile.fragments php/ext/google/protobuf/Makefile.global diff --git a/Makefile.am b/Makefile.am index 8fd66c79ee..ed852c8d51 100644 --- a/Makefile.am +++ b/Makefile.am @@ -877,6 +877,8 @@ php_EXTRA_DIST= \ php/tests/generated_service_test.php \ php/tests/map_field_test.php \ php/tests/memory_leak_test.php \ + php/tests/multirequest.php \ + php/tests/multirequest.sh \ php/tests/php_implementation_test.php \ php/tests/proto/empty/echo.proto \ php/tests/proto/test.proto \ diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c index fb4c20984b..e9ac935949 100644 --- a/php/ext/google/protobuf/protobuf.c +++ b/php/ext/google/protobuf/protobuf.c @@ -49,8 +49,8 @@ static upb_inttable upb_def_to_enumdesc_map_persistent; // Global map from message/enum's php class entry to corresponding wrapper // Descriptor/EnumDescriptor instances. static HashTable* ce_to_php_obj_map; -static upb_inttable ce_to_desc_map_persistent; -static upb_inttable ce_to_enumdesc_map_persistent; +static upb_strtable ce_to_desc_map_persistent; +static upb_strtable ce_to_enumdesc_map_persistent; // Global map from message/enum's proto fully-qualified name to corresponding // wrapper Descriptor/EnumDescriptor instances. static upb_strtable proto_to_desc_map_persistent; @@ -138,16 +138,28 @@ PHP_PROTO_HASHTABLE_VALUE get_ce_obj(const void* ce) { } void add_ce_desc(const zend_class_entry* ce, DescriptorInternal* desc) { - upb_inttable_insertptr(&ce_to_desc_map_persistent, - ce, upb_value_ptr(desc)); +#if PHP_MAJOR_VERSION < 7 + const char* klass = ce->name; +#else + const char* klass = ZSTR_VAL(ce->name); +#endif + upb_strtable_insert(&ce_to_desc_map_persistent, klass, + upb_value_ptr(desc)); } DescriptorInternal* get_ce_desc(const zend_class_entry* ce) { +#if PHP_MAJOR_VERSION < 7 + const char* klass = ce->name; +#else + const char* klass = ZSTR_VAL(ce->name); +#endif + upb_value v; #ifndef NDEBUG v.ctype = UPB_CTYPE_PTR; #endif - if (!upb_inttable_lookupptr(&ce_to_desc_map_persistent, ce, &v)) { + + if (!upb_strtable_lookup(&ce_to_desc_map_persistent, klass, &v)) { return NULL; } else { return upb_value_getptr(v); @@ -155,16 +167,26 @@ DescriptorInternal* get_ce_desc(const zend_class_entry* ce) { } void add_ce_enumdesc(const zend_class_entry* ce, EnumDescriptorInternal* desc) { - upb_inttable_insertptr(&ce_to_enumdesc_map_persistent, - ce, upb_value_ptr(desc)); +#if PHP_MAJOR_VERSION < 7 + const char* klass = ce->name; +#else + const char* klass = ZSTR_VAL(ce->name); +#endif + upb_strtable_insert(&ce_to_enumdesc_map_persistent, klass, + upb_value_ptr(desc)); } EnumDescriptorInternal* get_ce_enumdesc(const zend_class_entry* ce) { +#if PHP_MAJOR_VERSION < 7 + const char* klass = ce->name; +#else + const char* klass = ZSTR_VAL(ce->name); +#endif upb_value v; #ifndef NDEBUG v.ctype = UPB_CTYPE_PTR; #endif - if (!upb_inttable_lookupptr(&ce_to_enumdesc_map_persistent, ce, &v)) { + if (!upb_strtable_lookup(&ce_to_enumdesc_map_persistent, klass, &v)) { return NULL; } else { return upb_value_getptr(v); @@ -330,8 +352,8 @@ static void php_proto_hashtable_descriptor_release(zval* value) { static void initialize_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_init(&upb_def_to_desc_map_persistent, UPB_CTYPE_PTR); upb_inttable_init(&upb_def_to_enumdesc_map_persistent, UPB_CTYPE_PTR); - upb_inttable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR); - upb_inttable_init(&ce_to_enumdesc_map_persistent, UPB_CTYPE_PTR); + upb_strtable_init(&ce_to_desc_map_persistent, UPB_CTYPE_PTR); + upb_strtable_init(&ce_to_enumdesc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&proto_to_desc_map_persistent, UPB_CTYPE_PTR); upb_strtable_init(&class_to_desc_map_persistent, UPB_CTYPE_PTR); @@ -360,7 +382,29 @@ static PHP_RINIT_FUNCTION(protobuf) { generated_pool_php = NULL; internal_generated_pool_php = NULL; - if (!PROTOBUF_G(keep_descriptor_pool_after_request)) { + if (PROTOBUF_G(keep_descriptor_pool_after_request)) { + // Needs to clean up obsolete class entry + upb_strtable_iter i; + upb_value v; + + DescriptorInternal* desc; + for(upb_strtable_begin(&i, &ce_to_desc_map_persistent); + !upb_strtable_done(&i); + upb_strtable_next(&i)) { + v = upb_strtable_iter_value(&i); + desc = upb_value_getptr(v); + desc->klass = NULL; + } + + EnumDescriptorInternal* enumdesc; + for(upb_strtable_begin(&i, &ce_to_enumdesc_map_persistent); + !upb_strtable_done(&i); + upb_strtable_next(&i)) { + v = upb_strtable_iter_value(&i); + enumdesc = upb_value_getptr(v); + enumdesc->klass = NULL; + } + } else { initialize_persistent_descriptor_pool(TSRMLS_C); } @@ -410,8 +454,8 @@ static void cleanup_persistent_descriptor_pool(TSRMLS_D) { upb_inttable_uninit(&upb_def_to_desc_map_persistent); upb_inttable_uninit(&upb_def_to_enumdesc_map_persistent); - upb_inttable_uninit(&ce_to_desc_map_persistent); - upb_inttable_uninit(&ce_to_enumdesc_map_persistent); + upb_strtable_uninit(&ce_to_desc_map_persistent); + upb_strtable_uninit(&ce_to_enumdesc_map_persistent); upb_strtable_uninit(&proto_to_desc_map_persistent); upb_strtable_uninit(&class_to_desc_map_persistent); } diff --git a/php/tests/compile_extension.sh b/php/tests/compile_extension.sh index 24367dcc90..2ffc51f14b 100755 --- a/php/tests/compile_extension.sh +++ b/php/tests/compile_extension.sh @@ -1,8 +1,12 @@ #!/bin/bash -EXTENSION_PATH=$1 +VERSION=$2 -pushd $EXTENSION_PATH +export PATH=/usr/local/php-$VERSION/bin:$PATH +export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH +export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH + +pushd ../ext/google/protobuf make clean || true set -e # Add following in configure for debug: --enable-debug CFLAGS='-g -O0' diff --git a/php/tests/multirequest.php b/php/tests/multirequest.php new file mode 100644 index 0000000000..bbe8d7703d --- /dev/null +++ b/php/tests/multirequest.php @@ -0,0 +1,8 @@ +protobuf loaded

"; +} else { + echo "

protobuf not loaded

"; +} diff --git a/php/tests/multirequest.sh b/php/tests/multirequest.sh new file mode 100755 index 0000000000..97535ea0ed --- /dev/null +++ b/php/tests/multirequest.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# Compile c extension +VERSION=7.4 +PORT=12345 + +export PATH=/usr/local/php-$VERSION/bin:$PATH +export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$C_INCLUDE_PATH +export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH +/bin/bash ./compile_extension.sh $VERSION + +nohup php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so -S localhost:$PORT multirequest.php 2>&1 & + +sleep 1 + +wget http://localhost:$PORT/multirequest.result -O multirequest.result +wget http://localhost:$PORT/multirequest.result -O multirequest.result + +pushd ../ext/google/protobuf +phpize --clean +popd + +PID=`ps | grep "php" | awk '{print $1}'` +echo $PID + +if [[ -z "$PID" ]] +then + echo "Failed" + exit 1 +else + kill $PID + echo "Succeeded" +fi diff --git a/php/tests/test.sh b/php/tests/test.sh index 9ef565c713..3c5e30d738 100755 --- a/php/tests/test.sh +++ b/php/tests/test.sh @@ -7,7 +7,7 @@ export C_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$V export CPLUS_INCLUDE_PATH=/usr/local/php-$VERSION/include/php/main:/usr/local/php-$VERSION/include/php:$CPLUS_INCLUDE_PATH # Compile c extension -/bin/bash ./compile_extension.sh ../ext/google/protobuf +/bin/bash ./compile_extension.sh $VERSION tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php wrapper_type_setters_test.php) diff --git a/tests.sh b/tests.sh index 7605e64778..65dc15fb55 100755 --- a/tests.sh +++ b/tests.sh @@ -534,7 +534,9 @@ build_php5.5_mixed() { pushd php rm -rf vendor composer update - /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + pushd tests + /bin/bash ./compile_extension.sh 5.5 + popd php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -584,7 +586,9 @@ build_php5.6_mixed() { pushd php rm -rf vendor composer update - /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + pushd tests + /bin/bash ./compile_extension.sh 5.6 + popd php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -658,7 +662,9 @@ build_php7.0_mixed() { pushd php rm -rf vendor composer update - /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + pushd tests + /bin/bash ./compile_extension.sh 7.0 + popd php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -706,6 +712,13 @@ build_php_compatibility() { php/tests/compatibility_test.sh $LAST_RELEASED } +build_php_multirequest() { + use_php 7.4 + pushd php/tests + ./multirequest.sh + popd +} + build_php7.1() { use_php 7.1 pushd php @@ -737,7 +750,9 @@ build_php7.1_mixed() { pushd php rm -rf vendor composer update - /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + pushd tests + /bin/bash ./compile_extension.sh 7.1 + popd php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd } @@ -790,7 +805,9 @@ build_php7.4_mixed() { pushd php rm -rf vendor composer update - /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf + pushd tests + /bin/bash ./compile_extension.sh 7.4 + popd php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit popd pushd php/ext/google/protobuf @@ -840,6 +857,7 @@ build_php_all_32() { build_php_all() { build_php_all_32 true + build_php_multirequest build_php_compatibility } From 7faab5eeebf6aa62d89bf6b3cc1eaea711dea192 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Fri, 13 Dec 2019 15:49:18 -0800 Subject: [PATCH 21/23] add python38 (#7009) * add python38 * add python3.8 * fix tox --- .../dockerfile/test/python_stretch/Dockerfile | 2 ++ kokoro/linux/python38/build.sh | 18 ++++++++++++++++++ kokoro/linux/python38/continuous.cfg | 11 +++++++++++ kokoro/linux/python38/presubmit.cfg | 11 +++++++++++ kokoro/linux/python38_cpp/build.sh | 18 ++++++++++++++++++ kokoro/linux/python38_cpp/continuous.cfg | 11 +++++++++++ kokoro/linux/python38_cpp/presubmit.cfg | 11 +++++++++++ .../release/python/windows/build_artifacts.bat | 10 ++++++++++ .../python/windows/build_single_artifact.bat | 6 ++++++ tests.sh | 8 ++++++++ 10 files changed, 106 insertions(+) create mode 100755 kokoro/linux/python38/build.sh create mode 100644 kokoro/linux/python38/continuous.cfg create mode 100644 kokoro/linux/python38/presubmit.cfg create mode 100755 kokoro/linux/python38_cpp/build.sh create mode 100644 kokoro/linux/python38_cpp/continuous.cfg create mode 100644 kokoro/linux/python38_cpp/presubmit.cfg diff --git a/kokoro/linux/dockerfile/test/python_stretch/Dockerfile b/kokoro/linux/dockerfile/test/python_stretch/Dockerfile index 1dba53087f..10790b9c3e 100644 --- a/kokoro/linux/dockerfile/test/python_stretch/Dockerfile +++ b/kokoro/linux/dockerfile/test/python_stretch/Dockerfile @@ -40,8 +40,10 @@ RUN apt-get update && apt-get -t testing install -y \ python3.5 \ python3.6 \ python3.7 \ + python3.8 \ python3-all-dev RUN curl https://bootstrap.pypa.io/get-pip.py | python3.5 RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 RUN curl https://bootstrap.pypa.io/get-pip.py | python3.7 +RUN curl https://bootstrap.pypa.io/get-pip.py | python3.8 diff --git a/kokoro/linux/python38/build.sh b/kokoro/linux/python38/build.sh new file mode 100755 index 0000000000..9609939a48 --- /dev/null +++ b/kokoro/linux/python38/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# This is the top-level script we give to Kokoro as the entry point for +# running the "pull request" project: +# +# This script selects a specific Dockerfile (for building a Docker image) and +# a script to run inside that image. Then we delegate to the general +# build_and_run_docker.sh script. + +# Change to repo root +cd $(dirname $0)/../../.. + +export DOCKERHUB_ORGANIZATION=protobuftesting +export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/python_stretch +export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh +export OUTPUT_DIR=testoutput +export TEST_SET="python38" +./kokoro/linux/build_and_run_docker.sh diff --git a/kokoro/linux/python38/continuous.cfg b/kokoro/linux/python38/continuous.cfg new file mode 100644 index 0000000000..e2fc4136f0 --- /dev/null +++ b/kokoro/linux/python38/continuous.cfg @@ -0,0 +1,11 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/python/build.sh" +timeout_mins: 120 + +action { + define_artifacts { + regex: "**/sponge_log.xml" + } +} diff --git a/kokoro/linux/python38/presubmit.cfg b/kokoro/linux/python38/presubmit.cfg new file mode 100644 index 0000000000..e2fc4136f0 --- /dev/null +++ b/kokoro/linux/python38/presubmit.cfg @@ -0,0 +1,11 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/python/build.sh" +timeout_mins: 120 + +action { + define_artifacts { + regex: "**/sponge_log.xml" + } +} diff --git a/kokoro/linux/python38_cpp/build.sh b/kokoro/linux/python38_cpp/build.sh new file mode 100755 index 0000000000..c5cd6eeb42 --- /dev/null +++ b/kokoro/linux/python38_cpp/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# This is the top-level script we give to Kokoro as the entry point for +# running the "pull request" project: +# +# This script selects a specific Dockerfile (for building a Docker image) and +# a script to run inside that image. Then we delegate to the general +# build_and_run_docker.sh script. + +# Change to repo root +cd $(dirname $0)/../../.. + +export DOCKERHUB_ORGANIZATION=protobuftesting +export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/python_stretch +export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh +export OUTPUT_DIR=testoutput +export TEST_SET="python38_cpp" +./kokoro/linux/build_and_run_docker.sh diff --git a/kokoro/linux/python38_cpp/continuous.cfg b/kokoro/linux/python38_cpp/continuous.cfg new file mode 100644 index 0000000000..b1b0e550ff --- /dev/null +++ b/kokoro/linux/python38_cpp/continuous.cfg @@ -0,0 +1,11 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/python_cpp/build.sh" +timeout_mins: 120 + +action { + define_artifacts { + regex: "**/sponge_log.xml" + } +} diff --git a/kokoro/linux/python38_cpp/presubmit.cfg b/kokoro/linux/python38_cpp/presubmit.cfg new file mode 100644 index 0000000000..b1b0e550ff --- /dev/null +++ b/kokoro/linux/python38_cpp/presubmit.cfg @@ -0,0 +1,11 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/python_cpp/build.sh" +timeout_mins: 120 + +action { + define_artifacts { + regex: "**/sponge_log.xml" + } +} diff --git a/kokoro/release/python/windows/build_artifacts.bat b/kokoro/release/python/windows/build_artifacts.bat index 9a6842ac91..70a86a199c 100644 --- a/kokoro/release/python/windows/build_artifacts.bat +++ b/kokoro/release/python/windows/build_artifacts.bat @@ -62,6 +62,16 @@ SET PYTHON_VERSION=3.7 SET PYTHON_ARCH=64 CALL build_single_artifact.bat || goto :error +SET PYTHON=C:\python38_32bit +SET PYTHON_VERSION=3.8 +SET PYTHON_ARCH=32 +CALL build_single_artifact.bat || goto :error + +SET PYTHON=C:\python38 +SET PYTHON_VERSION=3.8 +SET PYTHON_ARCH=64 +CALL build_single_artifact.bat || goto :error + goto :EOF :error diff --git a/kokoro/release/python/windows/build_single_artifact.bat b/kokoro/release/python/windows/build_single_artifact.bat index d7cd062c10..45843e1a09 100644 --- a/kokoro/release/python/windows/build_single_artifact.bat +++ b/kokoro/release/python/windows/build_single_artifact.bat @@ -18,6 +18,12 @@ if %PYTHON%==C:\python37_32bit set vcplatform=Win32 if %PYTHON%==C:\python37 set generator=Visual Studio 14 Win64 if %PYTHON%==C:\python37 set vcplatform=x64 +if %PYTHON%==C:\python38_32bit set generator=Visual Studio 14 +if %PYTHON%==C:\python38_32bit set vcplatform=Win32 + +if %PYTHON%==C:\python38 set generator=Visual Studio 14 Win64 +if %PYTHON%==C:\python38 set vcplatform=x64 + REM Prepend newly installed Python to the PATH of this build (this cannot be REM done from inside the powershell script as it would require to restart REM the parent CMD process). diff --git a/tests.sh b/tests.sh index 65dc15fb55..4c7a802324 100755 --- a/tests.sh +++ b/tests.sh @@ -360,6 +360,10 @@ build_python37() { build_python_version py37-python } +build_python38() { + build_python_version py38-python +} + build_python_cpp() { internal_build_cpp export LD_LIBRARY_PATH=../src/.libs # for Linux @@ -408,6 +412,10 @@ build_python37_cpp() { build_python_cpp_version py37-cpp } +build_python38_cpp() { + build_python_cpp_version py38-cpp +} + build_python_compatibility() { internal_build_cpp # Use the unit-tests extraced from 2.5.0 to test the compatibilty. From 03ba4ac171493b53d35bd0acbe81b951c8fefc95 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Thu, 19 Dec 2019 10:27:39 -0800 Subject: [PATCH 22/23] Add python3.8 in build_artifacts for linux and macos (#7019) --- kokoro/release/python/linux/build_artifacts.sh | 1 + kokoro/release/python/macos/build_artifacts.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/kokoro/release/python/linux/build_artifacts.sh b/kokoro/release/python/linux/build_artifacts.sh index 5f9eaa19c8..fd9d5a9395 100755 --- a/kokoro/release/python/linux/build_artifacts.sh +++ b/kokoro/release/python/linux/build_artifacts.sh @@ -53,3 +53,4 @@ build_artifact_version 2.7 build_artifact_version 3.5 build_artifact_version 3.6 build_artifact_version 3.7 +build_artifact_version 3.8 diff --git a/kokoro/release/python/macos/build_artifacts.sh b/kokoro/release/python/macos/build_artifacts.sh index 148d1f9bab..5ecba0be6c 100755 --- a/kokoro/release/python/macos/build_artifacts.sh +++ b/kokoro/release/python/macos/build_artifacts.sh @@ -54,3 +54,4 @@ build_artifact_version 2.7 build_artifact_version 3.5 build_artifact_version 3.6 build_artifact_version 3.7 +build_artifact_version 3.8 From 63cfdafacba6141717a2df97fc123dc0c14ba7c4 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Thu, 19 Dec 2019 14:06:29 -0800 Subject: [PATCH 23/23] Fix python release breakages by set MB_PYTHON_OSX_VER (#7038) --- kokoro/release/python/macos/build_artifacts.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kokoro/release/python/macos/build_artifacts.sh b/kokoro/release/python/macos/build_artifacts.sh index 5ecba0be6c..15aae39777 100755 --- a/kokoro/release/python/macos/build_artifacts.sh +++ b/kokoro/release/python/macos/build_artifacts.sh @@ -50,8 +50,13 @@ build_artifact_version() { mv wheelhouse/* $ARTIFACT_DIR } +export MB_PYTHON_OSX_VER=10.9 build_artifact_version 2.7 -build_artifact_version 3.5 build_artifact_version 3.6 build_artifact_version 3.7 build_artifact_version 3.8 + +# python OSX10.9 does not have python 3.5 +export MB_PYTHON_OSX_VER=10.6 +build_artifact_version 3.5 +