aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2019-06-21 20:31:00 +0000
committerBo Yang <teboring@google.com>2019-06-21 20:31:00 +0000
commitd581c76063e3a4cf468febda2ce8221418f0b813 (patch)
tree03891c75b30d569e0e4dd4b7a3f8fc5e68119e64
parent1f0d8172da990a05811ce975afd2d68948eeeb60 (diff)
parent54288a01cebfd0bfa62ca581dd07ffd6f9c77f2c (diff)
downloadplatform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.tar.gz
platform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.tar.bz2
platform_external_protobuf-d581c76063e3a4cf468febda2ce8221418f0b813.zip
Merge branch 'master' into 3.9.x
Conflicts: java/lite/pom.xml java/util/pom.xml
-rw-r--r--BUILD103
-rw-r--r--Makefile.am1
-rw-r--r--conformance/binary_json_conformance_suite.cc8
-rw-r--r--conformance/failure_list_php.txt4
-rw-r--r--conformance/failure_list_php_c.txt2
-rw-r--r--conformance/failure_list_ruby.txt2
-rw-r--r--conformance/failure_list_ruby_mac.txt2
-rw-r--r--docs/options.md4
-rwxr-xr-xjava/compatibility_tests/v2.5.0/test.sh10
-rw-r--r--java/lite/pom.xml1
-rw-r--r--kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile2
-rw-r--r--php/ext/google/protobuf/upb.c41
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptor.php15
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/EnumValueOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FieldOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileDescriptorSet.php2
-rw-r--r--php/src/Google/Protobuf/Internal/FileOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php26
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MessageOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/MethodOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/OneofOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php2
-rw-r--r--php/src/Google/Protobuf/Internal/ServiceOptions.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo.php2
-rw-r--r--php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php2
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption.php2
-rw-r--r--php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php2
-rw-r--r--php/tests/proto/test_wrapper_type_setters.proto11
-rw-r--r--php/tests/wrapper_type_setters_test.php142
-rw-r--r--ruby/ext/google/protobuf_c/upb.c41
-rw-r--r--ruby/tests/common_tests.rb12
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc22
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_file.cc67
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_file.h6
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_message.cc127
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_message.h8
-rw-r--r--src/google/protobuf/compiler/php/php_generator.cc72
51 files changed, 390 insertions, 393 deletions
diff --git a/BUILD b/BUILD
index 1f1a04746..44beeb298 100644
--- a/BUILD
+++ b/BUILD
@@ -219,7 +219,7 @@ cc_library(
# TODO(keveman): Remove this target once the support gets added to Bazel.
cc_library(
name = "protobuf_headers",
- hdrs = glob(["src/**/*.h"]),
+ hdrs = glob(["src/**/*.h", "src/**/*.inc"]),
includes = ["src/"],
visibility = ["//visibility:public"],
)
@@ -648,6 +648,107 @@ java_library(
)
java_library(
+ name = "protobuf_javalite",
+ srcs = [
+ # Keep in sync with java/lite/pom.xml
+ "java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java",
+ "java/core/src/main/java/com/google/protobuf/AbstractParser.java",
+ "java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java",
+ "java/core/src/main/java/com/google/protobuf/AllocatedBuffer.java",
+ "java/core/src/main/java/com/google/protobuf/Android.java",
+ "java/core/src/main/java/com/google/protobuf/ArrayDecoders.java",
+ "java/core/src/main/java/com/google/protobuf/BinaryReader.java",
+ "java/core/src/main/java/com/google/protobuf/BinaryWriter.java",
+ "java/core/src/main/java/com/google/protobuf/BooleanArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/BufferAllocator.java",
+ "java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java",
+ "java/core/src/main/java/com/google/protobuf/ByteOutput.java",
+ "java/core/src/main/java/com/google/protobuf/ByteString.java",
+ "java/core/src/main/java/com/google/protobuf/CodedInputStream.java",
+ "java/core/src/main/java/com/google/protobuf/CodedInputStreamReader.java",
+ "java/core/src/main/java/com/google/protobuf/CodedOutputStream.java",
+ "java/core/src/main/java/com/google/protobuf/CodedOutputStreamWriter.java",
+ "java/core/src/main/java/com/google/protobuf/DoubleArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/ExperimentalApi.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionLite.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionSchema.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionSchemaLite.java",
+ "java/core/src/main/java/com/google/protobuf/ExtensionSchemas.java",
+ "java/core/src/main/java/com/google/protobuf/FieldInfo.java",
+ "java/core/src/main/java/com/google/protobuf/FieldSet.java",
+ "java/core/src/main/java/com/google/protobuf/FieldType.java",
+ "java/core/src/main/java/com/google/protobuf/FloatArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/GeneratedMessageInfoFactory.java",
+ "java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java",
+ "java/core/src/main/java/com/google/protobuf/IntArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/Internal.java",
+ "java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java",
+ "java/core/src/main/java/com/google/protobuf/IterableByteBufferInputStream.java",
+ "java/core/src/main/java/com/google/protobuf/JavaType.java",
+ "java/core/src/main/java/com/google/protobuf/LazyField.java",
+ "java/core/src/main/java/com/google/protobuf/LazyFieldLite.java",
+ "java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/LazyStringList.java",
+ "java/core/src/main/java/com/google/protobuf/ListFieldSchema.java",
+ "java/core/src/main/java/com/google/protobuf/LongArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/ManifestSchemaFactory.java",
+ "java/core/src/main/java/com/google/protobuf/MapEntryLite.java",
+ "java/core/src/main/java/com/google/protobuf/MapFieldLite.java",
+ "java/core/src/main/java/com/google/protobuf/MapFieldSchema.java",
+ "java/core/src/main/java/com/google/protobuf/MapFieldSchemaLite.java",
+ "java/core/src/main/java/com/google/protobuf/MapFieldSchemas.java",
+ "java/core/src/main/java/com/google/protobuf/MessageInfo.java",
+ "java/core/src/main/java/com/google/protobuf/MessageInfoFactory.java",
+ "java/core/src/main/java/com/google/protobuf/MessageLite.java",
+ "java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java",
+ "java/core/src/main/java/com/google/protobuf/MessageLiteToString.java",
+ "java/core/src/main/java/com/google/protobuf/MessageSchema.java",
+ "java/core/src/main/java/com/google/protobuf/MessageSetSchema.java",
+ "java/core/src/main/java/com/google/protobuf/MutabilityOracle.java",
+ "java/core/src/main/java/com/google/protobuf/NewInstanceSchema.java",
+ "java/core/src/main/java/com/google/protobuf/NewInstanceSchemaLite.java",
+ "java/core/src/main/java/com/google/protobuf/NewInstanceSchemas.java",
+ "java/core/src/main/java/com/google/protobuf/NioByteString.java",
+ "java/core/src/main/java/com/google/protobuf/OneofInfo.java",
+ "java/core/src/main/java/com/google/protobuf/Parser.java",
+ "java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java",
+ "java/core/src/main/java/com/google/protobuf/ProtoSyntax.java",
+ "java/core/src/main/java/com/google/protobuf/Protobuf.java",
+ "java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java",
+ "java/core/src/main/java/com/google/protobuf/ProtobufLists.java",
+ "java/core/src/main/java/com/google/protobuf/ProtocolStringList.java",
+ "java/core/src/main/java/com/google/protobuf/RawMessageInfo.java",
+ "java/core/src/main/java/com/google/protobuf/Reader.java",
+ "java/core/src/main/java/com/google/protobuf/RopeByteString.java",
+ "java/core/src/main/java/com/google/protobuf/Schema.java",
+ "java/core/src/main/java/com/google/protobuf/SchemaFactory.java",
+ "java/core/src/main/java/com/google/protobuf/SchemaUtil.java",
+ "java/core/src/main/java/com/google/protobuf/SmallSortedMap.java",
+ "java/core/src/main/java/com/google/protobuf/StructuralMessageInfo.java",
+ "java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java",
+ "java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java",
+ "java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java",
+ "java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java",
+ "java/core/src/main/java/com/google/protobuf/UnknownFieldSetLiteSchema.java",
+ "java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java",
+ "java/core/src/main/java/com/google/protobuf/UnsafeUtil.java",
+ "java/core/src/main/java/com/google/protobuf/Utf8.java",
+ "java/core/src/main/java/com/google/protobuf/WireFormat.java",
+ "java/core/src/main/java/com/google/protobuf/Writer.java",
+ ],
+ javacopts = select({
+ "//:jdk9": ["--add-modules=jdk.unsupported"],
+ "//conditions:default": [
+ "-source 7",
+ "-target 7",
+ ],
+ }),
+ visibility = ["//visibility:public"],
+)
+
+java_library(
name = "protobuf_java_util",
srcs = glob([
"java/util/src/main/java/com/google/protobuf/util/*.java",
diff --git a/Makefile.am b/Makefile.am
index 8396f6e0c..c03b45c78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1230,6 +1230,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
examples/pubspec.yaml \
examples/third_party/zlib.BUILD \
protobuf.bzl \
+ protobuf_deps.bzl \
python/release/wheel/build_wheel_manylinux.sh \
python/release/wheel/Dockerfile \
python/release/wheel/protobuf_optimized_pip.sh \
diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc
index 0995d3563..5ddb3a90b 100644
--- a/conformance/binary_json_conformance_suite.cc
+++ b/conformance/binary_json_conformance_suite.cc
@@ -1980,12 +1980,12 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
"repeated_timestamp: {seconds: 253402300799 nanos: 999999999}");
RunValidJsonTest(
"TimestampWithPositiveOffset", REQUIRED,
- R"({"optionalTimestamp": "1970-01-01T08:00:00+08:00"})",
- "optional_timestamp: {seconds: 0}");
+ R"({"optionalTimestamp": "1970-01-01T08:00:01+08:00"})",
+ "optional_timestamp: {seconds: 1}");
RunValidJsonTest(
"TimestampWithNegativeOffset", REQUIRED,
- R"({"optionalTimestamp": "1969-12-31T16:00:00-08:00"})",
- "optional_timestamp: {seconds: 0}");
+ R"({"optionalTimestamp": "1969-12-31T16:00:01-08:00"})",
+ "optional_timestamp: {seconds: 1}");
RunValidJsonTest(
"TimestampNull", REQUIRED,
R"({"optionalTimestamp": null})",
diff --git a/conformance/failure_list_php.txt b/conformance/failure_list_php.txt
index f76e9d731..28ca461d4 100644
--- a/conformance/failure_list_php.txt
+++ b/conformance/failure_list_php.txt
@@ -3,10 +3,6 @@ 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
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
diff --git a/conformance/failure_list_php_c.txt b/conformance/failure_list_php_c.txt
index eff09ffe1..8f7af6185 100644
--- a/conformance/failure_list_php_c.txt
+++ b/conformance/failure_list_php_c.txt
@@ -6,7 +6,6 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
-Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.OneofZeroBytes.JsonOutput
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
@@ -17,7 +16,6 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
-Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
Recommended.Proto3.ProtobufInput.OneofZeroBytes.JsonOutput
Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt
index a36f056fd..fc6455d8e 100644
--- a/conformance/failure_list_ruby.txt
+++ b/conformance/failure_list_ruby.txt
@@ -6,7 +6,6 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
-Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
@@ -16,7 +15,6 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
-Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
diff --git a/conformance/failure_list_ruby_mac.txt b/conformance/failure_list_ruby_mac.txt
index 19be38a30..153b0a201 100644
--- a/conformance/failure_list_ruby_mac.txt
+++ b/conformance/failure_list_ruby_mac.txt
@@ -5,7 +5,6 @@ Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
Recommended.Proto3.JsonInput.DurationHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.DurationHas6FractionalDigits.Validator
-Recommended.Proto3.JsonInput.Int64FieldBeString.Validator
Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
@@ -15,7 +14,6 @@ Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.Proto3.JsonInput.TimestampHas3FractionalDigits.Validator
Recommended.Proto3.JsonInput.TimestampHas6FractionalDigits.Validator
-Recommended.Proto3.JsonInput.Uint64FieldBeString.Validator
Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
diff --git a/docs/options.md b/docs/options.md
index 72e265634..f240f0c8b 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -201,3 +201,7 @@ with info about your project (name and website) so we can add an entry for you.
* Website: https://twirpql.dev
* Extensions: 1070
+1. Protoc-gen-validate
+ * Website: https://github.com/envoyproxy/protoc-gen-validate
+ * Extensions: 1071
+
diff --git a/java/compatibility_tests/v2.5.0/test.sh b/java/compatibility_tests/v2.5.0/test.sh
index eea832850..860437809 100755
--- a/java/compatibility_tests/v2.5.0/test.sh
+++ b/java/compatibility_tests/v2.5.0/test.sh
@@ -24,23 +24,23 @@ case "$1" in
;;
2.6.1)
OLD_VERSION=2.6.1
- OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
+ OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/2.6.1-build2/protoc-2.6.1-build2-linux-x86_64.exe
;;
3.0.0-beta-1)
OLD_VERSION=3.0.0-beta-1
- OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
+ OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-1/protoc-3.0.0-beta-1-linux-x86_64.exe
;;
3.0.0-beta-2)
OLD_VERSION=3.0.0-beta-2
- OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
+ OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.exe
;;
3.0.0-beta-3)
OLD_VERSION=3.0.0-beta-3
- OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
+ OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-3/protoc-3.0.0-beta-3-linux-x86_64.exe
;;
3.0.0-beta-4)
OLD_VERSION=3.0.0-beta-4
- OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
+ OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.exe
;;
*)
echo "[ERROR]: Unknown version number: $1"
diff --git a/java/lite/pom.xml b/java/lite/pom.xml
index a1a8b4dcf..f6e1c250f 100644
--- a/java/lite/pom.xml
+++ b/java/lite/pom.xml
@@ -84,6 +84,7 @@
<resource>
<directory>${basedir}/../core/src/main/java/com/google/protobuf</directory>
<includes>
+ <!-- Keep in sync with //:BUILD -->
<include>AbstractMessageLite.java</include>
<include>AbstractParser.java</include>
<include>AbstractProtobufList.java</include>
diff --git a/kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile b/kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile
index 9ba664d8b..866b28934 100644
--- a/kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile
+++ b/kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile
@@ -1,3 +1,3 @@
FROM grpctesting/rake-compiler-dock_53c22085d091183c528303791e7771359f699bcf
-RUN /bin/bash -l -c "gem install bundler"
+RUN /bin/bash -l -c "gem update --system '2.7.9' && gem install bundler"
diff --git a/php/ext/google/protobuf/upb.c b/php/ext/google/protobuf/upb.c
index 1d977437f..cc5a54ab8 100644
--- a/php/ext/google/protobuf/upb.c
+++ b/php/ext/google/protobuf/upb.c
@@ -12431,18 +12431,32 @@ static size_t fmt_bool(bool val, char* buf, size_t length) {
return n;
}
-static size_t fmt_int64(long val, char* buf, size_t length) {
- size_t n = _upb_snprintf(buf, length, "%ld", val);
+static size_t fmt_int64_as_number(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "%lld", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
-static size_t fmt_uint64(unsigned long long val, char* buf, size_t length) {
+static size_t fmt_uint64_as_number(
+ unsigned long long val, char* buf, size_t length) {
size_t n = _upb_snprintf(buf, length, "%llu", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
+static size_t fmt_int64_as_string(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%lld\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
+static size_t fmt_uint64_as_string(
+ unsigned long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%llu\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
/* Print a map key given a field name. Called by scalar field handlers and by
* startseq for repeated fields. */
static bool putkey(void *closure, const void *handler_data) {
@@ -12486,8 +12500,11 @@ static bool putkey(void *closure, const void *handler_data) {
static bool putmapkey_##type(void *closure, const void *handler_data, \
type val) { \
upb_json_printer *p = closure; \
+ char data[64]; \
+ size_t length = fmt_func(val, data, sizeof(data)); \
+ UPB_UNUSED(handler_data); \
print_data(p, "\"", 1); \
- CHK(put##type(closure, handler_data, val)); \
+ print_data(p, data, length); \
print_data(p, "\":", 2); \
return true; \
}
@@ -12495,17 +12512,17 @@ static bool putkey(void *closure, const void *handler_data) {
TYPE_HANDLERS(double, fmt_double)
TYPE_HANDLERS(float, fmt_float)
TYPE_HANDLERS(bool, fmt_bool)
-TYPE_HANDLERS(int32_t, fmt_int64)
-TYPE_HANDLERS(uint32_t, fmt_int64)
-TYPE_HANDLERS(int64_t, fmt_int64)
-TYPE_HANDLERS(uint64_t, fmt_uint64)
+TYPE_HANDLERS(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS(int64_t, fmt_int64_as_string)
+TYPE_HANDLERS(uint64_t, fmt_uint64_as_string)
/* double and float are not allowed to be map keys. */
TYPE_HANDLERS_MAPKEY(bool, fmt_bool)
-TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64)
+TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64_as_number)
#undef TYPE_HANDLERS
#undef TYPE_HANDLERS_MAPKEY
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto.php b/php/src/Google/Protobuf/Internal/DescriptorProto.php
index 3b215d52a..2d5283145 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto</code>
*/
-class DescriptorProto extends \Google\Protobuf\Internal\Message
+final class DescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
index a2057fd5d..fb98f7d5a 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ExtensionRange.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ExtensionRange</code>
*/
-class ExtensionRange extends \Google\Protobuf\Internal\Message
+final class ExtensionRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
index 73c964faa..fa46419a5 100644
--- a/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/DescriptorProto/ReservedRange.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.DescriptorProto.ReservedRange</code>
*/
-class ReservedRange extends \Google\Protobuf\Internal\Message
+final class ReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptor.php b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
index 82a427670..7af4f8401 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptor.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptor.php
@@ -39,17 +39,26 @@ class EnumDescriptor
public function getValueByNumber($number)
{
- return $this->value[$number];
+ if (isset($this->value[$number])) {
+ return $this->value[$number];
+ }
+ return null;
}
public function getValueByName($name)
{
- return $this->name_to_value[$name];
+ if (isset($this->name_to_value[$name])) {
+ return $this->name_to_value[$name];
+ }
+ return null;
}
public function getValueDescriptorByIndex($index)
{
- return $this->value_descriptor[$index];
+ if (isset($this->value_descriptor[$index])) {
+ return $this->value_descriptor[$index];
+ }
+ return null;
}
public function getValueCount()
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
index da30fa990..b7c3a208b 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto</code>
*/
-class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
index e1079585e..0103a1b30 100644
--- a/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
+++ b/php/src/Google/Protobuf/Internal/EnumDescriptorProto/EnumReservedRange.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumDescriptorProto.EnumReservedRange</code>
*/
-class EnumReservedRange extends \Google\Protobuf\Internal\Message
+final class EnumReservedRange extends \Google\Protobuf\Internal\Message
{
/**
* Inclusive.
diff --git a/php/src/Google/Protobuf/Internal/EnumOptions.php b/php/src/Google/Protobuf/Internal/EnumOptions.php
index 3d74c81c2..4c73d5274 100644
--- a/php/src/Google/Protobuf/Internal/EnumOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumOptions</code>
*/
-class EnumOptions extends \Google\Protobuf\Internal\Message
+final class EnumOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set this option to true to allow mapping different tag names to the same
diff --git a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
index 50bda008e..d5a0a9afb 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.EnumValueDescriptorProto</code>
*/
-class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
+final class EnumValueDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/EnumValueOptions.php b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
index a267c6d5e..50ac904ff 100644
--- a/php/src/Google/Protobuf/Internal/EnumValueOptions.php
+++ b/php/src/Google/Protobuf/Internal/EnumValueOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.EnumValueOptions</code>
*/
-class EnumValueOptions extends \Google\Protobuf\Internal\Message
+final class EnumValueOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this enum value deprecated?
diff --git a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
index 00fbebeca..97ad2c055 100644
--- a/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
+++ b/php/src/Google/Protobuf/Internal/ExtensionRangeOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ExtensionRangeOptions</code>
*/
-class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
+final class ExtensionRangeOptions extends \Google\Protobuf\Internal\Message
{
/**
* 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 e57819751..6f8643c8d 100644
--- a/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FieldDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FieldDescriptorProto</code>
*/
-class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FieldDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/FieldOptions.php b/php/src/Google/Protobuf/Internal/FieldOptions.php
index 751c278d7..47d1951d1 100644
--- a/php/src/Google/Protobuf/Internal/FieldOptions.php
+++ b/php/src/Google/Protobuf/Internal/FieldOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FieldOptions</code>
*/
-class FieldOptions extends \Google\Protobuf\Internal\Message
+final class FieldOptions extends \Google\Protobuf\Internal\Message
{
/**
* The ctype option instructs the C++ code generator to use a different
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
index cb10aa793..e95205476 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorProto</code>
*/
-class FileDescriptorProto extends \Google\Protobuf\Internal\Message
+final class FileDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* file name, relative to root of source tree
diff --git a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
index 9907b17d7..c9a38808f 100644
--- a/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
+++ b/php/src/Google/Protobuf/Internal/FileDescriptorSet.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.FileDescriptorSet</code>
*/
-class FileDescriptorSet extends \Google\Protobuf\Internal\Message
+final class FileDescriptorSet extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.FileDescriptorProto file = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/FileOptions.php b/php/src/Google/Protobuf/Internal/FileOptions.php
index 6fea195ec..911000501 100644
--- a/php/src/Google/Protobuf/Internal/FileOptions.php
+++ b/php/src/Google/Protobuf/Internal/FileOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.FileOptions</code>
*/
-class FileOptions extends \Google\Protobuf\Internal\Message
+final class FileOptions extends \Google\Protobuf\Internal\Message
{
/**
* Sets the Java package where classes generated from this .proto will be
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index 0beedba33..7ec3ca229 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -504,17 +504,29 @@ class GPBUtil
public static function formatDuration($value)
{
- if (bccomp($value->getSeconds(), "315576000001") != -1) {
- throw new GPBDecodeException("Duration number too large.");
+ if (bccomp($value->getSeconds(), '315576000001') != -1) {
+ throw new GPBDecodeException('Duration number too large.');
}
- if (bccomp($value->getSeconds(), "-315576000001") != 1) {
- throw new GPBDecodeException("Duration number too small.");
+ if (bccomp($value->getSeconds(), '-315576000001') != 1) {
+ throw new GPBDecodeException('Duration number too small.');
+ }
+
+ $nanos = $value->getNanos();
+ if ($nanos === 0) {
+ return (string) $value->getSeconds();
}
- return strval(bcadd($value->getSeconds(),
- $value->getNanos() / 1000000000.0, 9));
- }
+ if ($nanos % 1000000 === 0) {
+ $digits = 3;
+ } elseif ($nanos % 1000 === 0) {
+ $digits = 6;
+ } else {
+ $digits = 9;
+ }
+ $nanos = bcdiv($nanos, '1000000000', $digits);
+ return bcadd($value->getSeconds(), $nanos, $digits);
+ }
public static function parseFieldMask($paths_string)
{
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
index f5a65bea4..c99d77afa 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php
@@ -17,7 +17,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo</code>
*/
-class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
+final class GeneratedCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* An Annotation connects some span of text in generated code to an element
diff --git a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
index 09f958d25..8cc3cdf45 100644
--- a/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
+++ b/php/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.GeneratedCodeInfo.Annotation</code>
*/
-class Annotation extends \Google\Protobuf\Internal\Message
+final class Annotation extends \Google\Protobuf\Internal\Message
{
/**
* Identifies the element in the original source .proto file. This field
diff --git a/php/src/Google/Protobuf/Internal/MessageOptions.php b/php/src/Google/Protobuf/Internal/MessageOptions.php
index 445394211..9032c97e9 100644
--- a/php/src/Google/Protobuf/Internal/MessageOptions.php
+++ b/php/src/Google/Protobuf/Internal/MessageOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MessageOptions</code>
*/
-class MessageOptions extends \Google\Protobuf\Internal\Message
+final class MessageOptions extends \Google\Protobuf\Internal\Message
{
/**
* Set true to use the old proto1 MessageSet wire format for extensions.
diff --git a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
index 1bd5dd3e1..25a2c166f 100644
--- a/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/MethodDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.MethodDescriptorProto</code>
*/
-class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
+final class MethodDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/MethodOptions.php b/php/src/Google/Protobuf/Internal/MethodOptions.php
index a2c729a9b..a9c093ad5 100644
--- a/php/src/Google/Protobuf/Internal/MethodOptions.php
+++ b/php/src/Google/Protobuf/Internal/MethodOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.MethodOptions</code>
*/
-class MethodOptions extends \Google\Protobuf\Internal\Message
+final class MethodOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this method deprecated?
diff --git a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
index 9ecfe5cbf..a703fcb70 100644
--- a/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/OneofDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.OneofDescriptorProto</code>
*/
-class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
+final class OneofDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/OneofOptions.php b/php/src/Google/Protobuf/Internal/OneofOptions.php
index 46b516f30..749051f31 100644
--- a/php/src/Google/Protobuf/Internal/OneofOptions.php
+++ b/php/src/Google/Protobuf/Internal/OneofOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.OneofOptions</code>
*/
-class OneofOptions extends \Google\Protobuf\Internal\Message
+final class OneofOptions extends \Google\Protobuf\Internal\Message
{
/**
* The parser stores options it doesn't recognize here. See above.
diff --git a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
index 8de7afd0b..9534f0480 100644
--- a/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
+++ b/php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php
@@ -15,7 +15,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.ServiceDescriptorProto</code>
*/
-class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
+final class ServiceDescriptorProto extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>optional string name = 1;</code>
diff --git a/php/src/Google/Protobuf/Internal/ServiceOptions.php b/php/src/Google/Protobuf/Internal/ServiceOptions.php
index 67162f376..55bf7a775 100644
--- a/php/src/Google/Protobuf/Internal/ServiceOptions.php
+++ b/php/src/Google/Protobuf/Internal/ServiceOptions.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.ServiceOptions</code>
*/
-class ServiceOptions extends \Google\Protobuf\Internal\Message
+final class ServiceOptions extends \Google\Protobuf\Internal\Message
{
/**
* Is this service deprecated?
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
index dfeb69ff6..3ddd89226 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo.php
@@ -16,7 +16,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo</code>
*/
-class SourceCodeInfo extends \Google\Protobuf\Internal\Message
+final class SourceCodeInfo extends \Google\Protobuf\Internal\Message
{
/**
* A Location identifies a piece of source code in a .proto file which
diff --git a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
index bad247a11..470d64c6e 100644
--- a/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
+++ b/php/src/Google/Protobuf/Internal/SourceCodeInfo/Location.php
@@ -13,7 +13,7 @@ use Google\Protobuf\Internal\GPBUtil;
/**
* Generated from protobuf message <code>google.protobuf.SourceCodeInfo.Location</code>
*/
-class Location extends \Google\Protobuf\Internal\Message
+final class Location extends \Google\Protobuf\Internal\Message
{
/**
* Identifies which part of the FileDescriptorProto was defined at this
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption.php b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
index 3b517ec55..39273d62f 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption.php
@@ -20,7 +20,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption</code>
*/
-class UninterpretedOption extends \Google\Protobuf\Internal\Message
+final class UninterpretedOption extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>repeated .google.protobuf.UninterpretedOption.NamePart name = 2;</code>
diff --git a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
index 92ee4b44b..a2f9250f9 100644
--- a/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
+++ b/php/src/Google/Protobuf/Internal/UninterpretedOption/NamePart.php
@@ -19,7 +19,7 @@ use Google\Protobuf\Internal\GPBUtil;
*
* Generated from protobuf message <code>google.protobuf.UninterpretedOption.NamePart</code>
*/
-class NamePart extends \Google\Protobuf\Internal\Message
+final class NamePart extends \Google\Protobuf\Internal\Message
{
/**
* Generated from protobuf field <code>required string name_part = 1;</code>
diff --git a/php/tests/proto/test_wrapper_type_setters.proto b/php/tests/proto/test_wrapper_type_setters.proto
index 119bd2547..41ca7f3f3 100644
--- a/php/tests/proto/test_wrapper_type_setters.proto
+++ b/php/tests/proto/test_wrapper_type_setters.proto
@@ -24,14 +24,3 @@ message TestWrapperSetters {
map<string, google.protobuf.StringValue> map_string_value = 13;
}
-
-message TestWrapperAccessorConflicts {
- int32 normal_vs_wrapper_value = 1;
- google.protobuf.Int32Value normal_vs_wrapper = 2;
-
- int32 normal_vs_normal_value = 3;
- int32 normal_vs_normal = 4;
-
- google.protobuf.Int32Value wrapper_vs_wrapper_value = 5;
- google.protobuf.Int32Value wrapper_vs_wrapper = 6;
-}
diff --git a/php/tests/wrapper_type_setters_test.php b/php/tests/wrapper_type_setters_test.php
index 35e3a7dec..ad9f7181d 100644
--- a/php/tests/wrapper_type_setters_test.php
+++ b/php/tests/wrapper_type_setters_test.php
@@ -16,44 +16,6 @@ use Google\Protobuf\UInt64Value;
class WrapperTypeSettersTest extends TestBase
{
- public function testConflictNormalVsWrapper()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setNormalVsWrapperValue1(1);
- $this->assertSame(1, $m->getNormalVsWrapperValue1());
-
- $m->setNormalVsWrapperValue2(1);
- $this->assertSame(1, $m->getNormalVsWrapperValue2());
-
- $wrapper = new Int32Value(["value" => 1]);
- $m->setNormalVsWrapper($wrapper);
- $this->assertSame(1, $m->getNormalVsWrapper()->getValue());
- }
-
- public function testConflictNormalVsNormal()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setNormalVsNormalValue(1);
- $this->assertSame(1, $m->getNormalVsNormalValue());
-
- $m->setNormalVsNormal(1);
- $this->assertSame(1, $m->getNormalVsNormal());
- }
-
- public function testConflictWrapperVsWrapper()
- {
- $m = new Foo\TestWrapperAccessorConflicts();
-
- $m->setWrapperVsWrapperValueValue(1);
- $this->assertSame(1, $m->getWrapperVsWrapperValueValue());
-
- $wrapper = new Int32Value(["value" => 1]);
- $m->setWrapperVsWrapperValue5($wrapper);
- $this->assertSame(1, $m->getWrapperVsWrapperValue5()->getValue());
- }
-
/**
* @dataProvider gettersAndSettersDataProvider
*/
@@ -98,26 +60,26 @@ class WrapperTypeSettersTest extends TestBase
public function gettersAndSettersDataProvider()
{
return [
- [TestWrapperSetters::class, DoubleValue::class, "setDoubleValue", "setDoubleValueValue", "getDoubleValue", "getDoubleValueValue", [
+ [TestWrapperSetters::class, DoubleValue::class, "setDoubleValue", "setDoubleValueUnwrapped", "getDoubleValue", "getDoubleValueUnwrapped", [
[1.1, new DoubleValue(["value" => 1.1])],
[2.2, new DoubleValue(["value" => 2.2])],
[null, null],
[0, new DoubleValue()],
]],
- [TestWrapperSetters::class, FloatValue::class, "setFloatValue", "setFloatValueValue", "getFloatValue", "getFloatValueValue", [
+ [TestWrapperSetters::class, FloatValue::class, "setFloatValue", "setFloatValueUnwrapped", "getFloatValue", "getFloatValueUnwrapped", [
[1.1, new FloatValue(["value" => 1.1])],
[2.2, new FloatValue(["value" => 2.2])],
[null, null],
[0, new FloatValue()],
]],
- [TestWrapperSetters::class, Int64Value::class, "setInt64Value", "setInt64ValueValue", "getInt64Value", "getInt64ValueValue", [
+ [TestWrapperSetters::class, Int64Value::class, "setInt64Value", "setInt64ValueUnwrapped", "getInt64Value", "getInt64ValueUnwrapped", [
[123, new Int64Value(["value" => 123])],
[-789, new Int64Value(["value" => -789])],
[null, null],
[0, new Int64Value()],
[5.5, new Int64Value(["value" => 5])], // Test conversion from float to int
]],
- [TestWrapperSetters::class, UInt64Value::class, "setUInt64Value", "setUInt64ValueValue", "getUInt64Value", "getUInt64ValueValue", [
+ [TestWrapperSetters::class, UInt64Value::class, "setUInt64Value", "setUInt64ValueUnwrapped", "getUInt64Value", "getUInt64ValueUnwrapped", [
[123, new UInt64Value(["value" => 123])],
[789, new UInt64Value(["value" => 789])],
[null, null],
@@ -125,14 +87,14 @@ class WrapperTypeSettersTest extends TestBase
[5.5, new UInt64Value(["value" => 5])], // Test conversion from float to int
[-7, new UInt64Value(["value" => -7])], // Test conversion from -ve to +ve
]],
- [TestWrapperSetters::class, Int32Value::class, "setInt32Value", "setInt32ValueValue", "getInt32Value", "getInt32ValueValue", [
+ [TestWrapperSetters::class, Int32Value::class, "setInt32Value", "setInt32ValueUnwrapped", "getInt32Value", "getInt32ValueUnwrapped", [
[123, new Int32Value(["value" => 123])],
[-789, new Int32Value(["value" => -789])],
[null, null],
[0, new Int32Value()],
[5.5, new Int32Value(["value" => 5])], // Test conversion from float to int
]],
- [TestWrapperSetters::class, UInt32Value::class, "setUInt32Value", "setUInt32ValueValue", "getUInt32Value", "getUInt32ValueValue", [
+ [TestWrapperSetters::class, UInt32Value::class, "setUInt32Value", "setUInt32ValueUnwrapped", "getUInt32Value", "getUInt32ValueUnwrapped", [
[123, new UInt32Value(["value" => 123])],
[789, new UInt32Value(["value" => 789])],
[null, null],
@@ -140,12 +102,12 @@ class WrapperTypeSettersTest extends TestBase
[5.5, new UInt32Value(["value" => 5])], // Test conversion from float to int
[-7, new UInt32Value(["value" => -7])], // Test conversion from -ve to +ve
]],
- [TestWrapperSetters::class, BoolValue::class, "setBoolValue", "setBoolValueValue", "getBoolValue", "getBoolValueValue", [
+ [TestWrapperSetters::class, BoolValue::class, "setBoolValue", "setBoolValueUnwrapped", "getBoolValue", "getBoolValueUnwrapped", [
[true, new BoolValue(["value" => true])],
[false, new BoolValue(["value" => false])],
[null, null],
]],
- [TestWrapperSetters::class, StringValue::class, "setStringValue", "setStringValueValue", "getStringValue", "getStringValueValue", [
+ [TestWrapperSetters::class, StringValue::class, "setStringValue", "setStringValueUnwrapped", "getStringValue", "getStringValueUnwrapped", [
["asdf", new StringValue(["value" => "asdf"])],
["", new StringValue(["value" => ""])],
[null, null],
@@ -155,7 +117,7 @@ class WrapperTypeSettersTest extends TestBase
[-7, new StringValue(["value" => "-7"])], // Test conversion from number to string
[-7.5, new StringValue(["value" => "-7.5"])], // Test conversion from number to string
]],
- [TestWrapperSetters::class, BytesValue::class, "setBytesValue", "setBytesValueValue", "getBytesValue", "getBytesValueValue", [
+ [TestWrapperSetters::class, BytesValue::class, "setBytesValue", "setBytesValueUnwrapped", "getBytesValue", "getBytesValueUnwrapped", [
["asdf", new BytesValue(["value" => "asdf"])],
["", new BytesValue(["value" => ""])],
[null, null],
@@ -165,12 +127,12 @@ class WrapperTypeSettersTest extends TestBase
[-7, new BytesValue(["value" => "-7"])], // Test conversion from number to bytes
[-7.5, new BytesValue(["value" => "-7.5"])], // Test conversion from number to bytes
]],
- [TestWrapperSetters::class, DoubleValue::class, "setDoubleValueOneof", "setDoubleValueOneofValue", "getDoubleValueOneof", "getDoubleValueOneofValue", [
+ [TestWrapperSetters::class, DoubleValue::class, "setDoubleValueOneof", "setDoubleValueOneofUnwrapped", "getDoubleValueOneof", "getDoubleValueOneofUnwrapped", [
[1.1, new DoubleValue(["value" => 1.1])],
[2.2, new DoubleValue(["value" => 2.2])],
[null, null],
[0, new DoubleValue()],
- ]],[TestWrapperSetters::class, StringValue::class, "setStringValueOneof", "setStringValueOneofValue", "getStringValueOneof", "getStringValueOneofValue", [
+ ]],[TestWrapperSetters::class, StringValue::class, "setStringValueOneof", "setStringValueOneofUnwrapped", "getStringValueOneof", "getStringValueOneofUnwrapped", [
["asdf", new StringValue(["value" => "asdf"])],
["", new StringValue(["value" => ""])],
[null, null],
@@ -195,47 +157,47 @@ class WrapperTypeSettersTest extends TestBase
public function invalidSettersDataProvider()
{
return [
- [TestWrapperSetters::class, "setDoubleValueValue", "abc"],
- [TestWrapperSetters::class, "setDoubleValueValue", []],
- [TestWrapperSetters::class, "setDoubleValueValue", new stdClass()],
- [TestWrapperSetters::class, "setDoubleValueValue", new DoubleValue()],
-
- [TestWrapperSetters::class, "setFloatValueValue", "abc"],
- [TestWrapperSetters::class, "setFloatValueValue", []],
- [TestWrapperSetters::class, "setFloatValueValue", new stdClass()],
- [TestWrapperSetters::class, "setFloatValueValue", new FloatValue()],
-
- [TestWrapperSetters::class, "setInt64ValueValue", "abc"],
- [TestWrapperSetters::class, "setInt64ValueValue", []],
- [TestWrapperSetters::class, "setInt64ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setInt64ValueValue", new Int64Value()],
-
- [TestWrapperSetters::class, "setUInt64ValueValue", "abc"],
- [TestWrapperSetters::class, "setUInt64ValueValue", []],
- [TestWrapperSetters::class, "setUInt64ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setUInt64ValueValue", new UInt64Value()],
-
- [TestWrapperSetters::class, "setInt32ValueValue", "abc"],
- [TestWrapperSetters::class, "setInt32ValueValue", []],
- [TestWrapperSetters::class, "setInt32ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setInt32ValueValue", new Int32Value()],
-
- [TestWrapperSetters::class, "setUInt32ValueValue", "abc"],
- [TestWrapperSetters::class, "setUInt32ValueValue", []],
- [TestWrapperSetters::class, "setUInt32ValueValue", new stdClass()],
- [TestWrapperSetters::class, "setUInt32ValueValue", new UInt32Value()],
-
- [TestWrapperSetters::class, "setBoolValueValue", []],
- [TestWrapperSetters::class, "setBoolValueValue", new stdClass()],
- [TestWrapperSetters::class, "setBoolValueValue", new BoolValue()],
-
- [TestWrapperSetters::class, "setStringValueValue", []],
- [TestWrapperSetters::class, "setStringValueValue", new stdClass()],
- [TestWrapperSetters::class, "setStringValueValue", new StringValue()],
-
- [TestWrapperSetters::class, "setBytesValueValue", []],
- [TestWrapperSetters::class, "setBytesValueValue", new stdClass()],
- [TestWrapperSetters::class, "setBytesValueValue", new BytesValue()],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", []],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setDoubleValueUnwrapped", new DoubleValue()],
+
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", []],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setFloatValueUnwrapped", new FloatValue()],
+
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setInt64ValueUnwrapped", new Int64Value()],
+
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setUInt64ValueUnwrapped", new UInt64Value()],
+
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setInt32ValueUnwrapped", new Int32Value()],
+
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", "abc"],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", []],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setUInt32ValueUnwrapped", new UInt32Value()],
+
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", []],
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setBoolValueUnwrapped", new BoolValue()],
+
+ [TestWrapperSetters::class, "setStringValueUnwrapped", []],
+ [TestWrapperSetters::class, "setStringValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setStringValueUnwrapped", new StringValue()],
+
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", []],
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", new stdClass()],
+ [TestWrapperSetters::class, "setBytesValueUnwrapped", new BytesValue()],
];
}
diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c
index 3d96c5ccc..748205083 100644
--- a/ruby/ext/google/protobuf_c/upb.c
+++ b/ruby/ext/google/protobuf_c/upb.c
@@ -16289,18 +16289,32 @@ static size_t fmt_bool(bool val, char* buf, size_t length) {
return n;
}
-static size_t fmt_int64(long val, char* buf, size_t length) {
- size_t n = _upb_snprintf(buf, length, "%ld", val);
+static size_t fmt_int64_as_number(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "%lld", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
-static size_t fmt_uint64(unsigned long long val, char* buf, size_t length) {
+static size_t fmt_uint64_as_number(
+ unsigned long long val, char* buf, size_t length) {
size_t n = _upb_snprintf(buf, length, "%llu", val);
CHKLENGTH(n > 0 && n < length);
return n;
}
+static size_t fmt_int64_as_string(long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%lld\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
+static size_t fmt_uint64_as_string(
+ unsigned long long val, char* buf, size_t length) {
+ size_t n = _upb_snprintf(buf, length, "\"%llu\"", val);
+ CHKLENGTH(n > 0 && n < length);
+ return n;
+}
+
/* Print a map key given a field name. Called by scalar field handlers and by
* startseq for repeated fields. */
static bool putkey(void *closure, const void *handler_data) {
@@ -16344,8 +16358,11 @@ static bool putkey(void *closure, const void *handler_data) {
static bool putmapkey_##type(void *closure, const void *handler_data, \
type val) { \
upb_json_printer *p = closure; \
+ char data[64]; \
+ size_t length = fmt_func(val, data, sizeof(data)); \
+ UPB_UNUSED(handler_data); \
print_data(p, "\"", 1); \
- CHK(put##type(closure, handler_data, val)); \
+ print_data(p, data, length); \
print_data(p, "\":", 2); \
return true; \
}
@@ -16353,17 +16370,17 @@ static bool putkey(void *closure, const void *handler_data) {
TYPE_HANDLERS(double, fmt_double)
TYPE_HANDLERS(float, fmt_float)
TYPE_HANDLERS(bool, fmt_bool)
-TYPE_HANDLERS(int32_t, fmt_int64)
-TYPE_HANDLERS(uint32_t, fmt_int64)
-TYPE_HANDLERS(int64_t, fmt_int64)
-TYPE_HANDLERS(uint64_t, fmt_uint64)
+TYPE_HANDLERS(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS(int64_t, fmt_int64_as_string)
+TYPE_HANDLERS(uint64_t, fmt_uint64_as_string)
/* double and float are not allowed to be map keys. */
TYPE_HANDLERS_MAPKEY(bool, fmt_bool)
-TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64)
-TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64)
+TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64_as_number)
+TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64_as_number)
#undef TYPE_HANDLERS
#undef TYPE_HANDLERS_MAPKEY
diff --git a/ruby/tests/common_tests.rb b/ruby/tests/common_tests.rb
index 2945003b0..fa1e2ff7d 100644
--- a/ruby/tests/common_tests.rb
+++ b/ruby/tests/common_tests.rb
@@ -1108,9 +1108,9 @@ module CommonTests
expected = {
optionalInt32: 0,
- optionalInt64: 0,
+ optionalInt64: "0",
optionalUint32: 0,
- optionalUint64: 0,
+ optionalUint64: "0",
optionalBool: false,
optionalFloat: 0,
optionalDouble: 0,
@@ -1142,9 +1142,9 @@ module CommonTests
expected = {
optionalInt32: 0,
- optionalInt64: 0,
+ optionalInt64: "0",
optionalUint32: 0,
- optionalUint64: 0,
+ optionalUint64: "0",
optionalBool: false,
optionalFloat: 0,
optionalDouble: 0,
@@ -1177,9 +1177,9 @@ module CommonTests
expected = {
optionalInt32: 0,
- optionalInt64: 0,
+ optionalInt64: "0",
optionalUint32: 0,
- optionalUint64: 0,
+ optionalUint64: "0",
optionalBool: false,
optionalFloat: 0,
optionalDouble: 0,
diff --git a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
index 33c561984..978fdf02b 100644
--- a/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
@@ -77,23 +77,19 @@ class MockErrorCollector : public MultiFileErrorCollector {
class MockGeneratorContext : public GeneratorContext {
public:
- MockGeneratorContext() {}
- ~MockGeneratorContext() {
- STLDeleteValues(&files_);
- }
-
void ExpectFileMatches(const string& virtual_filename,
const string& physical_filename) {
- string* expected_contents = FindPtrOrNull(files_, virtual_filename);
- ASSERT_TRUE(expected_contents != NULL)
+ auto it = files_.find(virtual_filename);
+ ASSERT_TRUE(it != files_.end())
<< "Generator failed to generate file: " << virtual_filename;
+ string expected_contents = *it->second;
string actual_contents;
GOOGLE_CHECK_OK(
File::GetContentsAsText(TestSourceDir() + "/" + physical_filename,
&actual_contents, true))
<< "Unable to get " << physical_filename;
- EXPECT_TRUE(actual_contents == *expected_contents)
+ EXPECT_TRUE(actual_contents == expected_contents)
<< physical_filename << " needs to be regenerated. Please run "
"generate_descriptor_proto.sh. Then add this file "
"to your CL.";
@@ -102,15 +98,13 @@ class MockGeneratorContext : public GeneratorContext {
// implements GeneratorContext --------------------------------------
virtual io::ZeroCopyOutputStream* Open(const string& filename) {
- string** map_slot = &files_[filename];
- delete *map_slot;
- *map_slot = new string;
-
- return new io::StringOutputStream(*map_slot);
+ auto& map_slot = files_[filename];
+ map_slot.reset(new std::string);
+ return new io::StringOutputStream(map_slot.get());
}
private:
- std::map<string, string*> files_;
+ std::map<std::string, std::unique_ptr<std::string>> files_;
};
class GenerateAndTest {
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
index d4a4d708f..7bc585e9b 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -192,27 +192,21 @@ FileGenerator::FileGenerator(const FileDescriptor *file, const Options& options)
options_(options) {
for (int i = 0; i < file_->enum_type_count(); i++) {
EnumGenerator *generator = new EnumGenerator(file_->enum_type(i));
- enum_generators_.push_back(generator);
+ enum_generators_.emplace_back(generator);
}
for (int i = 0; i < file_->message_type_count(); i++) {
MessageGenerator *generator =
new MessageGenerator(root_class_name_, file_->message_type(i), options_);
- message_generators_.push_back(generator);
+ message_generators_.emplace_back(generator);
}
for (int i = 0; i < file_->extension_count(); i++) {
ExtensionGenerator *generator =
new ExtensionGenerator(root_class_name_, file_->extension(i));
- extension_generators_.push_back(generator);
+ extension_generators_.emplace_back(generator);
}
}
-FileGenerator::~FileGenerator() {
- STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end());
- STLDeleteContainerPointers(message_generators_.begin(),
- message_generators_.end());
- STLDeleteContainerPointers(extension_generators_.begin(),
- extension_generators_.end());
-}
+FileGenerator::~FileGenerator() {}
void FileGenerator::GenerateHeader(io::Printer *printer) {
std::set<string> headers;
@@ -270,9 +264,8 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
"\n");
std::set<string> fwd_decls;
- for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- (*iter)->DetermineForwardDeclarations(&fwd_decls);
+ for (const auto& generator : message_generators_) {
+ generator->DetermineForwardDeclarations(&fwd_decls);
}
for (std::set<string>::const_iterator i(fwd_decls.begin());
i != fwd_decls.end(); ++i) {
@@ -287,14 +280,12 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
"\n");
// need to write out all enums first
- for (std::vector<EnumGenerator *>::iterator iter = enum_generators_.begin();
- iter != enum_generators_.end(); ++iter) {
- (*iter)->GenerateHeader(printer);
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateHeader(printer);
}
- for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- (*iter)->GenerateEnumHeader(printer);
+ for (const auto& generator : message_generators_) {
+ generator->GenerateEnumHeader(printer);
}
// For extensions to chain together, the Root gets created even if there
@@ -323,18 +314,15 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
"@interface $root_class_name$ (DynamicMethods)\n",
"root_class_name", root_class_name_);
- for (std::vector<ExtensionGenerator *>::iterator iter =
- extension_generators_.begin();
- iter != extension_generators_.end(); ++iter) {
- (*iter)->GenerateMembersHeader(printer);
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateMembersHeader(printer);
}
printer->Print("@end\n\n");
} // extension_generators_.size() > 0
- for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- (*iter)->GenerateMessageHeader(printer);
+ for (const auto& generator : message_generators_) {
+ generator->GenerateMessageHeader(printer);
}
printer->Print(
@@ -403,9 +391,8 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
}
bool includes_oneof = false;
- for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- if ((*iter)->IncludesOneOfDefinition()) {
+ for (const auto& generator : message_generators_) {
+ if (generator->IncludesOneOfDefinition()) {
includes_oneof = true;
break;
}
@@ -456,15 +443,11 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
printer->Print(
"static GPBExtensionDescription descriptions[] = {\n");
printer->Indent();
- for (std::vector<ExtensionGenerator *>::iterator iter =
- extension_generators_.begin();
- iter != extension_generators_.end(); ++iter) {
- (*iter)->GenerateStaticVariablesInitialization(printer);
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateStaticVariablesInitialization(printer);
}
- for (std::vector<MessageGenerator *>::iterator iter =
- message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- (*iter)->GenerateStaticVariablesInitialization(printer);
+ for (const auto& generator : message_generators_) {
+ generator->GenerateStaticVariablesInitialization(printer);
}
printer->Outdent();
printer->Print(
@@ -561,13 +544,11 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
"\n");
}
- for (std::vector<EnumGenerator *>::iterator iter = enum_generators_.begin();
- iter != enum_generators_.end(); ++iter) {
- (*iter)->GenerateSource(printer);
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateSource(printer);
}
- for (std::vector<MessageGenerator *>::iterator iter = message_generators_.begin();
- iter != message_generators_.end(); ++iter) {
- (*iter)->GenerateSource(printer);
+ for (const auto& generator : message_generators_) {
+ generator->GenerateSource(printer);
}
printer->Print(
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.h b/src/google/protobuf/compiler/objectivec/objectivec_file.h
index ed7fad80a..fd5726348 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_file.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_file.h
@@ -65,9 +65,9 @@ class FileGenerator {
string root_class_name_;
bool is_bundled_proto_;
- std::vector<EnumGenerator*> enum_generators_;
- std::vector<MessageGenerator*> message_generators_;
- std::vector<ExtensionGenerator*> extension_generators_;
+ std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
+ std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
+ std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
const Options options_;
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
index a9e845397..6731e37a7 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -184,18 +184,18 @@ MessageGenerator::MessageGenerator(const string& root_classname,
GetOptionalDeprecatedAttribute(descriptor, descriptor->file(), false, true)) {
for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_.push_back(
+ extension_generators_.emplace_back(
new ExtensionGenerator(class_name_, descriptor_->extension(i)));
}
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
OneofGenerator* generator = new OneofGenerator(descriptor_->oneof_decl(i));
- oneof_generators_.push_back(generator);
+ oneof_generators_.emplace_back(generator);
}
for (int i = 0; i < descriptor_->enum_type_count(); i++) {
EnumGenerator* generator = new EnumGenerator(descriptor_->enum_type(i));
- enum_generators_.push_back(generator);
+ enum_generators_.emplace_back(generator);
}
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -203,32 +203,20 @@ MessageGenerator::MessageGenerator(const string& root_classname,
new MessageGenerator(root_classname_,
descriptor_->nested_type(i),
options);
- nested_message_generators_.push_back(generator);
+ nested_message_generators_.emplace_back(generator);
}
}
-MessageGenerator::~MessageGenerator() {
- STLDeleteContainerPointers(extension_generators_.begin(),
- extension_generators_.end());
- STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end());
- STLDeleteContainerPointers(nested_message_generators_.begin(),
- nested_message_generators_.end());
- STLDeleteContainerPointers(oneof_generators_.begin(),
- oneof_generators_.end());
-}
+MessageGenerator::~MessageGenerator() {}
void MessageGenerator::GenerateStaticVariablesInitialization(
io::Printer* printer) {
- for (std::vector<ExtensionGenerator*>::iterator iter =
- extension_generators_.begin();
- iter != extension_generators_.end(); ++iter) {
- (*iter)->GenerateStaticVariablesInitialization(printer);
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateStaticVariablesInitialization(printer);
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateStaticVariablesInitialization(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateStaticVariablesInitialization(printer);
}
}
@@ -241,10 +229,8 @@ void MessageGenerator::DetermineForwardDeclarations(std::set<string>* fwd_decls)
}
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->DetermineForwardDeclarations(fwd_decls);
+ for (const auto& generator : nested_message_generators_) {
+ generator->DetermineForwardDeclarations(fwd_decls);
}
}
@@ -253,10 +239,8 @@ bool MessageGenerator::IncludesOneOfDefinition() const {
return true;
}
- for (std::vector<MessageGenerator*>::const_iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- if ((*iter)->IncludesOneOfDefinition()) {
+ for (const auto& generator : nested_message_generators_) {
+ if (generator->IncludesOneOfDefinition()) {
return true;
}
}
@@ -265,40 +249,31 @@ bool MessageGenerator::IncludesOneOfDefinition() const {
}
void MessageGenerator::GenerateEnumHeader(io::Printer* printer) {
- for (std::vector<EnumGenerator*>::iterator iter = enum_generators_.begin();
- iter != enum_generators_.end(); ++iter) {
- (*iter)->GenerateHeader(printer);
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateHeader(printer);
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateEnumHeader(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateEnumHeader(printer);
}
}
void MessageGenerator::GenerateExtensionRegistrationSource(
io::Printer* printer) {
- for (std::vector<ExtensionGenerator*>::iterator iter =
- extension_generators_.begin();
- iter != extension_generators_.end(); ++iter) {
- (*iter)->GenerateRegistrationSource(printer);
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateRegistrationSource(printer);
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateExtensionRegistrationSource(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateExtensionRegistrationSource(printer);
}
}
void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
// This a a map entry message, just recurse and do nothing directly.
if (IsMapEntryMessage(descriptor_)) {
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateMessageHeader(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateMessageHeader(printer);
}
return;
}
@@ -325,9 +300,8 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
printer->Print("};\n\n");
}
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- (*iter)->GenerateCaseEnum(printer);
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateCaseEnum(printer);
}
string message_comments;
@@ -366,9 +340,8 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
}
if (!oneof_generators_.empty()) {
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- (*iter)->GenerateClearFunctionDeclaration(printer);
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateClearFunctionDeclaration(printer);
}
printer->Print("\n");
}
@@ -376,18 +349,14 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
if (descriptor_->extension_count() > 0) {
printer->Print("@interface $classname$ (DynamicMethods)\n\n",
"classname", class_name_);
- for (std::vector<ExtensionGenerator*>::iterator iter =
- extension_generators_.begin();
- iter != extension_generators_.end(); ++iter) {
- (*iter)->GenerateMembersHeader(printer);
+ for (const auto& generator : extension_generators_) {
+ generator->GenerateMembersHeader(printer);
}
printer->Print("@end\n\n");
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateMessageHeader(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateMessageHeader(printer);
}
}
@@ -409,9 +378,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
printer->Print("@implementation $classname$\n\n",
"classname", class_name_);
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- (*iter)->GeneratePropertyImplementation(printer);
+ for (const auto& generator : oneof_generators_) {
+ generator->GeneratePropertyImplementation(printer);
}
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -447,9 +415,8 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
sizeof_has_storage = 1;
}
// Tell all the fields the oneof base.
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- (*iter)->SetOneofIndexBase(sizeof_has_storage);
+ for (const auto& generator : oneof_generators_) {
+ generator->SetOneofIndexBase(sizeof_has_storage);
}
field_generators_.SetOneofIndexBase(sizeof_has_storage);
// sizeof_has_storage needs enough bits for the single fields that aren't in
@@ -547,11 +514,9 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
if (oneof_generators_.size() != 0) {
printer->Print(
" static const char *oneofs[] = {\n");
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- printer->Print(
- " \"$name$\",\n",
- "name", (*iter)->DescriptorName());
+ for (const auto& generator : oneof_generators_) {
+ printer->Print(" \"$name$\",\n", "name",
+ generator->DescriptorName());
}
printer->Print(
" };\n"
@@ -624,21 +589,17 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
.GenerateCFunctionImplementations(printer);
}
- for (std::vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
- iter != oneof_generators_.end(); ++iter) {
- (*iter)->GenerateClearFunctionImplementation(printer);
+ for (const auto& generator : oneof_generators_) {
+ generator->GenerateClearFunctionImplementation(printer);
}
}
- for (std::vector<EnumGenerator*>::iterator iter = enum_generators_.begin();
- iter != enum_generators_.end(); ++iter) {
- (*iter)->GenerateSource(printer);
+ for (const auto& generator : enum_generators_) {
+ generator->GenerateSource(printer);
}
- for (std::vector<MessageGenerator*>::iterator iter =
- nested_message_generators_.begin();
- iter != nested_message_generators_.end(); ++iter) {
- (*iter)->GenerateSource(printer);
+ for (const auto& generator : nested_message_generators_) {
+ generator->GenerateSource(printer);
}
}
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.h b/src/google/protobuf/compiler/objectivec/objectivec_message.h
index 1d41628f6..55eda0b8e 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_message.h
+++ b/src/google/protobuf/compiler/objectivec/objectivec_message.h
@@ -85,10 +85,10 @@ class MessageGenerator {
FieldGeneratorMap field_generators_;
const string class_name_;
const string deprecated_attribute_;
- std::vector<ExtensionGenerator*> extension_generators_;
- std::vector<EnumGenerator*> enum_generators_;
- std::vector<MessageGenerator*> nested_message_generators_;
- std::vector<OneofGenerator*> oneof_generators_;
+ std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
+ std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
+ std::vector<std::unique_ptr<MessageGenerator>> nested_message_generators_;
+ std::vector<std::unique_ptr<OneofGenerator>> oneof_generators_;
};
} // namespace objectivec
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc
index c47ea33f7..232db80b5 100644
--- a/src/google/protobuf/compiler/php/php_generator.cc
+++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -655,88 +655,50 @@ void GenerateOneofField(const OneofDescriptor* oneof, io::Printer* printer) {
void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
io::Printer* printer) {
- bool need_other_name_for_accessor = false;
- bool need_other_name_for_wrapper_accessor = false;
- const Descriptor* desc = field->containing_type();
-
- if (!field->is_repeated() &&
- field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- IsWrapperType(field)) {
- // Check if there is any field called xxx_value
- const FieldDescriptor* other =
- desc->FindFieldByName(StrCat(field->name(), "_value"));
- if (other != NULL) {
- need_other_name_for_wrapper_accessor = true;
- }
- }
-
- if (strings::EndsWith(field->name(), "_value")) {
- std::size_t pos = (field->name()).find("_value");
- string name = (field->name()).substr(0, pos);
- const FieldDescriptor* other = desc->FindFieldByName(name);
- if (other != NULL &&
- !other->is_repeated() &&
- other->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- IsWrapperType(other)) {
- need_other_name_for_accessor = true;
- }
- }
-
const OneofDescriptor* oneof = field->containing_oneof();
// Generate getter.
if (oneof != NULL) {
GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter);
printer->Print(
- "public function get^camel_name^^field_number^()\n"
+ "public function get^camel_name^()\n"
"{\n"
" return $this->readOneof(^number^);\n"
"}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true),
- "number", IntToString(field->number()),
- "field_number", need_other_name_for_accessor ?
- StrCat(field->number()) : "");
+ "number", IntToString(field->number()));
} else {
GenerateFieldDocComment(printer, field, is_descriptor, kFieldGetter);
printer->Print(
- "public function get^camel_name^^field_number^()\n"
+ "public function get^camel_name^()\n"
"{\n"
" return $this->^name^;\n"
"}\n\n",
- "camel_name", UnderscoresToCamelCase(field->name(), true),
- "name", field->name(),
- "field_number", need_other_name_for_accessor ?
- StrCat(field->number()) : "");
+ "camel_name", UnderscoresToCamelCase(field->name(), true), "name",
+ field->name());
}
- // For wrapper types, generate an additional getXXXValue getter
+ // For wrapper types, generate an additional getXXXUnwrapped getter
if (!field->is_map() &&
!field->is_repeated() &&
field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
IsWrapperType(field)) {
GenerateWrapperFieldGetterDocComment(printer, field);
-
printer->Print(
- "public function get^camel_name^Value^field_number1^()\n"
+ "public function get^camel_name^Unwrapped()\n"
"{\n"
- " $wrapper = $this->get^camel_name^^field_number2^();\n"
+ " $wrapper = $this->get^camel_name^();\n"
" return is_null($wrapper) ? null : $wrapper->getValue();\n"
"}\n\n",
- "camel_name", UnderscoresToCamelCase(field->name(), true),
- "field_number1", need_other_name_for_wrapper_accessor ?
- StrCat(field->number()) : "",
- "field_number2", need_other_name_for_accessor ?
- StrCat(field->number()) : "");
+ "camel_name", UnderscoresToCamelCase(field->name(), true));
}
// Generate setter.
GenerateFieldDocComment(printer, field, is_descriptor, kFieldSetter);
printer->Print(
- "public function set^camel_name^^field_number^($var)\n"
+ "public function set^camel_name^($var)\n"
"{\n",
- "camel_name", UnderscoresToCamelCase(field->name(), true),
- "field_number", need_other_name_for_accessor ?
- StrCat(field->number()) : "");
+ "camel_name", UnderscoresToCamelCase(field->name(), true));
Indent(printer);
@@ -836,17 +798,13 @@ void GenerateFieldAccessor(const FieldDescriptor* field, bool is_descriptor,
IsWrapperType(field)) {
GenerateWrapperFieldSetterDocComment(printer, field);
printer->Print(
- "public function set^camel_name^Value^field_number1^($var)\n"
+ "public function set^camel_name^Unwrapped($var)\n"
"{\n"
" $wrappedVar = is_null($var) ? null : new \\^wrapper_type^(['value' => $var]);\n"
- " return $this->set^camel_name^^field_number2^($wrappedVar);\n"
+ " return $this->set^camel_name^($wrappedVar);\n"
"}\n\n",
"camel_name", UnderscoresToCamelCase(field->name(), true),
- "wrapper_type", LegacyFullClassName(field->message_type(), is_descriptor),
- "field_number1", need_other_name_for_wrapper_accessor ?
- StrCat(field->number()) : "",
- "field_number2", need_other_name_for_accessor ?
- StrCat(field->number()) : "");
+ "wrapper_type", LegacyFullClassName(field->message_type(), is_descriptor));
}
// Generate has method for proto2 only.
@@ -1307,7 +1265,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
}
printer.Print(
- "class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
+ "final class ^name^ extends \\Google\\Protobuf\\Internal\\Message\n"
"{\n",
"name", fullname);
Indent(&printer);