Sync from Piper @364389596
PROTOBUF_SYNC_PIPER
This commit is contained in:
parent
9df42757f9
commit
96307d28f6
4
.github/mergeable.yml
vendored
4
.github/mergeable.yml
vendored
@ -11,8 +11,8 @@ mergeable:
|
||||
regex: 'release notes: yes'
|
||||
message: 'Please include release notes: yes'
|
||||
- must_include:
|
||||
regex: '^(c#|c\+\+|cleanup|conformance tests|integration|java|javascript|go|objective-c|php|python|ruby|bazel|cmake|protoc)'
|
||||
message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: bazel, cmake, cleanup, conformance tests, integration, protoc.'
|
||||
regex: '^(autotools|bazel|c#|c\+\+|cleanup|cmake|conformance tests|integration|go|java|javascript|objective-c|php|protoc|python|ruby)'
|
||||
message: 'Please include at least a language label (e.g., c++, java, python). Or apply one of the following labels: autotools, bazel, cmake, cleanup, conformance tests, integration, protoc.'
|
||||
- must_include:
|
||||
regex: 'release notes: no'
|
||||
message: 'Please include release notes: no'
|
||||
|
44
BUILD
44
BUILD
@ -14,38 +14,6 @@ exports_files(["LICENSE"])
|
||||
# build configuration
|
||||
################################################################################
|
||||
|
||||
# TODO(yannic): Remove in 3.14.0.
|
||||
string_flag(
|
||||
name = "incompatible_use_com_google_googletest",
|
||||
build_setting_default = "true",
|
||||
values = ["true", "false"]
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "use_com_google_googletest",
|
||||
flag_values = {
|
||||
"//:incompatible_use_com_google_googletest": "true"
|
||||
},
|
||||
)
|
||||
|
||||
GTEST = select({
|
||||
"//:use_com_google_googletest": [
|
||||
"@com_google_googletest//:gtest",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"//external:gtest",
|
||||
],
|
||||
})
|
||||
|
||||
GTEST_MAIN = select({
|
||||
"//:use_com_google_googletest": [
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"//external:gtest_main",
|
||||
],
|
||||
})
|
||||
|
||||
################################################################################
|
||||
# ZLIB configuration
|
||||
################################################################################
|
||||
@ -571,6 +539,7 @@ COMMON_TEST_SRCS = [
|
||||
|
||||
cc_binary(
|
||||
name = "test_plugin",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
# AUTOGEN(test_plugin_srcs)
|
||||
"src/google/protobuf/compiler/mock_code_generator.cc",
|
||||
@ -580,7 +549,8 @@ cc_binary(
|
||||
deps = [
|
||||
":protobuf",
|
||||
":protoc_lib",
|
||||
] + GTEST,
|
||||
"@com_google_googletest//:gtest",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
@ -592,7 +562,9 @@ cc_test(
|
||||
],
|
||||
deps = [
|
||||
":protobuf_lite",
|
||||
] + GTEST_MAIN,
|
||||
"@com_google_googletest//:gtest",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
@ -695,7 +667,9 @@ cc_test(
|
||||
":cc_test_protos",
|
||||
":protobuf",
|
||||
":protoc_lib",
|
||||
] + PROTOBUF_DEPS + GTEST_MAIN,
|
||||
"@com_google_googletest//:gtest",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
] + PROTOBUF_DEPS,
|
||||
)
|
||||
|
||||
################################################################################
|
||||
|
43
CHANGES.txt
43
CHANGES.txt
@ -1,3 +1,46 @@
|
||||
Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
C++
|
||||
* Allow MessageDifferencer::TreatAsSet() (and friends) to override previous
|
||||
calls instead of crashing.
|
||||
* Reduce the size of generated proto headers for protos with `string` or
|
||||
`bytes` fields.
|
||||
* Move arena() operation on uncommon path to out-of-line routine
|
||||
* For iterator-pair function parameter types, take both iterators by value.
|
||||
* Code-space savings and perhaps some modest performance improvements in
|
||||
RepeatedPtrField.
|
||||
|
||||
Java:
|
||||
* Exceptions thrown while reading from an InputStream in parseFrom are now included as causes.
|
||||
|
||||
2021-03-10 version 3.15.6 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
Ruby
|
||||
* Fixed bug in string comparison logic (#8386)
|
||||
|
||||
2021-03-04 version 3.15.5 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
Ruby
|
||||
* Fixed quadratic memory use in array append (#8379)
|
||||
|
||||
PHP
|
||||
* Fixed quadratic memory use in array append (#8379)
|
||||
|
||||
C++
|
||||
* Do not disable RTTI by default in the CMake build (#8377)
|
||||
|
||||
2021-03-02 version 3.15.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
Ruby
|
||||
* Fixed SEGV when users pass nil messages (#8363)
|
||||
* Fixed quadratic memory usage when appending to arrays (#8364)
|
||||
|
||||
C++
|
||||
* Create a CMake option to control whether or not RTTI is enabled (#8361)
|
||||
|
||||
PHP
|
||||
* read_property() handler is not supposed to return NULL (#8362)
|
||||
|
||||
2021-02-25 version 3.15.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
Ruby
|
||||
|
@ -529,7 +529,6 @@ java_EXTRA_DIST=
|
||||
java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \
|
||||
java/core/src/test/proto/com/google/protobuf/wrappers_test.proto \
|
||||
java/lite.md \
|
||||
java/lite/BUILD \
|
||||
|
@ -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.15.3'
|
||||
s.version = '3.15.6'
|
||||
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
|
||||
s.homepage = 'https://github.com/protocolbuffers/protobuf'
|
||||
s.license = '3-Clause BSD License'
|
||||
|
21
WORKSPACE
21
WORKSPACE
@ -17,6 +17,15 @@ http_archive(
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "com_github_google_benchmark",
|
||||
sha256 = "2a778d821997df7d8646c9c59b8edb9a573a6e04c534c01892a40aa524a7b68c",
|
||||
strip_prefix = "benchmark-bf585a2789e30585b4e3ce6baf11ef2750b54677",
|
||||
urls = [
|
||||
"https://github.com/google/benchmark/archive/bf585a2789e30585b4e3ce6baf11ef2750b54677.zip",
|
||||
],
|
||||
)
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("//:protobuf_deps.bzl", "protobuf_deps")
|
||||
|
||||
@ -29,18 +38,6 @@ bind(
|
||||
actual = "//util/python:python_headers",
|
||||
)
|
||||
|
||||
# TODO(yannic): Remove in 3.14.0.
|
||||
bind(
|
||||
name = "gtest",
|
||||
actual = "@com_google_googletest//:gtest",
|
||||
)
|
||||
|
||||
# TODO(yannic): Remove in 3.14.0.
|
||||
bind(
|
||||
name = "gtest_main",
|
||||
actual = "@com_google_googletest//:gtest_main",
|
||||
)
|
||||
|
||||
jvm_maven_import_external(
|
||||
name = "guava_maven",
|
||||
artifact = "com.google.guava:guava:18.0",
|
||||
|
65
benchmarks/BUILD
Normal file
65
benchmarks/BUILD
Normal file
@ -0,0 +1,65 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "benchmarks_proto",
|
||||
srcs = [
|
||||
"benchmarks.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmarks_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"benchmarks_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmarks_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"benchmarks_proto",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "google_size_proto",
|
||||
srcs = [
|
||||
"google_size.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "google_size_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"google_size_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "google_size_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"google_size_proto",
|
||||
],
|
||||
)
|
15
benchmarks/cpp/BUILD
Normal file
15
benchmarks/cpp/BUILD
Normal file
@ -0,0 +1,15 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
|
||||
cc_binary(
|
||||
name = "cpp",
|
||||
srcs = [
|
||||
"cpp_benchmark.cc",
|
||||
],
|
||||
tags = ["benchmark"],
|
||||
deps = [
|
||||
"//:protobuf",
|
||||
"//benchmarks:benchmarks_cc_proto",
|
||||
"//benchmarks/datasets:cc_protos",
|
||||
"@com_github_google_benchmark//:benchmark_main",
|
||||
],
|
||||
)
|
59
benchmarks/datasets/BUILD
Normal file
59
benchmarks/datasets/BUILD
Normal file
@ -0,0 +1,59 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("@rules_java//java:defs.bzl", "java_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [
|
||||
"//benchmarks/datasets/google_message1/proto2:datasets",
|
||||
"//benchmarks/datasets/google_message1/proto3:datasets",
|
||||
"//benchmarks/datasets/google_message2:datasets",
|
||||
"//benchmarks/datasets/google_message3:datasets",
|
||||
"//benchmarks/datasets/google_message4:datasets",
|
||||
],
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "protos",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_proto",
|
||||
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_proto",
|
||||
"//benchmarks/datasets/google_message2:benchmark_message2_proto",
|
||||
"//benchmarks/datasets/google_message3:benchmark_message3_proto",
|
||||
"//benchmarks/datasets/google_message4:benchmark_message4_proto",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "cc_protos",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_cc_proto",
|
||||
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_cc_proto",
|
||||
"//benchmarks/datasets/google_message2:benchmark_message2_cc_proto",
|
||||
"//benchmarks/datasets/google_message3:benchmark_message3_cc_proto",
|
||||
"//benchmarks/datasets/google_message4:benchmark_message4_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "java_protos",
|
||||
visibility = [
|
||||
"//benchmarks:__subpackages__",
|
||||
],
|
||||
exports = [
|
||||
"//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_java_proto",
|
||||
"//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_java_proto",
|
||||
"//benchmarks/datasets/google_message2:benchmark_message2_java_proto",
|
||||
"//benchmarks/datasets/google_message3:benchmark_message3_java_proto",
|
||||
"//benchmarks/datasets/google_message4:benchmark_message4_java_proto",
|
||||
],
|
||||
)
|
44
benchmarks/datasets/google_message1/proto2/BUILD
Normal file
44
benchmarks/datasets/google_message1/proto2/BUILD
Normal file
@ -0,0 +1,44 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [
|
||||
"dataset.google_message1_proto2.pb",
|
||||
],
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "benchmark_message1_proto2_proto",
|
||||
srcs = [
|
||||
"benchmark_message1_proto2.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmark_message1_proto2_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message1_proto2_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmark_message1_proto2_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message1_proto2_proto",
|
||||
],
|
||||
)
|
44
benchmarks/datasets/google_message1/proto3/BUILD
Normal file
44
benchmarks/datasets/google_message1/proto3/BUILD
Normal file
@ -0,0 +1,44 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [
|
||||
"dataset.google_message1_proto3.pb",
|
||||
],
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "benchmark_message1_proto3_proto",
|
||||
srcs = [
|
||||
"benchmark_message1_proto3.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmark_message1_proto3_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message1_proto3_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmark_message1_proto3_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message1_proto3_proto",
|
||||
],
|
||||
)
|
44
benchmarks/datasets/google_message2/BUILD
Normal file
44
benchmarks/datasets/google_message2/BUILD
Normal file
@ -0,0 +1,44 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [
|
||||
"dataset.google_message2.pb",
|
||||
],
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "benchmark_message2_proto",
|
||||
srcs = [
|
||||
"benchmark_message2.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmark_message2_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message2_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmark_message2_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message2_proto",
|
||||
],
|
||||
)
|
50
benchmarks/datasets/google_message3/BUILD
Normal file
50
benchmarks/datasets/google_message3/BUILD
Normal file
@ -0,0 +1,50 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [],
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "benchmark_message3_proto",
|
||||
srcs = [
|
||||
"benchmark_message3.proto",
|
||||
"benchmark_message3_1.proto",
|
||||
"benchmark_message3_2.proto",
|
||||
"benchmark_message3_3.proto",
|
||||
"benchmark_message3_4.proto",
|
||||
"benchmark_message3_5.proto",
|
||||
"benchmark_message3_6.proto",
|
||||
"benchmark_message3_7.proto",
|
||||
"benchmark_message3_8.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmark_message3_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message3_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmark_message3_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message3_proto",
|
||||
],
|
||||
)
|
45
benchmarks/datasets/google_message4/BUILD
Normal file
45
benchmarks/datasets/google_message4/BUILD
Normal file
@ -0,0 +1,45 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
|
||||
load("@rules_java//java:defs.bzl", "java_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
|
||||
filegroup(
|
||||
name = "datasets",
|
||||
srcs = [],
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "benchmark_message4_proto",
|
||||
srcs = [
|
||||
"benchmark_message4.proto",
|
||||
"benchmark_message4_1.proto",
|
||||
"benchmark_message4_2.proto",
|
||||
"benchmark_message4_3.proto",
|
||||
],
|
||||
strip_import_prefix = "/benchmarks",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "benchmark_message4_cc_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message4_proto",
|
||||
],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "benchmark_message4_java_proto",
|
||||
visibility = [
|
||||
"//benchmarks/datasets:__pkg__",
|
||||
],
|
||||
deps = [
|
||||
"benchmark_message4_proto",
|
||||
],
|
||||
)
|
@ -451,6 +451,27 @@ void TextFormatConformanceTestSuite::RunSuiteImpl() {
|
||||
}
|
||||
)",
|
||||
prototype);
|
||||
|
||||
prototype.Clear();
|
||||
ConformanceRequestSetting setting_map(
|
||||
REQUIRED, conformance::TEXT_FORMAT, conformance::PROTOBUF,
|
||||
conformance::TEXT_FORMAT_TEST, prototype, "DuplicateMapKey", R"(
|
||||
map_string_nested_message {
|
||||
key: "duplicate"
|
||||
value: { a: 123 }
|
||||
}
|
||||
map_string_nested_message {
|
||||
key: "duplicate"
|
||||
value: { corecursive: {} }
|
||||
}
|
||||
)");
|
||||
// The last-specified value will be retained in a parsed map
|
||||
RunValidInputTest(setting_map, R"(
|
||||
map_string_nested_message {
|
||||
key: "duplicate"
|
||||
value: { corecursive: {} }
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace protobuf
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>Google Protocol Buffers tools</title>
|
||||
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
||||
<description>See project site for more info.</description>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
<authors>Google Inc.</authors>
|
||||
<owners>protobuf-packages</owners>
|
||||
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
|
||||
|
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
|
||||
<Copyright>Copyright 2015, Google Inc.</Copyright>
|
||||
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
|
||||
<VersionPrefix>3.15.3</VersionPrefix>
|
||||
<VersionPrefix>3.15.6</VersionPrefix>
|
||||
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
|
||||
<LangVersion>7.2</LangVersion>
|
||||
<Authors>Google Inc.</Authors>
|
||||
|
@ -107,57 +107,58 @@ namespace Google.Protobuf.Reflection {
|
||||
"eV9wYWNrYWdlGC0gASgJEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMo",
|
||||
"CzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uIjoKDE9w",
|
||||
"dGltaXplTW9kZRIJCgVTUEVFRBABEg0KCUNPREVfU0laRRACEhAKDExJVEVf",
|
||||
"UlVOVElNRRADKgkI6AcQgICAgAJKBAgmECci8gEKDk1lc3NhZ2VPcHRpb25z",
|
||||
"UlVOVElNRRADKgkI6AcQgICAgAJKBAgmECcihAIKDk1lc3NhZ2VPcHRpb25z",
|
||||
"EiYKF21lc3NhZ2Vfc2V0X3dpcmVfZm9ybWF0GAEgASgIOgVmYWxzZRIuCh9u",
|
||||
"b19zdGFuZGFyZF9kZXNjcmlwdG9yX2FjY2Vzc29yGAIgASgIOgVmYWxzZRIZ",
|
||||
"CgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRIRCgltYXBfZW50cnkYByABKAgS",
|
||||
"QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAkoECAgQCUoECAkQ",
|
||||
"CiKeAwoMRmllbGRPcHRpb25zEjoKBWN0eXBlGAEgASgOMiMuZ29vZ2xlLnBy",
|
||||
"b3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlwZToGU1RSSU5HEg4KBnBhY2tlZBgC",
|
||||
"IAEoCBI/CgZqc3R5cGUYBiABKA4yJC5nb29nbGUucHJvdG9idWYuRmllbGRP",
|
||||
"cHRpb25zLkpTVHlwZToJSlNfTk9STUFMEhMKBGxhenkYBSABKAg6BWZhbHNl",
|
||||
"EhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNlEhMKBHdlYWsYCiABKAg6BWZh",
|
||||
"bHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5w",
|
||||
"cm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uIi8KBUNUeXBlEgoKBlNUUklO",
|
||||
"RxAAEggKBENPUkQQARIQCgxTVFJJTkdfUElFQ0UQAiI1CgZKU1R5cGUSDQoJ",
|
||||
"SlNfTk9STUFMEAASDQoJSlNfU1RSSU5HEAESDQoJSlNfTlVNQkVSEAIqCQjo",
|
||||
"BxCAgICAAkoECAQQBSJeCgxPbmVvZk9wdGlvbnMSQwoUdW5pbnRlcnByZXRl",
|
||||
"ZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0",
|
||||
"ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoLRW51bU9wdGlvbnMSEwoLYWxsb3df",
|
||||
"YWxpYXMYAiABKAgSGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USQwoUdW5p",
|
||||
"bnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVu",
|
||||
"aW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAkoECAUQBiJ9ChBFbnVtVmFs",
|
||||
"dWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQYASABKAg6BWZhbHNlEkMKFHVuaW50",
|
||||
"ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu",
|
||||
"dGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIiewoOU2VydmljZU9wdGlvbnMS",
|
||||
"GQoKZGVwcmVjYXRlZBghIAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9v",
|
||||
"cHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRP",
|
||||
"cHRpb24qCQjoBxCAgICAAiKtAgoNTWV0aG9kT3B0aW9ucxIZCgpkZXByZWNh",
|
||||
"dGVkGCEgASgIOgVmYWxzZRJfChFpZGVtcG90ZW5jeV9sZXZlbBgiIAEoDjIv",
|
||||
"Lmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRpb25zLklkZW1wb3RlbmN5TGV2",
|
||||
"ZWw6E0lERU1QT1RFTkNZX1VOS05PV04SQwoUdW5pbnRlcnByZXRlZF9vcHRp",
|
||||
"b24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRp",
|
||||
"b24iUAoQSWRlbXBvdGVuY3lMZXZlbBIXChNJREVNUE9URU5DWV9VTktOT1dO",
|
||||
"EAASEwoPTk9fU0lERV9FRkZFQ1RTEAESDgoKSURFTVBPVEVOVBACKgkI6AcQ",
|
||||
"gICAgAIingIKE1VuaW50ZXJwcmV0ZWRPcHRpb24SOwoEbmFtZRgCIAMoCzIt",
|
||||
"Lmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uLk5hbWVQYXJ0",
|
||||
"EhgKEGlkZW50aWZpZXJfdmFsdWUYAyABKAkSGgoScG9zaXRpdmVfaW50X3Zh",
|
||||
"bHVlGAQgASgEEhoKEm5lZ2F0aXZlX2ludF92YWx1ZRgFIAEoAxIUCgxkb3Vi",
|
||||
"bGVfdmFsdWUYBiABKAESFAoMc3RyaW5nX3ZhbHVlGAcgASgMEhcKD2FnZ3Jl",
|
||||
"Z2F0ZV92YWx1ZRgIIAEoCRozCghOYW1lUGFydBIRCgluYW1lX3BhcnQYASAC",
|
||||
"KAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigIItUBCg5Tb3VyY2VDb2RlSW5mbxI6",
|
||||
"Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2dsZS5wcm90b2J1Zi5Tb3VyY2VDb2Rl",
|
||||
"SW5mby5Mb2NhdGlvbhqGAQoITG9jYXRpb24SEAoEcGF0aBgBIAMoBUICEAES",
|
||||
"EAoEc3BhbhgCIAMoBUICEAESGAoQbGVhZGluZ19jb21tZW50cxgDIAEoCRIZ",
|
||||
"ChF0cmFpbGluZ19jb21tZW50cxgEIAEoCRIhChlsZWFkaW5nX2RldGFjaGVk",
|
||||
"X2NvbW1lbnRzGAYgAygJIqcBChFHZW5lcmF0ZWRDb2RlSW5mbxJBCgphbm5v",
|
||||
"dGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3RvYnVmLkdlbmVyYXRlZENvZGVJ",
|
||||
"bmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlvbhIQCgRwYXRoGAEgAygFQgIQ",
|
||||
"ARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgViZWdpbhgDIAEoBRILCgNlbmQY",
|
||||
"BCABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1ZkIQRGVzY3JpcHRvclByb3Rv",
|
||||
"c0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9kZXNjcmlw",
|
||||
"dG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJvdG9idWYuUmVmbGVjdGlvbg=="));
|
||||
"YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAkoECAQQBUoECAUQ",
|
||||
"BkoECAYQB0oECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0eXBl",
|
||||
"GAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlwZToG",
|
||||
"U1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5nb29n",
|
||||
"bGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFMEhMK",
|
||||
"BGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNl",
|
||||
"EhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9u",
|
||||
"GOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9u",
|
||||
"Ii8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdfUElF",
|
||||
"Q0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5HEAES",
|
||||
"DQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9wdGlv",
|
||||
"bnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy",
|
||||
"b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoLRW51",
|
||||
"bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRlZBgD",
|
||||
"IAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQu",
|
||||
"Z29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICA",
|
||||
"AkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQYASAB",
|
||||
"KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv",
|
||||
"b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi",
|
||||
"ewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFsc2US",
|
||||
"QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0aG9k",
|
||||
"T3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVtcG90",
|
||||
"ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRp",
|
||||
"b25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04SQwoU",
|
||||
"dW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVm",
|
||||
"LlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIXChNJ",
|
||||
"REVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAESDgoK",
|
||||
"SURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRPcHRp",
|
||||
"b24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJl",
|
||||
"dGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyABKAkS",
|
||||
"GgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2ludF92",
|
||||
"YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5nX3Zh",
|
||||
"bHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1lUGFy",
|
||||
"dBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigIItUB",
|
||||
"Cg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2dsZS5w",
|
||||
"cm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRpb24S",
|
||||
"EAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVhZGlu",
|
||||
"Z19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEoCRIh",
|
||||
"ChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5lcmF0",
|
||||
"ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlv",
|
||||
"bhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgVi",
|
||||
"ZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1",
|
||||
"ZkIQRGVzY3JpcHRvclByb3Rvc0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90",
|
||||
"b2J1Zi90eXBlcy9kZXNjcmlwdG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJv",
|
||||
"dG9idWYuUmVmbGVjdGlvbg=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
|
@ -261,7 +261,7 @@ bool FieldHasPresence(const google::protobuf::FieldDescriptor* field) {
|
||||
Old:
|
||||
|
||||
```c++
|
||||
bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) {
|
||||
bool FieldIsInOneof(const google::protobuf::FieldDescriptor* field) {
|
||||
return field->containing_oneof() != nullptr;
|
||||
}
|
||||
```
|
||||
@ -269,7 +269,7 @@ bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) {
|
||||
New:
|
||||
|
||||
```c++
|
||||
bool FieldIsInOneof(const google::protobuf::FielDescriptor* field) {
|
||||
bool FieldIsInOneof(const google::protobuf::FieldDescriptor* field) {
|
||||
// real_containing_oneof() returns nullptr for synthetic oneofs.
|
||||
return field->real_containing_oneof() != nullptr;
|
||||
}
|
||||
|
@ -268,3 +268,11 @@ with info about your project (name and website) so we can add an entry for you.
|
||||
1. Protoc-gen-sanitize
|
||||
* Website: https://github.com/Intrinsec/protoc-gen-sanitize
|
||||
* Extension: 1102-1106
|
||||
|
||||
1. Coach Client Connect (planned release in March 2021)
|
||||
* Website: https://www.coachclientconnect.com
|
||||
* Extension: 1107
|
||||
|
||||
1. Kratos API Errors
|
||||
* Website: https://go-kratos.dev
|
||||
* Extension: 1108
|
||||
|
@ -11,6 +11,7 @@ These are projects we know about implementing Protocol Buffers for other program
|
||||
* Action Script: https://code.google.com/p/protoc-gen-as3/
|
||||
* Action Script: https://github.com/matrix3d/JProtoc
|
||||
* Action Script: https://github.com/zhongfq/protobuf-as3/
|
||||
* Ada: https://github.com/reznikmm/protobuf
|
||||
* C: https://github.com/protobuf-c/protobuf-c
|
||||
* C: http://koti.kapsi.fi/jpa/nanopb/
|
||||
* C: https://github.com/cloudwu/pbc/
|
||||
@ -101,7 +102,6 @@ These are projects we know about implementing Protocol Buffers for other program
|
||||
* Solidity: https://github.com/celer-network/pb3-gen-sol
|
||||
* Swift: https://github.com/alexeyxo/protobuf-swift
|
||||
* Swift: https://github.com/apple/swift-protobuf/
|
||||
* Typescript: https://github.com/y3llowcake/protoc-gen-ts
|
||||
* Vala: https://launchpad.net/protobuf-vala
|
||||
* Visual Basic: http://code.google.com/p/protobuf-net/
|
||||
|
||||
|
@ -23,7 +23,7 @@ If you are using Maven, use the following:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.15.3</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@ -37,7 +37,7 @@ protobuf-java-util package:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<version>3.15.3</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-bom</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [BOM]</name>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
|
@ -1043,8 +1043,10 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a byte string. Its size is the current size of this output stream and its output has
|
||||
* been copied to it.
|
||||
* Creates a byte string with the size and contents of this output stream. This does not create
|
||||
* a new copy of the underlying bytes. If the stream size grows dynamically, the runtime is
|
||||
* O(log n) in respect to the number of bytes written to the {@link Output}. If the stream size
|
||||
* stays within the initial capacity, the runtime is O(1).
|
||||
*
|
||||
* @return the current contents of this output stream, as a byte string.
|
||||
*/
|
||||
|
@ -603,7 +603,12 @@ final class RopeByteString extends ByteString {
|
||||
|
||||
@Override
|
||||
public CodedInputStream newCodedInput() {
|
||||
return CodedInputStream.newInstance(new RopeInputStream());
|
||||
// Passing along direct references to internal ByteBuffers can support more efficient parsing
|
||||
// via aliasing in CodedInputStream for users who wish to use it.
|
||||
//
|
||||
// Otherwise we force data copies, both in copying as an input stream and in buffering in the
|
||||
// CodedInputSteam.
|
||||
return CodedInputStream.newInstance(asReadOnlyByteBufferList(), /* bufferIsImmutable= */ true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,7 +283,7 @@ public class AbstractMessageTest extends TestCase {
|
||||
Message.Builder abstractMessageBuilder =
|
||||
new AbstractMessageWrapper.Builder(TestRequiredForeign.newBuilder());
|
||||
// mergeFrom() should not throw initialization error.
|
||||
abstractMessageBuilder.mergeFrom(bytes).buildPartial();
|
||||
Message unused1 = abstractMessageBuilder.mergeFrom(bytes).buildPartial();
|
||||
try {
|
||||
abstractMessageBuilder.mergeFrom(bytes).build();
|
||||
fail();
|
||||
@ -295,7 +295,7 @@ public class AbstractMessageTest extends TestCase {
|
||||
Message.Builder dynamicMessageBuilder =
|
||||
DynamicMessage.newBuilder(TestRequiredForeign.getDescriptor());
|
||||
// mergeFrom() should not throw initialization error.
|
||||
dynamicMessageBuilder.mergeFrom(bytes).buildPartial();
|
||||
Message unused2 = dynamicMessageBuilder.mergeFrom(bytes).buildPartial();
|
||||
try {
|
||||
dynamicMessageBuilder.mergeFrom(bytes).build();
|
||||
fail();
|
||||
|
@ -69,7 +69,7 @@ public class DynamicMessageTest extends TestCase {
|
||||
Message.Builder builder = DynamicMessage.newBuilder(TestAllTypes.getDescriptor());
|
||||
Message firstMessage = builder.build();
|
||||
// double build()
|
||||
builder.build();
|
||||
Message unused = builder.build();
|
||||
// clear() after build()
|
||||
builder.clear();
|
||||
// setters after build()
|
||||
|
@ -76,6 +76,7 @@ import junit.framework.TestCase;
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
*/
|
||||
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
|
||||
public class GeneratedMessageTest extends TestCase {
|
||||
TestUtil.ReflectionTester reflectionTester =
|
||||
new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);
|
||||
|
@ -1163,8 +1163,8 @@ public class MapForProto2Test extends TestCase {
|
||||
}
|
||||
|
||||
public void testReservedWordsFieldNames() {
|
||||
ReservedAsMapField.newBuilder().build();
|
||||
ReservedAsMapFieldWithEnumValue.newBuilder().build();
|
||||
ReservedAsMapField unused1 = ReservedAsMapField.newBuilder().build();
|
||||
ReservedAsMapFieldWithEnumValue unused2 = ReservedAsMapFieldWithEnumValue.newBuilder().build();
|
||||
}
|
||||
|
||||
public void testGetMap() {
|
||||
|
@ -1294,8 +1294,8 @@ public class MapTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testReservedWordsFieldNames() {
|
||||
ReservedAsMapField.newBuilder().build();
|
||||
ReservedAsMapFieldWithEnumValue.newBuilder().build();
|
||||
ReservedAsMapField unused1 = ReservedAsMapField.newBuilder().build();
|
||||
ReservedAsMapFieldWithEnumValue unused2 = ReservedAsMapFieldWithEnumValue.newBuilder().build();
|
||||
}
|
||||
|
||||
public void testDeterministicSerialziation() throws Exception {
|
||||
|
@ -43,8 +43,10 @@ public class TestBadIdentifiers extends TestCase {
|
||||
|
||||
public void testCompilation() {
|
||||
// If this compiles, it means the generation was correct.
|
||||
TestBadIdentifiersProto.Deprecated.newBuilder();
|
||||
TestBadIdentifiersProto.Override.newBuilder();
|
||||
TestBadIdentifiersProto.Deprecated unused1 =
|
||||
TestBadIdentifiersProto.Deprecated.newBuilder().build();
|
||||
TestBadIdentifiersProto.Override unused2 =
|
||||
TestBadIdentifiersProto.Override.getDefaultInstance();
|
||||
}
|
||||
|
||||
public void testGetDescriptor() {
|
||||
|
@ -45,7 +45,9 @@ public final class TestBadIdentifiersLite extends TestCase {
|
||||
|
||||
public void testCompilation() {
|
||||
// If this compiles, it means the generation was correct.
|
||||
TestBadIdentifiersProto.Deprecated.Builder builder1 =
|
||||
TestBadIdentifiersProto.Deprecated.newBuilder();
|
||||
TestBadIdentifiersProto.Override.Builder builder2 =
|
||||
TestBadIdentifiersProto.Override.newBuilder();
|
||||
}
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: Darick Tong (darick@google.com)
|
||||
syntax = "proto2";
|
||||
|
||||
package protobuf_unittest;
|
||||
|
||||
message Proto1 {
|
||||
option experimental_java_message_interface =
|
||||
"com.google.protobuf.ExtraInterfaces.HasBoolValue";
|
||||
option experimental_java_message_interface =
|
||||
"com.google.protobuf.ExtraInterfaces.HasStringValue<Proto1>";
|
||||
option experimental_java_builder_interface =
|
||||
"com.google.protobuf.ExtraInterfaces.HasStringValueBuilder"
|
||||
"<Proto1, Builder>";
|
||||
|
||||
optional string string_value = 1;
|
||||
optional bool bool_value = 2;
|
||||
optional bytes byte_value = 3;
|
||||
optional int32 int_value = 4;
|
||||
}
|
||||
|
||||
message Proto2 {
|
||||
option experimental_java_message_interface =
|
||||
"com.google.protobuf.ExtraInterfaces.HasBoolValue";
|
||||
|
||||
optional bool bool_value = 1;
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
<arg value="--java_out=lite:${generated.testsources.dir}"/>
|
||||
<arg value="--proto_path=${protobuf.source.dir}"/>
|
||||
<arg value="--proto_path=${protobuf.basedir}/java/core/${test.proto.dir}"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/descriptor.proto"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/unittest.proto"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import.proto"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/unittest_import_lite.proto"/>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-javalite</artifactId>
|
||||
|
@ -2406,6 +2406,7 @@ public class LiteTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testAddAllIteratesOnce() {
|
||||
TestAllTypesLite unused =
|
||||
TestAllTypesLite.newBuilder()
|
||||
.addAllRepeatedBool(new OneTimeIterableList<>(false))
|
||||
.addAllRepeatedInt32(new OneTimeIterableList<>(0))
|
||||
@ -2414,7 +2415,8 @@ public class LiteTest extends TestCase {
|
||||
.addAllRepeatedDouble(new OneTimeIterableList<>(0d))
|
||||
.addAllRepeatedBytes(new OneTimeIterableList<>(ByteString.EMPTY))
|
||||
.addAllRepeatedString(new OneTimeIterableList<>(""))
|
||||
.addAllRepeatedNestedMessage(new OneTimeIterableList<>(NestedMessage.getDefaultInstance()))
|
||||
.addAllRepeatedNestedMessage(
|
||||
new OneTimeIterableList<>(NestedMessage.getDefaultInstance()))
|
||||
.addAllRepeatedBool(new OneTimeIterable<>(false))
|
||||
.addAllRepeatedInt32(new OneTimeIterable<>(0))
|
||||
.addAllRepeatedInt64(new OneTimeIterable<>(0L))
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [Parent]</name>
|
||||
@ -75,7 +75,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -104,7 +104,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.truth</groupId>
|
||||
<artifactId>truth</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
|
@ -23,7 +23,7 @@ sudo apt install -y g++-powerpc64le-linux-gnu
|
||||
protoc-artifacts/build-protoc.sh linux ppcle_64 protoc
|
||||
|
||||
sudo apt install -y g++-s390x-linux-gnu
|
||||
protoc-artifacts/build-protoc.sh linux s390x protoc
|
||||
protoc-artifacts/build-protoc.sh linux s390_64 protoc
|
||||
|
||||
# Use docker image to build linux artifacts.
|
||||
DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ")
|
||||
|
@ -334,7 +334,7 @@ static zval *Message_read_property(PROTO_VAL *obj, PROTO_STR *member,
|
||||
Message* intern = PROTO_VAL_P(obj);
|
||||
const upb_fielddef *f = get_field(intern, member);
|
||||
|
||||
if (!f) return NULL;
|
||||
if (!f) return &EG(uninitialized_zval);
|
||||
Message_get(intern, f, rv);
|
||||
return rv;
|
||||
}
|
||||
|
@ -10,11 +10,11 @@
|
||||
<email>protobuf-opensource@google.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2021-02-24</date>
|
||||
<time>16:49:52</time>
|
||||
<date>2021-03-10</date>
|
||||
<time>10:11:34</time>
|
||||
<version>
|
||||
<release>3.15.3</release>
|
||||
<api>3.15.3</api>
|
||||
<release>3.15.6</release>
|
||||
<api>3.15.6</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
@ -22,15 +22,7 @@
|
||||
</stability>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
|
||||
<notes>
|
||||
New changes in 3.15.0:
|
||||
* unregister INI entries and fix invalid read on shutdown (#8042)
|
||||
* Fix PhpDoc comments for message accessors to include "|null". (#8136)
|
||||
* fix: convert native PHP floats to single precision (#8187)
|
||||
* Fixed PHP to support field numbers >=2**28. (#8235)
|
||||
* feat: add support for deprecated fields to PHP compiler (#8223)
|
||||
* Protect against stack overflow if the user derives from Message. (#8248)
|
||||
* Fixed clone for Message, RepeatedField, and MapField. (#8245)
|
||||
* Updated upb to allow nonzero offset minutes in JSON timestamps. (#8258)
|
||||
No new changes in 3.15.6
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
@ -850,5 +842,50 @@ G A release.
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.15.4</release>
|
||||
<api>3.15.4</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2021-03-02</date>
|
||||
<time>15:25:02</time>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.15.5</release>
|
||||
<api>3.15.5</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2021-03-04</date>
|
||||
<time>10:45:30</time>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.15.6</release>
|
||||
<api>3.15.6</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2021-03-10</date>
|
||||
<time>10:11:34</time>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
|
@ -7047,10 +7047,9 @@ void upb_array_set(upb_array *arr, size_t i, upb_msgval val) {
|
||||
}
|
||||
|
||||
bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena) {
|
||||
if (!_upb_array_realloc(arr, arr->len + 1, arena)) {
|
||||
if (!upb_array_resize(arr, arr->len + 1, arena)) {
|
||||
return false;
|
||||
}
|
||||
arr->len++;
|
||||
upb_array_set(arr, arr->len - 1, val);
|
||||
return true;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define PHP_PROTOBUF_VERSION "3.15.3"
|
||||
#define PHP_PROTOBUF_VERSION "3.15.6"
|
||||
|
||||
// ptr -> PHP object cache. This is a weak map that caches lazily-created
|
||||
// wrapper objects around upb types:
|
||||
|
@ -123,7 +123,7 @@ target directory layout:
|
||||
protoc.exe
|
||||
+ ppcle_64
|
||||
protoc.exe
|
||||
+ s390x
|
||||
+ s390_64
|
||||
protoc.exe
|
||||
+ osx
|
||||
+ x86_64
|
||||
|
@ -93,7 +93,7 @@ checkArch ()
|
||||
assertEq $format "elf64-x86-64" $LINENO
|
||||
elif [[ "$ARCH" == aarch_64 ]]; then
|
||||
assertEq $format "elf64-little" $LINENO
|
||||
elif [[ "$ARCH" == s390x ]]; then
|
||||
elif [[ "$ARCH" == s390_64 ]]; then
|
||||
if [[ $host_machine == s390x ]];then
|
||||
assertEq $format "elf64-s390" $LINENO
|
||||
else
|
||||
@ -149,7 +149,7 @@ checkDependencies ()
|
||||
white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2"
|
||||
elif [[ "$ARCH" == x86_64 ]]; then
|
||||
white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2"
|
||||
elif [[ "$ARCH" == s390x ]]; then
|
||||
elif [[ "$ARCH" == s390_64 ]]; then
|
||||
if [[ $host_machine != s390x ]];then
|
||||
dump_cmd='objdump -p '"$1"' | grep NEEDED'
|
||||
fi
|
||||
@ -226,7 +226,7 @@ elif [[ "$(uname)" == Linux* ]]; then
|
||||
elif [[ "$ARCH" == ppcle_64 ]]; then
|
||||
CXXFLAGS="$CXXFLAGS -m64"
|
||||
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=powerpc64le-linux-gnu"
|
||||
elif [[ "$ARCH" == s390x ]]; then
|
||||
elif [[ "$ARCH" == s390_64 ]]; then
|
||||
CXXFLAGS="$CXXFLAGS -m64"
|
||||
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=s390x-linux-gnu"
|
||||
else
|
||||
|
@ -21,7 +21,7 @@ included. Each invocation will create 8 zip packages:
|
||||
dist/<TARGET>-<VERSION_NUMBER>-linux-x86_64.zip
|
||||
dist/<TARGET>-<VERSION_NUMBER>-linux-aarch_64.zip
|
||||
dist/<TARGET>-<VERSION_NUMBER>-linux-ppcle_64.zip
|
||||
dist/<TARGET>-<VERSION_NUMBER>-linux-s390x.zip
|
||||
dist/<TARGET>-<VERSION_NUMBER>-linux-s390_64.zip
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
@ -38,7 +38,7 @@ declare -a FILE_NAMES=( \
|
||||
linux-x86_64.zip linux-x86_64.exe \
|
||||
linux-aarch_64.zip linux-aarch_64.exe \
|
||||
linux-ppcle_64.zip linux-ppcle_64.exe \
|
||||
linux-s390x.zip linux-s390x.exe \
|
||||
linux-s390_64.zip linux-s390_64.exe \
|
||||
)
|
||||
|
||||
# List of all well-known types to be included.
|
||||
|
@ -8,7 +8,7 @@
|
||||
</parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protoc</artifactId>
|
||||
<version>3.15.3</version>
|
||||
<version>3.15.6</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Protobuf Compiler</name>
|
||||
<description>
|
||||
@ -81,8 +81,8 @@
|
||||
<type>exe</type>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<file>${basedir}/target/linux/s390x/protoc.exe</file>
|
||||
<classifier>linux-s390x</classifier>
|
||||
<file>${basedir}/target/linux/s390_64/protoc.exe</file>
|
||||
<classifier>linux-s390_64</classifier>
|
||||
<type>exe</type>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
|
@ -1176,6 +1176,54 @@ class OnlyWorksWithProto2RightNowTests(TextFormatBase):
|
||||
' }\n'
|
||||
'}\n')
|
||||
|
||||
def testDuplicateMapKey(self):
|
||||
message = map_unittest_pb2.TestMap()
|
||||
text = (
|
||||
'map_uint64_uint64 {\n'
|
||||
' key: 123\n'
|
||||
' value: 17179869184\n'
|
||||
'}\n'
|
||||
'map_string_string {\n'
|
||||
' key: "abc"\n'
|
||||
' value: "first"\n'
|
||||
'}\n'
|
||||
'map_int32_foreign_message {\n'
|
||||
' key: 111\n'
|
||||
' value {\n'
|
||||
' c: 5\n'
|
||||
' }\n'
|
||||
'}\n'
|
||||
'map_uint64_uint64 {\n'
|
||||
' key: 123\n'
|
||||
' value: 321\n'
|
||||
'}\n'
|
||||
'map_string_string {\n'
|
||||
' key: "abc"\n'
|
||||
' value: "second"\n'
|
||||
'}\n'
|
||||
'map_int32_foreign_message {\n'
|
||||
' key: 111\n'
|
||||
' value {\n'
|
||||
' d: 5\n'
|
||||
' }\n'
|
||||
'}\n')
|
||||
text_format.Parse(text, message)
|
||||
self.CompareToGoldenText(
|
||||
text_format.MessageToString(message), 'map_uint64_uint64 {\n'
|
||||
' key: 123\n'
|
||||
' value: 321\n'
|
||||
'}\n'
|
||||
'map_string_string {\n'
|
||||
' key: "abc"\n'
|
||||
' value: "second"\n'
|
||||
'}\n'
|
||||
'map_int32_foreign_message {\n'
|
||||
' key: 111\n'
|
||||
' value {\n'
|
||||
' d: 5\n'
|
||||
' }\n'
|
||||
'}\n')
|
||||
|
||||
# In cpp implementation, __str__ calls the cpp implementation of text format.
|
||||
def testPrintMapUsingCppImplementation(self):
|
||||
message = map_unittest_pb2.TestMap()
|
||||
@ -2348,6 +2396,13 @@ class OptionalColonMessageToStringTest(unittest.TestCase):
|
||||
'}\n')
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def testPrintShortFormatRepeatedFields(self):
|
||||
message = unittest_pb2.TestAllTypes()
|
||||
message.repeated_int32.append(1)
|
||||
output = text_format.MessageToString(
|
||||
message, use_short_repeated_primitives=True, force_colon=True)
|
||||
self.assertEqual('repeated_int32: [1]\n', output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -30,15 +30,18 @@
|
||||
|
||||
// Author: petar@google.com (Petar Petrov)
|
||||
|
||||
#include <google/protobuf/pyext/descriptor.h>
|
||||
|
||||
#include <Python.h>
|
||||
#include <frameobject.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/dynamic_message.h>
|
||||
#include <google/protobuf/pyext/descriptor.h>
|
||||
#include <google/protobuf/pyext/descriptor_containers.h>
|
||||
#include <google/protobuf/pyext/descriptor_pool.h>
|
||||
#include <google/protobuf/pyext/message.h>
|
||||
@ -195,7 +198,7 @@ bool Reparse(
|
||||
std::string serialized;
|
||||
from.SerializeToString(&serialized);
|
||||
io::CodedInputStream input(
|
||||
reinterpret_cast<const uint8*>(serialized.c_str()), serialized.size());
|
||||
reinterpret_cast<const uint8_t*>(serialized.c_str()), serialized.size());
|
||||
input.SetExtensionRegistry(message_factory->pool->pool,
|
||||
message_factory->message_factory);
|
||||
bool success = to->ParseFromCodedStream(&input);
|
||||
@ -804,22 +807,22 @@ static PyObject* GetDefaultValue(PyBaseDescriptor *self, void *closure) {
|
||||
|
||||
switch (_GetDescriptor(self)->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32: {
|
||||
int32 value = _GetDescriptor(self)->default_value_int32();
|
||||
int32_t value = _GetDescriptor(self)->default_value_int32();
|
||||
result = PyInt_FromLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_INT64: {
|
||||
int64 value = _GetDescriptor(self)->default_value_int64();
|
||||
int64_t value = _GetDescriptor(self)->default_value_int64();
|
||||
result = PyLong_FromLongLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT32: {
|
||||
uint32 value = _GetDescriptor(self)->default_value_uint32();
|
||||
uint32_t value = _GetDescriptor(self)->default_value_uint32();
|
||||
result = PyInt_FromSize_t(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT64: {
|
||||
uint64 value = _GetDescriptor(self)->default_value_uint64();
|
||||
uint64_t value = _GetDescriptor(self)->default_value_uint64();
|
||||
result = PyLong_FromUnsignedLongLong(value);
|
||||
break;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
#include <google/protobuf/pyext/descriptor_database.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <google/protobuf/stubs/logging.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
@ -164,7 +166,7 @@ bool PyDescriptorDatabase::FindAllExtensionNumbers(
|
||||
return false;
|
||||
}
|
||||
Py_ssize_t size = PyList_Size(py_list.get());
|
||||
int64 item_value;
|
||||
int64_t item_value;
|
||||
for (Py_ssize_t i = 0 ; i < size; ++i) {
|
||||
ScopedPyObjectPtr item(PySequence_GetItem(py_list.get(), i));
|
||||
item_value = PyLong_AsLong(item.get());
|
||||
|
@ -32,14 +32,16 @@
|
||||
// Author: tibell@google.com (Johan Tibell)
|
||||
|
||||
#include <google/protobuf/pyext/extension_dict.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/stubs/logging.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/dynamic_message.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/pyext/descriptor.h>
|
||||
#include <google/protobuf/pyext/message.h>
|
||||
#include <google/protobuf/pyext/message_factory.h>
|
||||
@ -263,7 +265,7 @@ PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* arg) {
|
||||
}
|
||||
|
||||
PyObject* _FindExtensionByNumber(ExtensionDict* self, PyObject* arg) {
|
||||
int64 number = PyLong_AsLong(arg);
|
||||
int64_t number = PyLong_AsLong(arg);
|
||||
if (number == -1 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -32,15 +32,16 @@
|
||||
|
||||
#include <google/protobuf/pyext/map_container.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/stubs/logging.h>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/map_field.h>
|
||||
#include <google/protobuf/map.h>
|
||||
#include <google/protobuf/map_field.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/pyext/message_factory.h>
|
||||
#include <google/protobuf/pyext/message.h>
|
||||
#include <google/protobuf/pyext/message_factory.h>
|
||||
#include <google/protobuf/pyext/repeated_composite_container.h>
|
||||
#include <google/protobuf/pyext/scoped_pyobject_ptr.h>
|
||||
#include <google/protobuf/stubs/map_util.h>
|
||||
@ -99,7 +100,7 @@ struct MapIterator {
|
||||
//
|
||||
// We store this so that if the map is modified during iteration we can throw
|
||||
// an error.
|
||||
uint64 version;
|
||||
uint64_t version;
|
||||
};
|
||||
|
||||
Message* MapContainer::GetMutableMessage() {
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/descriptor.h>
|
||||
@ -56,7 +57,7 @@ struct MapContainer : public ContainerBase {
|
||||
|
||||
// We bump this whenever we perform a mutation, to invalidate existing
|
||||
// iterators.
|
||||
uint64 version;
|
||||
uint64_t version;
|
||||
};
|
||||
|
||||
struct MessageMapContainer : public MapContainer {
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include <structmember.h> // A Python header file.
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -2191,22 +2192,22 @@ PyObject* InternalGetScalar(const Message* message,
|
||||
PyObject* result = NULL;
|
||||
switch (field_descriptor->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32: {
|
||||
int32 value = reflection->GetInt32(*message, field_descriptor);
|
||||
int32_t value = reflection->GetInt32(*message, field_descriptor);
|
||||
result = PyInt_FromLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_INT64: {
|
||||
int64 value = reflection->GetInt64(*message, field_descriptor);
|
||||
int64_t value = reflection->GetInt64(*message, field_descriptor);
|
||||
result = PyLong_FromLongLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT32: {
|
||||
uint32 value = reflection->GetUInt32(*message, field_descriptor);
|
||||
uint32_t value = reflection->GetUInt32(*message, field_descriptor);
|
||||
result = PyInt_FromSize_t(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT64: {
|
||||
uint64 value = reflection->GetUInt64(*message, field_descriptor);
|
||||
uint64_t value = reflection->GetUInt64(*message, field_descriptor);
|
||||
result = PyLong_FromUnsignedLongLong(value);
|
||||
break;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@ -286,25 +287,25 @@ PyObject* SetAllowOversizeProtos(PyObject* m, PyObject* arg);
|
||||
((field_descriptor)->label() == FieldDescriptor::LABEL_REPEATED)
|
||||
|
||||
#define GOOGLE_CHECK_GET_INT32(arg, value, err) \
|
||||
int32 value; \
|
||||
int32_t value; \
|
||||
if (!CheckAndGetInteger(arg, &value)) { \
|
||||
return err; \
|
||||
}
|
||||
|
||||
#define GOOGLE_CHECK_GET_INT64(arg, value, err) \
|
||||
int64 value; \
|
||||
int64_t value; \
|
||||
if (!CheckAndGetInteger(arg, &value)) { \
|
||||
return err; \
|
||||
}
|
||||
|
||||
#define GOOGLE_CHECK_GET_UINT32(arg, value, err) \
|
||||
uint32 value; \
|
||||
uint32_t value; \
|
||||
if (!CheckAndGetInteger(arg, &value)) { \
|
||||
return err; \
|
||||
}
|
||||
|
||||
#define GOOGLE_CHECK_GET_UINT64(arg, value, err) \
|
||||
uint64 value; \
|
||||
uint64_t value; \
|
||||
if (!CheckAndGetInteger(arg, &value)) { \
|
||||
return err; \
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <google/protobuf/pyext/repeated_scalar_container.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
@ -207,25 +208,25 @@ static PyObject* Item(PyObject* pself, Py_ssize_t index) {
|
||||
PyObject* result = nullptr;
|
||||
switch (field_descriptor->cpp_type()) {
|
||||
case FieldDescriptor::CPPTYPE_INT32: {
|
||||
int32 value =
|
||||
int32_t value =
|
||||
reflection->GetRepeatedInt32(*message, field_descriptor, index);
|
||||
result = PyInt_FromLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_INT64: {
|
||||
int64 value =
|
||||
int64_t value =
|
||||
reflection->GetRepeatedInt64(*message, field_descriptor, index);
|
||||
result = PyLong_FromLongLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT32: {
|
||||
uint32 value =
|
||||
uint32_t value =
|
||||
reflection->GetRepeatedUInt32(*message, field_descriptor, index);
|
||||
result = PyLong_FromLongLong(value);
|
||||
break;
|
||||
}
|
||||
case FieldDescriptor::CPPTYPE_UINT64: {
|
||||
uint64 value =
|
||||
uint64_t value =
|
||||
reflection->GetRepeatedUInt64(*message, field_descriptor, index);
|
||||
result = PyLong_FromUnsignedLongLong(value);
|
||||
break;
|
||||
|
@ -567,8 +567,6 @@ class _Printer(object):
|
||||
self.out.write(', ')
|
||||
self.PrintFieldValue(field, value[-1])
|
||||
self.out.write(']')
|
||||
if self.force_colon:
|
||||
self.out.write(':')
|
||||
self.out.write(' ' if self.as_one_line else '\n')
|
||||
|
||||
def _PrintMessageFieldValue(self, value):
|
||||
@ -1060,7 +1058,7 @@ class _Parser(object):
|
||||
value_cpptype = field.message_type.fields_by_name['value'].cpp_type
|
||||
if value_cpptype == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
|
||||
value = getattr(message, field.name)[sub_message.key]
|
||||
value.MergeFrom(sub_message.value)
|
||||
value.CopyFrom(sub_message.value)
|
||||
else:
|
||||
getattr(message, field.name)[sub_message.key] = sub_message.value
|
||||
|
||||
|
@ -14,10 +14,9 @@ setenv =
|
||||
commands =
|
||||
python setup.py -q build_py
|
||||
python: python setup.py -q build
|
||||
# --warnings_as_errors disabled until we update the Python C extension. See:
|
||||
# https://github.com/protocolbuffers/protobuf/issues/7930
|
||||
# cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension
|
||||
cpp: python setup.py -q build --cpp_implementation --compile_static_extension
|
||||
# --warnings_as_errors disabled for Python 2.7 because _POSIX_C_SOURCE and _XOPEN_SOURCE are redefined
|
||||
py27-cpp: python setup.py -q build --cpp_implementation --compile_static_extension
|
||||
py{33,34,35,36,37,38,39}-cpp: python setup.py -q build --cpp_implementation --warnings_as_errors --compile_static_extension
|
||||
python: python setup.py -q test -q
|
||||
cpp: python setup.py -q test -q --cpp_implementation
|
||||
python: python setup.py -q test_conformance
|
||||
|
@ -326,18 +326,6 @@ class RepeatedFieldTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_compact!
|
||||
m = TestMessage.new
|
||||
m.repeated_msg << TestMessage2.new(:foo => 1)
|
||||
m.repeated_msg << nil
|
||||
m.repeated_msg << TestMessage2.new(:foo => 2)
|
||||
reference_arr = m.repeated_string.to_a
|
||||
|
||||
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
|
||||
arr.compact!
|
||||
end
|
||||
end
|
||||
|
||||
def test_delete
|
||||
m = TestMessage.new
|
||||
reference_arr = %w(foo bar baz)
|
||||
|
@ -315,7 +315,7 @@ bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info) {
|
||||
return memcmp(&val1, &val2, 8) == 0;
|
||||
case UPB_TYPE_STRING:
|
||||
case UPB_TYPE_BYTES:
|
||||
return val1.str_val.size != val2.str_val.size ||
|
||||
return val1.str_val.size == val2.str_val.size &&
|
||||
memcmp(val1.str_val.data, val2.str_val.data,
|
||||
val1.str_val.size) == 0;
|
||||
case UPB_TYPE_MESSAGE:
|
||||
|
@ -1250,7 +1250,9 @@ upb_msg* Message_deep_copy(const upb_msg* msg, const upb_msgdef* m,
|
||||
|
||||
const upb_msg* Message_GetUpbMessage(VALUE value, const upb_msgdef* m,
|
||||
const char* name, upb_arena* arena) {
|
||||
if (value == Qnil) return NULL;
|
||||
if (value == Qnil) {
|
||||
rb_raise(cTypeError, "nil message not allowed here.");
|
||||
}
|
||||
|
||||
VALUE klass = CLASS_OF(value);
|
||||
VALUE desc_rb = rb_ivar_get(klass, descriptor_instancevar_interned);
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "message.h"
|
||||
#include "repeated_field.h"
|
||||
|
||||
VALUE cError;
|
||||
VALUE cParseError;
|
||||
VALUE cTypeError;
|
||||
|
||||
const upb_fielddef* map_field_key(const upb_fielddef* field) {
|
||||
@ -368,8 +368,10 @@ void Init_protobuf_c() {
|
||||
Map_register(protobuf);
|
||||
Message_register(protobuf);
|
||||
|
||||
cError = rb_const_get(protobuf, rb_intern("Error"));
|
||||
cParseError = rb_const_get(protobuf, rb_intern("ParseError"));
|
||||
rb_gc_register_mark_object(cParseError);
|
||||
cTypeError = rb_const_get(protobuf, rb_intern("TypeError"));
|
||||
rb_gc_register_mark_object(cTypeError);
|
||||
|
||||
rb_define_singleton_method(protobuf, "discard_unknown",
|
||||
Google_Protobuf_discard_unknown, 1);
|
||||
|
@ -6663,10 +6663,9 @@ void upb_array_set(upb_array *arr, size_t i, upb_msgval val) {
|
||||
}
|
||||
|
||||
bool upb_array_append(upb_array *arr, upb_msgval val, upb_arena *arena) {
|
||||
if (!_upb_array_realloc(arr, arr->len + 1, arena)) {
|
||||
if (!upb_array_resize(arr, arr->len + 1, arena)) {
|
||||
return false;
|
||||
}
|
||||
arr->len++;
|
||||
upb_array_set(arr, arr->len - 1, val);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "google-protobuf"
|
||||
s.version = "3.15.3"
|
||||
s.version = "3.15.6"
|
||||
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
|
||||
s.licenses = ["BSD-3-Clause"]
|
||||
s.summary = "Protocol Buffers"
|
||||
|
@ -52,10 +52,15 @@ module BasicTest
|
||||
|
||||
outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass
|
||||
|
||||
outer_proto = outer.new(
|
||||
outer.new(
|
||||
inners: []
|
||||
)
|
||||
outer_proto['inners'].to_s
|
||||
)['inners'].to_s
|
||||
|
||||
assert_raise Google::Protobuf::TypeError do
|
||||
outer.new(
|
||||
inners: [nil]
|
||||
).to_s
|
||||
end
|
||||
end
|
||||
|
||||
def test_has_field
|
||||
|
@ -436,6 +436,18 @@ module CommonTests
|
||||
end
|
||||
end
|
||||
|
||||
def test_b_8385
|
||||
m1 = Google::Protobuf::Map.new(:string, :string)
|
||||
m2 = Google::Protobuf::Map.new(:string, :string)
|
||||
|
||||
assert_equal m1, m2
|
||||
|
||||
m1["counter"] = "a"
|
||||
m2["counter"] = "aa"
|
||||
|
||||
assert_not_equal m1, m2
|
||||
end
|
||||
|
||||
def test_map_ctor
|
||||
m = Google::Protobuf::Map.new(:string, :int32,
|
||||
{"a" => 1, "b" => 2, "c" => 3})
|
||||
|
@ -339,18 +339,6 @@ class RepeatedFieldTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_compact!
|
||||
m = TestMessage.new
|
||||
m.repeated_msg << TestMessage2.new(:foo => 1)
|
||||
m.repeated_msg << nil
|
||||
m.repeated_msg << TestMessage2.new(:foo => 2)
|
||||
reference_arr = m.repeated_string.to_a
|
||||
|
||||
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
|
||||
arr.compact!
|
||||
end
|
||||
end
|
||||
|
||||
def test_delete
|
||||
m = TestMessage.new
|
||||
reference_arr = %w(foo bar baz)
|
||||
|
@ -163,7 +163,6 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
|
||||
while (!ctx->Done(&ptr)) {
|
||||
::PROTOBUF_NAMESPACE_ID::uint32 tag;
|
||||
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
|
||||
CHK_(ptr);
|
||||
switch (tag >> 3) {
|
||||
// string type_url = 1;
|
||||
case 1:
|
||||
@ -184,7 +183,8 @@ const char* Any::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
|
||||
continue;
|
||||
default: {
|
||||
handle_unusual:
|
||||
if ((tag & 7) == 4 || tag == 0) {
|
||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
||||
CHK_(ptr);
|
||||
ctx->SetLastTag(tag);
|
||||
goto success;
|
||||
}
|
||||
|
@ -268,7 +268,6 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
|
||||
while (!ctx->Done(&ptr)) {
|
||||
::PROTOBUF_NAMESPACE_ID::uint32 tag;
|
||||
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
|
||||
CHK_(ptr);
|
||||
switch (tag >> 3) {
|
||||
// string name = 1;
|
||||
case 1:
|
||||
@ -341,7 +340,8 @@ const char* Api::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::intern
|
||||
continue;
|
||||
default: {
|
||||
handle_unusual:
|
||||
if ((tag & 7) == 4 || tag == 0) {
|
||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
||||
CHK_(ptr);
|
||||
ctx->SetLastTag(tag);
|
||||
goto success;
|
||||
}
|
||||
@ -673,7 +673,6 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int
|
||||
while (!ctx->Done(&ptr)) {
|
||||
::PROTOBUF_NAMESPACE_ID::uint32 tag;
|
||||
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
|
||||
CHK_(ptr);
|
||||
switch (tag >> 3) {
|
||||
// string name = 1;
|
||||
case 1:
|
||||
@ -738,7 +737,8 @@ const char* Method::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::int
|
||||
continue;
|
||||
default: {
|
||||
handle_unusual:
|
||||
if ((tag & 7) == 4 || tag == 0) {
|
||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
||||
CHK_(ptr);
|
||||
ctx->SetLastTag(tag);
|
||||
goto success;
|
||||
}
|
||||
@ -1043,7 +1043,6 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
|
||||
while (!ctx->Done(&ptr)) {
|
||||
::PROTOBUF_NAMESPACE_ID::uint32 tag;
|
||||
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
|
||||
CHK_(ptr);
|
||||
switch (tag >> 3) {
|
||||
// string name = 1;
|
||||
case 1:
|
||||
@ -1065,7 +1064,8 @@ const char* Mixin::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::inte
|
||||
continue;
|
||||
default: {
|
||||
handle_unusual:
|
||||
if ((tag & 7) == 4 || tag == 0) {
|
||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
||||
CHK_(ptr);
|
||||
ctx->SetLastTag(tag);
|
||||
goto success;
|
||||
}
|
||||
|
@ -62,6 +62,14 @@ const std::string& LazyString::Init() const {
|
||||
}
|
||||
|
||||
|
||||
std::string* ArenaStringPtr::SetAndReturnNewString() {
|
||||
std::string* new_string = new std::string();
|
||||
tagged_ptr_.Set(new_string);
|
||||
return new_string;
|
||||
}
|
||||
|
||||
void ArenaStringPtr::DestroyNoArenaSlowPath() { delete UnsafeMutablePointer(); }
|
||||
|
||||
void ArenaStringPtr::Set(const std::string* default_value,
|
||||
ConstStringParam value, ::google::protobuf::Arena* arena) {
|
||||
if (IsDefault(default_value)) {
|
||||
|
@ -328,6 +328,12 @@ struct PROTOBUF_EXPORT ArenaStringPtr {
|
||||
template <typename... Lazy>
|
||||
std::string* MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default);
|
||||
|
||||
// Sets value to a newly allocated string and returns it
|
||||
std::string* SetAndReturnNewString();
|
||||
|
||||
// Destroys the non-default string value out-of-line
|
||||
void DestroyNoArenaSlowPath();
|
||||
|
||||
};
|
||||
|
||||
inline void ArenaStringPtr::UnsafeSetDefault(const std::string* value) {
|
||||
@ -379,9 +385,7 @@ inline std::string* ArenaStringPtr::MutableNoArenaNoDefault(
|
||||
// static global) and a branch to the slowpath (which calls operator new and
|
||||
// the ctor). DO NOT add any tagged-pointer operations here.
|
||||
if (IsDefault(default_value)) {
|
||||
std::string* new_string = new std::string();
|
||||
tagged_ptr_.Set(new_string);
|
||||
return new_string;
|
||||
return SetAndReturnNewString();
|
||||
} else {
|
||||
return UnsafeMutablePointer();
|
||||
}
|
||||
@ -389,7 +393,7 @@ inline std::string* ArenaStringPtr::MutableNoArenaNoDefault(
|
||||
|
||||
inline void ArenaStringPtr::DestroyNoArena(const std::string* default_value) {
|
||||
if (!IsDefault(default_value)) {
|
||||
delete UnsafeMutablePointer();
|
||||
DestroyNoArenaSlowPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <google/protobuf/compiler/annotation_test_util.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/testing/file.h>
|
||||
@ -141,8 +142,8 @@ bool AtLeastOneAnnotationMatchesSubstring(
|
||||
e = annotations.end();
|
||||
i != e; ++i) {
|
||||
const GeneratedCodeInfo::Annotation* annotation = *i;
|
||||
uint32 begin = annotation->begin();
|
||||
uint32 end = annotation->end();
|
||||
uint32_t begin = annotation->begin();
|
||||
uint32_t end = annotation->end();
|
||||
if (end < begin || end > file_content.size()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
#include <google/protobuf/compiler/command_line_interface.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <google/protobuf/stubs/platform_macros.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@ -2087,7 +2089,7 @@ Parse PROTO_FILES and generate output based on the options given:
|
||||
}
|
||||
|
||||
bool CommandLineInterface::EnforceProto3OptionalSupport(
|
||||
const std::string& codegen_name, uint64 supported_features,
|
||||
const std::string& codegen_name, uint64_t supported_features,
|
||||
const std::vector<const FileDescriptor*>& parsed_files) const {
|
||||
bool supports_proto3_optional =
|
||||
supported_features & CodeGenerator::FEATURE_PROTO3_OPTIONAL;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
@ -229,7 +230,7 @@ class PROTOC_EXPORT CommandLineInterface {
|
||||
// Fails if these files use proto3 optional and the code generator doesn't
|
||||
// support it. This is a permanent check.
|
||||
bool EnforceProto3OptionalSupport(
|
||||
const std::string& codegen_name, uint64 supported_features,
|
||||
const std::string& codegen_name, uint64_t supported_features,
|
||||
const std::vector<const FileDescriptor*>& parsed_files) const;
|
||||
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@ -211,7 +213,7 @@ class CommandLineInterfaceTest : public testing::Test {
|
||||
// code generator that omits the given feature(s).
|
||||
void CreateGeneratorWithMissingFeatures(const std::string& name,
|
||||
const std::string& description,
|
||||
uint64 features) {
|
||||
uint64_t features) {
|
||||
MockCodeGenerator* generator = new MockCodeGenerator(name);
|
||||
generator->SuppressFeatures(features);
|
||||
mock_generators_to_delete_.push_back(generator);
|
||||
|
@ -32,10 +32,14 @@
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_enum.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_enum.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_names.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/stubs/strutil.h>
|
||||
|
||||
@ -49,13 +53,13 @@ namespace {
|
||||
// is kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the
|
||||
// generation of the GOOGLE_ARRAYSIZE constant.
|
||||
bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
|
||||
int32 max_value = descriptor->value(0)->number();
|
||||
int32_t max_value = descriptor->value(0)->number();
|
||||
for (int i = 0; i < descriptor->value_count(); i++) {
|
||||
if (descriptor->value(i)->number() > max_value) {
|
||||
max_value = descriptor->value(i)->number();
|
||||
}
|
||||
}
|
||||
return max_value != kint32max;
|
||||
return max_value != std::numeric_limits<int32_t>::max();
|
||||
}
|
||||
|
||||
// Returns the number of unique numeric enum values. This is less than
|
||||
|
@ -33,6 +33,8 @@
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_field.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
@ -89,7 +91,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
|
||||
(*variables)["}"] = "";
|
||||
}
|
||||
|
||||
void FieldGenerator::SetHasBitIndex(int32 has_bit_index) {
|
||||
void FieldGenerator::SetHasBitIndex(int32_t has_bit_index) {
|
||||
if (!HasHasbit(descriptor_)) {
|
||||
GOOGLE_CHECK_EQ(has_bit_index, -1);
|
||||
return;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -180,7 +181,7 @@ class FieldGenerator {
|
||||
// are placed in the message's ByteSize() method.
|
||||
virtual void GenerateByteSize(io::Printer* printer) const = 0;
|
||||
|
||||
void SetHasBitIndex(int32 has_bit_index);
|
||||
void SetHasBitIndex(int32_t has_bit_index);
|
||||
|
||||
protected:
|
||||
const FieldDescriptor* descriptor_;
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
@ -642,7 +643,7 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
|
||||
}
|
||||
|
||||
std::string Int32ToString(int number) {
|
||||
if (number == kint32min) {
|
||||
if (number == std::numeric_limits<int32_t>::min()) {
|
||||
// This needs to be special-cased, see explanation here:
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
|
||||
return StrCat(number + 1, " - 1");
|
||||
@ -651,8 +652,8 @@ std::string Int32ToString(int number) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Int64ToString(const std::string& macro_prefix, int64 number) {
|
||||
if (number == kint64min) {
|
||||
std::string Int64ToString(const std::string& macro_prefix, int64_t number) {
|
||||
if (number == std::numeric_limits<int64_t>::min()) {
|
||||
// This needs to be special-cased, see explanation here:
|
||||
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
|
||||
return StrCat(macro_prefix, "_LONGLONG(", number + 1, ") - 1");
|
||||
@ -660,7 +661,7 @@ std::string Int64ToString(const std::string& macro_prefix, int64 number) {
|
||||
return StrCat(macro_prefix, "_LONGLONG(", number, ")");
|
||||
}
|
||||
|
||||
std::string UInt64ToString(const std::string& macro_prefix, uint64 number) {
|
||||
std::string UInt64ToString(const std::string& macro_prefix, uint64_t number) {
|
||||
return StrCat(macro_prefix, "_ULONGLONG(", number, ")");
|
||||
}
|
||||
|
||||
@ -748,7 +749,8 @@ std::string FilenameIdentifier(const std::string& filename) {
|
||||
} else {
|
||||
// Not alphanumeric. To avoid any possibility of name conflicts we
|
||||
// use the hex code for the character.
|
||||
StrAppend(&result, "_", strings::Hex(static_cast<uint8>(filename[i])));
|
||||
StrAppend(&result, "_",
|
||||
strings::Hex(static_cast<uint8_t>(filename[i])));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -1612,7 +1614,7 @@ class ParseLoopGenerator {
|
||||
}
|
||||
|
||||
// Convert a 1 or 2 byte varint into the equivalent value upon a direct load.
|
||||
static uint32 SmallVarintValue(uint32 x) {
|
||||
static uint32_t SmallVarintValue(uint32_t x) {
|
||||
GOOGLE_DCHECK(x < 128 * 128);
|
||||
if (x >= 128) x += (x & 0xFF80) + 128;
|
||||
return x;
|
||||
@ -1629,7 +1631,7 @@ class ParseLoopGenerator {
|
||||
|
||||
void GenerateFieldBody(internal::WireFormatLite::WireType wiretype,
|
||||
const FieldDescriptor* field) {
|
||||
uint32 tag = WireFormatLite::MakeTag(field->number(), wiretype);
|
||||
uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype);
|
||||
switch (wiretype) {
|
||||
case WireFormatLite::WIRETYPE_VARINT: {
|
||||
std::string type = PrimitiveTypeName(options_, field->cpp_type());
|
||||
@ -1724,16 +1726,16 @@ class ParseLoopGenerator {
|
||||
|
||||
// Returns the tag for this field and in case of repeated packable fields,
|
||||
// sets a fallback tag in fallback_tag_ptr.
|
||||
static uint32 ExpectedTag(const FieldDescriptor* field,
|
||||
uint32* fallback_tag_ptr) {
|
||||
uint32 expected_tag;
|
||||
static uint32_t ExpectedTag(const FieldDescriptor* field,
|
||||
uint32_t* fallback_tag_ptr) {
|
||||
uint32_t expected_tag;
|
||||
if (field->is_packable()) {
|
||||
auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type());
|
||||
expected_tag =
|
||||
WireFormatLite::MakeTag(field->number(), expected_wiretype);
|
||||
GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
|
||||
auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
|
||||
uint32 fallback_tag =
|
||||
uint32_t fallback_tag =
|
||||
WireFormatLite::MakeTag(field->number(), fallback_wiretype);
|
||||
|
||||
if (field->is_packed()) std::swap(expected_tag, fallback_tag);
|
||||
@ -1752,8 +1754,7 @@ class ParseLoopGenerator {
|
||||
format_(
|
||||
"while (!ctx->Done(&ptr)) {\n"
|
||||
" $uint32$ tag;\n"
|
||||
" ptr = $pi_ns$::ReadTag(ptr, &tag);\n"
|
||||
" CHK_(ptr);\n");
|
||||
" ptr = $pi_ns$::ReadTag(ptr, &tag);\n");
|
||||
if (!ordered_fields.empty()) format_(" switch (tag >> 3) {\n");
|
||||
|
||||
format_.Indent();
|
||||
@ -1763,14 +1764,14 @@ class ParseLoopGenerator {
|
||||
PrintFieldComment(format_, field);
|
||||
format_("case $1$:\n", field->number());
|
||||
format_.Indent();
|
||||
uint32 fallback_tag = 0;
|
||||
uint32 expected_tag = ExpectedTag(field, &fallback_tag);
|
||||
uint32_t fallback_tag = 0;
|
||||
uint32_t expected_tag = ExpectedTag(field, &fallback_tag);
|
||||
format_(
|
||||
"if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n",
|
||||
expected_tag & 0xFF);
|
||||
format_.Indent();
|
||||
auto wiretype = WireFormatLite::GetTagWireType(expected_tag);
|
||||
uint32 tag = WireFormatLite::MakeTag(field->number(), wiretype);
|
||||
uint32_t tag = WireFormatLite::MakeTag(field->number(), wiretype);
|
||||
int tag_size = io::CodedOutputStream::VarintSize32(tag);
|
||||
bool is_repeat = ShouldRepeat(field, wiretype);
|
||||
if (is_repeat) {
|
||||
@ -1807,7 +1808,8 @@ class ParseLoopGenerator {
|
||||
if (!ordered_fields.empty()) format_("default: {\n");
|
||||
if (!ordered_fields.empty()) format_("handle_unusual:\n");
|
||||
format_(
|
||||
" if ((tag & 7) == 4 || tag == 0) {\n"
|
||||
" if ((tag == 0) || ((tag & 7) == 4)) {\n"
|
||||
" CHK_(ptr);\n"
|
||||
" ctx->SetLastTag(tag);\n"
|
||||
" goto success;\n"
|
||||
" }\n");
|
||||
@ -1821,9 +1823,9 @@ class ParseLoopGenerator {
|
||||
descriptor->extension_range(i);
|
||||
if (i > 0) format_(" ||\n ");
|
||||
|
||||
uint32 start_tag = WireFormatLite::MakeTag(
|
||||
uint32_t start_tag = WireFormatLite::MakeTag(
|
||||
range->start, static_cast<WireFormatLite::WireType>(0));
|
||||
uint32 end_tag = WireFormatLite::MakeTag(
|
||||
uint32_t end_tag = WireFormatLite::MakeTag(
|
||||
range->end, static_cast<WireFormatLite::WireType>(0));
|
||||
|
||||
if (range->end > FieldDescriptor::kMaxNumber) {
|
||||
|
@ -36,11 +36,13 @@
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_options.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_names.h>
|
||||
#include <google/protobuf/compiler/scc.h>
|
||||
#include <google/protobuf/compiler/code_generator.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
@ -184,9 +186,6 @@ std::string ResolveKeyword(const std::string& name);
|
||||
// anyway, so normally this just returns field->name().
|
||||
std::string FieldName(const FieldDescriptor* field);
|
||||
|
||||
// Get the sanitized name that should be used for the given enum in C++ code.
|
||||
std::string EnumValueName(const EnumValueDescriptor* enum_value);
|
||||
|
||||
// Returns an estimate of the compiler's alignment for the field. This
|
||||
// can't guarantee to be correct because the generated code could be compiled on
|
||||
// different systems with different alignment rules. The estimates below assume
|
||||
@ -222,7 +221,7 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
|
||||
std::string Int32ToString(int number);
|
||||
|
||||
// Return the code that evaluates to the number when compiled.
|
||||
std::string Int64ToString(const Options& options, int64 number);
|
||||
std::string Int64ToString(const Options& options, int64_t number);
|
||||
|
||||
// Get code that evaluates to the field's default value.
|
||||
std::string DefaultValue(const Options& options, const FieldDescriptor* field);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <google/protobuf/compiler/cpp/cpp_message.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -76,7 +77,7 @@ static constexpr int kNoHasbit = -1;
|
||||
// masks is allowed to be shorter than _has_bits_, but at least one element of
|
||||
// masks must be non-zero.
|
||||
std::string ConditionalToCheckBitmasks(
|
||||
const std::vector<uint32>& masks, bool return_success = true,
|
||||
const std::vector<uint32_t>& masks, bool return_success = true,
|
||||
StringPiece has_bits_var = "_has_bits_") {
|
||||
std::vector<std::string> parts;
|
||||
for (int i = 0; i < masks.size(); i++) {
|
||||
@ -405,23 +406,23 @@ std::vector<std::vector<const FieldDescriptor*>> CollectFields(
|
||||
// Returns a bit mask based on has_bit index of "fields" that are typically on
|
||||
// the same chunk. It is used in a group presence check where _has_bits_ is
|
||||
// masked to tell if any thing in "fields" is present.
|
||||
uint32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields,
|
||||
uint32_t GenChunkMask(const std::vector<const FieldDescriptor*>& fields,
|
||||
const std::vector<int>& has_bit_indices) {
|
||||
GOOGLE_CHECK(!fields.empty());
|
||||
int first_index_offset = has_bit_indices[fields.front()->index()] / 32;
|
||||
uint32 chunk_mask = 0;
|
||||
uint32_t chunk_mask = 0;
|
||||
for (auto field : fields) {
|
||||
// "index" defines where in the _has_bits_ the field appears.
|
||||
int index = has_bit_indices[field->index()];
|
||||
GOOGLE_CHECK_EQ(first_index_offset, index / 32);
|
||||
chunk_mask |= static_cast<uint32>(1) << (index % 32);
|
||||
chunk_mask |= static_cast<uint32_t>(1) << (index % 32);
|
||||
}
|
||||
GOOGLE_CHECK_NE(0, chunk_mask);
|
||||
return chunk_mask;
|
||||
}
|
||||
|
||||
// Return the number of bits set in n, a non-negative integer.
|
||||
static int popcnt(uint32 n) {
|
||||
static int popcnt(uint32_t n) {
|
||||
int result = 0;
|
||||
while (n != 0) {
|
||||
result += (n & 1);
|
||||
@ -507,7 +508,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index,
|
||||
format("if (PROTOBUF_PREDICT_FALSE(");
|
||||
int first_word = HasbitWord(chunk, 0);
|
||||
while (chunk < limit_chunk_) {
|
||||
uint32 mask = 0;
|
||||
uint32_t mask = 0;
|
||||
int this_word = HasbitWord(chunk, 0);
|
||||
// Generate mask for chunks on the same word.
|
||||
for (; chunk < limit_chunk_ && HasbitWord(chunk, 0) == this_word; chunk++) {
|
||||
@ -1654,7 +1655,7 @@ namespace {
|
||||
|
||||
// We need to calculate for each field what function the table driven code
|
||||
// should use to serialize it. This returns the index in a lookup table.
|
||||
uint32 CalcFieldNum(const FieldGenerator& generator,
|
||||
uint32_t CalcFieldNum(const FieldGenerator& generator,
|
||||
const FieldDescriptor* field, const Options& options) {
|
||||
bool is_a_map = IsMapEntryMessage(field->containing_type());
|
||||
int type = field->type();
|
||||
@ -1707,7 +1708,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
|
||||
const FieldDescriptor* field = sorted[i];
|
||||
const FieldGenerator& generator = field_generators_.get(field);
|
||||
|
||||
uint32 tag = internal::WireFormatLite::MakeTag(
|
||||
uint32_t tag = internal::WireFormatLite::MakeTag(
|
||||
field->number(), WireFormat::WireTypeForFieldType(field->type()));
|
||||
|
||||
std::map<std::string, std::string> vars;
|
||||
@ -1764,7 +1765,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
|
||||
if (i == sorted.size()) break;
|
||||
const FieldDescriptor* field = sorted[i];
|
||||
|
||||
uint32 tag = internal::WireFormatLite::MakeTag(
|
||||
uint32_t tag = internal::WireFormatLite::MakeTag(
|
||||
field->number(), WireFormat::WireTypeForFieldType(field->type()));
|
||||
if (field->is_packed()) {
|
||||
tag = internal::WireFormatLite::MakeTag(
|
||||
@ -1827,7 +1828,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) {
|
||||
tag);
|
||||
} else if (field->real_containing_oneof()) {
|
||||
format.Set("oneofoffset",
|
||||
sizeof(uint32) * field->containing_oneof()->index());
|
||||
sizeof(uint32_t) * field->containing_oneof()->index());
|
||||
format(
|
||||
"{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$,"
|
||||
" PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_) + "
|
||||
@ -1933,7 +1934,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
|
||||
}
|
||||
}
|
||||
if (num_required_fields_ > 0) {
|
||||
const std::vector<uint32> masks_for_has_bits = RequiredFieldsBitMask();
|
||||
const std::vector<uint32_t> masks_for_has_bits = RequiredFieldsBitMask();
|
||||
format(
|
||||
"static bool MissingRequiredFields(const HasBits& has_bits) "
|
||||
"{\n"
|
||||
@ -2751,7 +2752,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
|
||||
|
||||
if (have_outer_if) {
|
||||
// Emit an if() that will let us skip the whole chunk if none are set.
|
||||
uint32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
std::string chunk_mask_str =
|
||||
StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
|
||||
|
||||
@ -3055,7 +3056,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
|
||||
|
||||
if (have_outer_if) {
|
||||
// Emit an if() that will let us skip the whole chunk if none are set.
|
||||
uint32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
std::string chunk_mask_str =
|
||||
StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
|
||||
|
||||
@ -3445,6 +3446,12 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
|
||||
}
|
||||
}
|
||||
|
||||
void EmitIfNotNull(const FieldDescriptor* field) {
|
||||
if (field != nullptr) {
|
||||
Emit(field);
|
||||
}
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
if (!v_.empty()) {
|
||||
mg_->GenerateSerializeOneofFields(format_.printer(), v_);
|
||||
@ -3471,6 +3478,61 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
|
||||
int cached_has_bit_index_;
|
||||
};
|
||||
|
||||
class LazyExtensionRangeEmitter {
|
||||
public:
|
||||
LazyExtensionRangeEmitter(MessageGenerator* mg, io::Printer* printer)
|
||||
: mg_(mg), format_(printer) {}
|
||||
|
||||
void AddToRange(const Descriptor::ExtensionRange* range) {
|
||||
if (!has_current_range_) {
|
||||
current_combined_range_ = *range;
|
||||
has_current_range_ = true;
|
||||
} else {
|
||||
current_combined_range_.start =
|
||||
std::min(current_combined_range_.start, range->start);
|
||||
current_combined_range_.end =
|
||||
std::max(current_combined_range_.end, range->end);
|
||||
}
|
||||
}
|
||||
|
||||
void Flush() {
|
||||
if (has_current_range_) {
|
||||
mg_->GenerateSerializeOneExtensionRange(format_.printer(),
|
||||
¤t_combined_range_);
|
||||
}
|
||||
has_current_range_ = false;
|
||||
}
|
||||
|
||||
private:
|
||||
MessageGenerator* mg_;
|
||||
Formatter format_;
|
||||
bool has_current_range_ = false;
|
||||
Descriptor::ExtensionRange current_combined_range_;
|
||||
};
|
||||
|
||||
// We need to track the largest weak field, because weak fields are serialized
|
||||
// differently than normal fields. The WeakFieldMap::FieldWriter will
|
||||
// serialize all weak fields that are ordinally between the last serialized
|
||||
// weak field and the current field. In order to guarantee that all weak
|
||||
// fields are serialized, we need to make sure to emit the code to serialize
|
||||
// the largest weak field present at some point.
|
||||
class LargestWeakFieldHolder {
|
||||
public:
|
||||
const FieldDescriptor* Release() {
|
||||
const FieldDescriptor* result = field_;
|
||||
field_ = nullptr;
|
||||
return result;
|
||||
}
|
||||
void ReplaceIfLarger(const FieldDescriptor* field) {
|
||||
if (field_ == nullptr || field_->number() < field->number()) {
|
||||
field_ = field;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const FieldDescriptor* field_ = nullptr;
|
||||
};
|
||||
|
||||
std::vector<const FieldDescriptor*> ordered_fields =
|
||||
SortFieldsByNumber(descriptor_);
|
||||
|
||||
@ -3494,7 +3556,8 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
|
||||
// Merge the fields and the extension ranges, both sorted by field number.
|
||||
{
|
||||
LazySerializerEmitter e(this, printer);
|
||||
const FieldDescriptor* last_weak_field = nullptr;
|
||||
LazyExtensionRangeEmitter re(this, printer);
|
||||
LargestWeakFieldHolder largest_weak_field;
|
||||
int i, j;
|
||||
for (i = 0, j = 0;
|
||||
i < ordered_fields.size() || j < sorted_extensions.size();) {
|
||||
@ -3505,31 +3568,22 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
|
||||
if (IsFieldStripped(field, options_)) {
|
||||
continue;
|
||||
}
|
||||
re.Flush();
|
||||
if (field->options().weak()) {
|
||||
if (last_weak_field == nullptr ||
|
||||
last_weak_field->number() < field->number()) {
|
||||
last_weak_field = field;
|
||||
}
|
||||
largest_weak_field.ReplaceIfLarger(field);
|
||||
PrintFieldComment(format, field);
|
||||
} else {
|
||||
if (last_weak_field != nullptr) {
|
||||
e.Emit(last_weak_field);
|
||||
last_weak_field = nullptr;
|
||||
}
|
||||
e.EmitIfNotNull(largest_weak_field.Release());
|
||||
e.Emit(field);
|
||||
}
|
||||
} else {
|
||||
if (last_weak_field != nullptr) {
|
||||
e.Emit(last_weak_field);
|
||||
last_weak_field = nullptr;
|
||||
}
|
||||
e.EmitIfNotNull(largest_weak_field.Release());
|
||||
e.Flush();
|
||||
GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
|
||||
re.AddToRange(sorted_extensions[j++]);
|
||||
}
|
||||
}
|
||||
if (last_weak_field != nullptr) {
|
||||
e.Emit(last_weak_field);
|
||||
}
|
||||
re.Flush();
|
||||
e.EmitIfNotNull(largest_weak_field.Release());
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> vars;
|
||||
@ -3644,9 +3698,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
|
||||
format("}\n");
|
||||
}
|
||||
|
||||
std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const {
|
||||
std::vector<uint32_t> MessageGenerator::RequiredFieldsBitMask() const {
|
||||
const int array_size = HasBitsSize();
|
||||
std::vector<uint32> masks(array_size, 0);
|
||||
std::vector<uint32_t> masks(array_size, 0);
|
||||
|
||||
for (auto field : FieldRange(descriptor_)) {
|
||||
if (!field->is_required()) {
|
||||
@ -3654,7 +3708,8 @@ std::vector<uint32> MessageGenerator::RequiredFieldsBitMask() const {
|
||||
}
|
||||
|
||||
const int has_bit_index = has_bit_indices_[field->index()];
|
||||
masks[has_bit_index / 32] |= static_cast<uint32>(1) << (has_bit_index % 32);
|
||||
masks[has_bit_index / 32] |= static_cast<uint32_t>(1)
|
||||
<< (has_bit_index % 32);
|
||||
}
|
||||
return masks;
|
||||
}
|
||||
@ -3735,7 +3790,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
|
||||
// present then the fast path executes; otherwise the slow path executes.
|
||||
if (num_required_fields_ > 1) {
|
||||
// The fast path works if all required fields are present.
|
||||
const std::vector<uint32> masks_for_has_bits = RequiredFieldsBitMask();
|
||||
const std::vector<uint32_t> masks_for_has_bits = RequiredFieldsBitMask();
|
||||
format("if ($1$) { // All required fields are present.\n",
|
||||
ConditionalToCheckBitmasks(masks_for_has_bits));
|
||||
format.Indent();
|
||||
@ -3791,7 +3846,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
|
||||
|
||||
if (have_outer_if) {
|
||||
// Emit an if() that will let us skip the whole chunk if none are set.
|
||||
uint32 chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_);
|
||||
std::string chunk_mask_str =
|
||||
StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
|
||||
|
||||
|
@ -35,9 +35,11 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_field.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h>
|
||||
@ -179,7 +181,7 @@ class MessageGenerator {
|
||||
int HasByteIndex(const FieldDescriptor* a) const;
|
||||
int HasWordIndex(const FieldDescriptor* a) const;
|
||||
bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const;
|
||||
std::vector<uint32> RequiredFieldsBitMask() const;
|
||||
std::vector<uint32_t> RequiredFieldsBitMask() const;
|
||||
|
||||
const Descriptor* descriptor_;
|
||||
int index_in_file_messages_;
|
||||
|
@ -40,6 +40,7 @@ namespace protobuf {
|
||||
|
||||
class Descriptor;
|
||||
class EnumDescriptor;
|
||||
class EnumValueDescriptor;
|
||||
class FieldDescriptor;
|
||||
|
||||
namespace compiler {
|
||||
@ -72,6 +73,10 @@ std::string QualifiedExtensionName(const FieldDescriptor* d);
|
||||
// anyway, so normally this just returns field->name().
|
||||
std::string FieldName(const FieldDescriptor* field);
|
||||
|
||||
// Get the (unqualified) name that should be used for this enum value in C++
|
||||
// code.
|
||||
std::string EnumValueName(const EnumValueDescriptor* enum_value);
|
||||
|
||||
// Strips ".proto" or ".protodevel" from the end of a filename.
|
||||
PROTOC_EXPORT std::string StripProto(const std::string& filename);
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
|
||||
|
||||
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
@ -301,7 +302,7 @@ void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers(
|
||||
io::Printer* printer) const {
|
||||
Formatter format(printer, variables_);
|
||||
format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
|
||||
if (descriptor_->is_packed() &&
|
||||
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
|
||||
HasGeneratedMethods(descriptor_->file(), options_)) {
|
||||
format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
|
||||
}
|
||||
@ -409,13 +410,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
|
||||
io::Printer* printer) const {
|
||||
Formatter format(printer, variables_);
|
||||
if (descriptor_->is_packed()) {
|
||||
if (FixedSize(descriptor_->type()) > 0) {
|
||||
format(
|
||||
"if (this->_internal_$name$_size() > 0) {\n"
|
||||
" target = stream->WriteFixedPacked($number$, _internal_$name$(), "
|
||||
"target);\n"
|
||||
"}\n");
|
||||
} else {
|
||||
if (FixedSize(descriptor_->type()) == -1) {
|
||||
format(
|
||||
"{\n"
|
||||
" int byte_size = "
|
||||
@ -425,6 +420,12 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
|
||||
" $number$, _internal_$name$(), byte_size, target);\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
} else {
|
||||
format(
|
||||
"if (this->_internal_$name$_size() > 0) {\n"
|
||||
" target = stream->WriteFixedPacked($number$, _internal_$name$(), "
|
||||
"target);\n"
|
||||
"}\n");
|
||||
}
|
||||
} else {
|
||||
format(
|
||||
@ -460,11 +461,14 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
|
||||
" total_size += $tag_size$ +\n"
|
||||
" ::$proto_ns$::internal::WireFormatLite::Int32Size(\n"
|
||||
" static_cast<$int32$>(data_size));\n"
|
||||
"}\n"
|
||||
"}\n");
|
||||
if (FixedSize(descriptor_->type()) == -1) {
|
||||
format(
|
||||
"int cached_size = ::$proto_ns$::internal::ToCachedSize(data_size);\n"
|
||||
"_$name$_cached_byte_size_.store(cached_size,\n"
|
||||
" std::memory_order_relaxed);\n"
|
||||
"total_size += data_size;\n");
|
||||
" std::memory_order_relaxed);\n");
|
||||
}
|
||||
format("total_size += data_size;\n");
|
||||
} else {
|
||||
format(
|
||||
"total_size += $tag_size$ *\n"
|
||||
@ -480,7 +484,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
|
||||
io::Printer* printer) const {
|
||||
Formatter format(printer, variables_);
|
||||
format("$name$_()");
|
||||
if (descriptor_->is_packed() &&
|
||||
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
|
||||
HasGeneratedMethods(descriptor_->file(), options_)) {
|
||||
format("\n, _$name$_cached_byte_size_()");
|
||||
}
|
||||
|
@ -44,6 +44,8 @@
|
||||
// correctly and produces the interfaces we expect, which is why this test
|
||||
// is written this way.
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@ -203,10 +205,13 @@ TEST(GENERATED_MESSAGE_TEST_NAME, Trigraph) {
|
||||
TEST(GENERATED_MESSAGE_TEST_NAME, ExtremeSmallIntegerDefault) {
|
||||
const UNITTEST::TestExtremeDefaultValues& extreme_default =
|
||||
UNITTEST::TestExtremeDefaultValues::default_instance();
|
||||
EXPECT_EQ(~0x7fffffff, kint32min);
|
||||
EXPECT_EQ(PROTOBUF_LONGLONG(~0x7fffffffffffffff), kint64min);
|
||||
EXPECT_EQ(kint32min, extreme_default.really_small_int32());
|
||||
EXPECT_EQ(kint64min, extreme_default.really_small_int64());
|
||||
EXPECT_EQ(~0x7fffffff, std::numeric_limits<int32_t>::min());
|
||||
EXPECT_EQ(PROTOBUF_LONGLONG(~0x7fffffffffffffff),
|
||||
std::numeric_limits<int64_t>::min());
|
||||
EXPECT_EQ(std::numeric_limits<int32_t>::min(),
|
||||
extreme_default.really_small_int32());
|
||||
EXPECT_EQ(std::numeric_limits<int64_t>::min(),
|
||||
extreme_default.really_small_int64());
|
||||
}
|
||||
|
||||
TEST(GENERATED_MESSAGE_TEST_NAME, Accessors) {
|
||||
@ -369,7 +374,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ClearOneField) {
|
||||
UNITTEST::TestAllTypes message;
|
||||
|
||||
TestUtil::SetAllFields(&message);
|
||||
int64 original_value = message.optional_int64();
|
||||
int64_t original_value = message.optional_int64();
|
||||
|
||||
// Clear the field and make sure it shows up as cleared.
|
||||
message.clear_optional_int64();
|
||||
@ -498,7 +503,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, ADLSwap) {
|
||||
|
||||
// Note the address of one of the repeated fields, to verify it was swapped
|
||||
// rather than copied.
|
||||
const int32* addr = &message1.repeated_int32().Get(0);
|
||||
const int32_t* addr = &message1.repeated_int32().Get(0);
|
||||
|
||||
using std::swap;
|
||||
swap(message1, message2);
|
||||
@ -648,7 +653,7 @@ TEST(GENERATED_MESSAGE_TEST_NAME, NonEmptyMergeFrom) {
|
||||
|
||||
// This tests concatenating.
|
||||
message2.add_repeated_int32(message1.repeated_int32(1));
|
||||
int32 i = message1.repeated_int32(0);
|
||||
int32_t i = message1.repeated_int32(0);
|
||||
message1.clear_repeated_int32();
|
||||
message1.add_repeated_int32(i);
|
||||
|
||||
@ -665,8 +670,8 @@ TEST(GENERATED_MESSAGE_TEST_NAME, SerializationToArray) {
|
||||
TestUtil::SetAllFields(&message1);
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
TestUtil::ExpectAllFieldsSet(message2);
|
||||
@ -679,8 +684,9 @@ TEST(GENERATED_MESSAGE_TEST_NAME, PackedFieldsSerializationToArray) {
|
||||
TestUtil::SetPackedFields(&packed_message1);
|
||||
int packed_size = packed_message1.ByteSizeLong();
|
||||
packed_data.resize(packed_size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&packed_data));
|
||||
uint8* end = packed_message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start =
|
||||
reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&packed_data));
|
||||
uint8_t* end = packed_message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(packed_size, end - start);
|
||||
EXPECT_TRUE(packed_message2.ParseFromString(packed_data));
|
||||
TestUtil::ExpectPackedFieldsSet(packed_message2);
|
||||
@ -1846,8 +1852,8 @@ std::string data;
|
||||
message1.set_foo_int(123);
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foo_int(), 123);
|
||||
@ -1860,8 +1866,8 @@ EXPECT_EQ(message2.foo_int(), 123);
|
||||
message1.set_foo_string("foo");
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foo_string(), "foo");
|
||||
@ -1875,8 +1881,8 @@ EXPECT_EQ(message2.foo_int(), 123);
|
||||
message1.set_foo_bytes("qux");
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foo_bytes(), "qux");
|
||||
@ -1889,8 +1895,8 @@ EXPECT_EQ(message2.foo_int(), 123);
|
||||
message1.set_foo_enum(UNITTEST::TestOneof2::FOO);
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foo_enum(), UNITTEST::TestOneof2::FOO);
|
||||
@ -1903,8 +1909,8 @@ EXPECT_EQ(message2.foo_int(), 123);
|
||||
message1.mutable_foo_message()->set_qux_int(234);
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foo_message().qux_int(), 234);
|
||||
@ -1917,8 +1923,8 @@ EXPECT_EQ(message2.foo_int(), 123);
|
||||
message1.mutable_foogroup()->set_a(345);
|
||||
int size = message1.ByteSizeLong();
|
||||
data.resize(size);
|
||||
uint8* start = reinterpret_cast<uint8*>(::google::protobuf::string_as_array(&data));
|
||||
uint8* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
uint8_t* start = reinterpret_cast<uint8_t*>(::google::protobuf::string_as_array(&data));
|
||||
uint8_t* end = message1.SerializeWithCachedSizesToArray(start);
|
||||
EXPECT_EQ(size, end - start);
|
||||
EXPECT_TRUE(message2.ParseFromString(data));
|
||||
EXPECT_EQ(message2.foogroup().a(), 345);
|
||||
|
@ -32,6 +32,9 @@
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/java/java_enum_field.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@ -39,7 +42,6 @@
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/compiler/java/java_context.h>
|
||||
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
||||
#include <google/protobuf/compiler/java/java_enum_field.h>
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
#include <google/protobuf/compiler/java/java_name_resolver.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
@ -67,7 +69,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
|
||||
(*variables)["default_number"] =
|
||||
StrCat(descriptor->default_value_enum()->number());
|
||||
(*variables)["tag"] = StrCat(
|
||||
static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
|
||||
static_cast<int32_t>(internal::WireFormat::MakeTag(descriptor)));
|
||||
(*variables)["tag_size"] = StrCat(
|
||||
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
|
||||
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
|
||||
|
@ -32,6 +32,9 @@
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/java/java_enum_field_lite.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@ -39,7 +42,6 @@
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/compiler/java/java_context.h>
|
||||
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
||||
#include <google/protobuf/compiler/java/java_enum_field_lite.h>
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
#include <google/protobuf/compiler/java/java_name_resolver.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
@ -74,7 +76,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
|
||||
(*variables)["default_number"] =
|
||||
StrCat(descriptor->default_value_enum()->number());
|
||||
(*variables)["tag"] = StrCat(
|
||||
static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
|
||||
static_cast<int32_t>(internal::WireFormat::MakeTag(descriptor)));
|
||||
(*variables)["tag_size"] = StrCat(
|
||||
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
|
||||
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
|
||||
@ -281,7 +283,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
|
||||
}
|
||||
|
||||
void ImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
@ -377,7 +379,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
|
||||
}
|
||||
|
||||
void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
@ -632,7 +634,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
|
||||
}
|
||||
|
||||
void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
|
@ -35,8 +35,10 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_field.h>
|
||||
|
||||
namespace google {
|
||||
@ -70,7 +72,7 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateInitializationCode(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
std::string GetBoxedType() const;
|
||||
|
||||
@ -95,7 +97,7 @@ class ImmutableEnumOneofFieldLiteGenerator
|
||||
void GenerateMembers(io::Printer* printer) const;
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldLiteGenerator);
|
||||
@ -115,7 +117,7 @@ class RepeatedImmutableEnumFieldLiteGenerator
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateInitializationCode(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
std::string GetBoxedType() const;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -104,7 +105,7 @@ class ImmutableFieldLiteGenerator {
|
||||
virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;
|
||||
virtual void GenerateInitializationCode(io::Printer* printer) const = 0;
|
||||
virtual void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const = 0;
|
||||
std::vector<uint16_t>* output) const = 0;
|
||||
|
||||
virtual std::string GetBoxedType() const = 0;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
@ -500,11 +501,11 @@ std::string DefaultValue(const FieldDescriptor* field, bool immutable,
|
||||
return StrCat(field->default_value_int32());
|
||||
case FieldDescriptor::CPPTYPE_UINT32:
|
||||
// Need to print as a signed int since Java has no unsigned.
|
||||
return StrCat(static_cast<int32>(field->default_value_uint32()));
|
||||
return StrCat(static_cast<int32_t>(field->default_value_uint32()));
|
||||
case FieldDescriptor::CPPTYPE_INT64:
|
||||
return StrCat(field->default_value_int64()) + "L";
|
||||
case FieldDescriptor::CPPTYPE_UINT64:
|
||||
return StrCat(static_cast<int64>(field->default_value_uint64())) +
|
||||
return StrCat(static_cast<int64_t>(field->default_value_uint64())) +
|
||||
"L";
|
||||
case FieldDescriptor::CPPTYPE_DOUBLE: {
|
||||
double value = field->default_value_double();
|
||||
@ -896,11 +897,11 @@ bool HasRepeatedFields(const Descriptor* descriptor) {
|
||||
//
|
||||
// Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF].
|
||||
// There will be no surrogate pairs in the encoded character sequence.
|
||||
void WriteUInt32ToUtf16CharSequence(uint32 number,
|
||||
std::vector<uint16>* output) {
|
||||
void WriteUInt32ToUtf16CharSequence(uint32_t number,
|
||||
std::vector<uint16_t>* output) {
|
||||
// For values in [0x0000, 0xD7FF], only use one char to encode it.
|
||||
if (number < 0xD800) {
|
||||
output->push_back(static_cast<uint16>(number));
|
||||
output->push_back(static_cast<uint16_t>(number));
|
||||
return;
|
||||
}
|
||||
// Encode into multiple chars. All except the last char will be in the range
|
||||
@ -910,10 +911,10 @@ void WriteUInt32ToUtf16CharSequence(uint32 number,
|
||||
// them.
|
||||
while (number >= 0xD800) {
|
||||
// [0xE000, 0xFFFF] can represent 13 bits of info.
|
||||
output->push_back(static_cast<uint16>(0xE000 | (number & 0x1FFF)));
|
||||
output->push_back(static_cast<uint16_t>(0xE000 | (number & 0x1FFF)));
|
||||
number >>= 13;
|
||||
}
|
||||
output->push_back(static_cast<uint16>(number));
|
||||
output->push_back(static_cast<uint16_t>(number));
|
||||
}
|
||||
|
||||
int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor* field) {
|
||||
@ -994,7 +995,7 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field) {
|
||||
}
|
||||
|
||||
// Escape a UTF-16 character to be embedded in a Java string.
|
||||
void EscapeUtf16ToString(uint16 code, std::string* output) {
|
||||
void EscapeUtf16ToString(uint16_t code, std::string* output) {
|
||||
if (code == '\t') {
|
||||
output->append("\\t");
|
||||
} else if (code == '\b') {
|
||||
|
@ -35,7 +35,9 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_context.h>
|
||||
#include <google/protobuf/descriptor.pb.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
@ -412,15 +414,16 @@ inline std::string GeneratedCodeVersionSuffix() {
|
||||
return "V3";
|
||||
}
|
||||
|
||||
void WriteUInt32ToUtf16CharSequence(uint32 number, std::vector<uint16>* output);
|
||||
void WriteUInt32ToUtf16CharSequence(uint32_t number,
|
||||
std::vector<uint16_t>* output);
|
||||
|
||||
inline void WriteIntToUtf16CharSequence(int value,
|
||||
std::vector<uint16>* output) {
|
||||
WriteUInt32ToUtf16CharSequence(static_cast<uint32>(value), output);
|
||||
std::vector<uint16_t>* output) {
|
||||
WriteUInt32ToUtf16CharSequence(static_cast<uint32_t>(value), output);
|
||||
}
|
||||
|
||||
// Escape a UTF-16 character so it can be embedded in a Java string literal.
|
||||
void EscapeUtf16ToString(uint16 code, std::string* output);
|
||||
void EscapeUtf16ToString(uint16_t code, std::string* output);
|
||||
|
||||
// Only the lowest two bytes of the return value are used. The lowest byte
|
||||
// is the integer value of a j/c/g/protobuf/FieldType enum. For the other
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include <google/protobuf/compiler/java/java_map_field_lite.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_context.h>
|
||||
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
@ -505,7 +507,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
|
||||
}
|
||||
|
||||
void ImmutableMapFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
|
@ -31,6 +31,8 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_field.h>
|
||||
|
||||
namespace google {
|
||||
@ -52,7 +54,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateInitializationCode(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
std::string GetBoxedType() const;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <google/protobuf/compiler/java/java_message.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -1213,11 +1214,11 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
|
||||
|
||||
for (int i = 0; i < descriptor_->field_count(); i++) {
|
||||
const FieldDescriptor* field = sorted_fields[i];
|
||||
uint32 tag = WireFormatLite::MakeTag(
|
||||
uint32_t tag = WireFormatLite::MakeTag(
|
||||
field->number(), WireFormat::WireTypeForFieldType(field->type()));
|
||||
|
||||
printer->Print("case $tag$: {\n", "tag",
|
||||
StrCat(static_cast<int32>(tag)));
|
||||
StrCat(static_cast<int32_t>(tag)));
|
||||
printer->Indent();
|
||||
|
||||
field_generators_.get(field).GenerateParsingCode(printer);
|
||||
@ -1230,10 +1231,10 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
|
||||
if (field->is_packable()) {
|
||||
// To make packed = true wire compatible, we generate parsing code from a
|
||||
// packed version of this field regardless of field->options().packed().
|
||||
uint32 packed_tag = WireFormatLite::MakeTag(
|
||||
uint32_t packed_tag = WireFormatLite::MakeTag(
|
||||
field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
|
||||
printer->Print("case $tag$: {\n", "tag",
|
||||
StrCat(static_cast<int32>(packed_tag)));
|
||||
StrCat(static_cast<int32_t>(packed_tag)));
|
||||
printer->Indent();
|
||||
|
||||
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
|
||||
|
@ -32,13 +32,15 @@
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/java/java_message_field_lite.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_context.h>
|
||||
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
#include <google/protobuf/compiler/java/java_message_field_lite.h>
|
||||
#include <google/protobuf/compiler/java/java_name_resolver.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
@ -276,7 +278,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
|
||||
}
|
||||
|
||||
void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
@ -366,7 +368,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
|
||||
}
|
||||
|
||||
void ImmutableMessageOneofFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
@ -731,7 +733,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
|
||||
}
|
||||
|
||||
void RepeatedImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
|
||||
io::Printer* printer, std::vector<uint16>* output) const {
|
||||
io::Printer* printer, std::vector<uint16_t>* output) const {
|
||||
WriteIntToUtf16CharSequence(descriptor_->number(), output);
|
||||
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
|
||||
output);
|
||||
|
@ -35,8 +35,10 @@
|
||||
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
|
||||
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/compiler/java/java_field.h>
|
||||
|
||||
namespace google {
|
||||
@ -70,7 +72,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateInitializationCode(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
std::string GetBoxedType() const;
|
||||
|
||||
@ -95,7 +97,7 @@ class ImmutableMessageOneofFieldLiteGenerator
|
||||
void GenerateMembers(io::Printer* printer) const;
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
private:
|
||||
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
|
||||
@ -115,7 +117,7 @@ class RepeatedImmutableMessageFieldLiteGenerator
|
||||
void GenerateBuilderMembers(io::Printer* printer) const;
|
||||
void GenerateInitializationCode(io::Printer* printer) const;
|
||||
void GenerateFieldInfo(io::Printer* printer,
|
||||
std::vector<uint16>* output) const;
|
||||
std::vector<uint16_t>* output) const;
|
||||
|
||||
std::string GetBoxedType() const;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <google/protobuf/compiler/java/java_message_lite.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -471,7 +472,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
|
||||
|
||||
// Collect field info into a sequence of UTF-16 chars. It will be embedded
|
||||
// as a Java string in the generated code.
|
||||
std::vector<uint16> chars;
|
||||
std::vector<uint16_t> chars;
|
||||
|
||||
int flags = 0;
|
||||
if (IsProto2(descriptor_->file())) {
|
||||
@ -553,7 +554,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
|
||||
printer->Print("java.lang.String info =\n");
|
||||
std::string line;
|
||||
for (size_t i = 0; i < chars.size(); i++) {
|
||||
uint16 code = chars[i];
|
||||
uint16_t code = chars[i];
|
||||
EscapeUtf16ToString(code, &line);
|
||||
if (line.size() >= 80) {
|
||||
printer->Print(" \"$string$\" +\n", "string", line);
|
||||
|
@ -32,6 +32,9 @@
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
#include <google/protobuf/compiler/java/java_primitive_field.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@ -41,7 +44,6 @@
|
||||
#include <google/protobuf/compiler/java/java_doc_comment.h>
|
||||
#include <google/protobuf/compiler/java/java_helpers.h>
|
||||
#include <google/protobuf/compiler/java/java_name_resolver.h>
|
||||
#include <google/protobuf/compiler/java/java_primitive_field.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
#include <google/protobuf/stubs/strutil.h>
|
||||
@ -112,7 +114,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
|
||||
(*variables)["capitalized_type"] =
|
||||
GetCapitalizedType(descriptor, /* immutable = */ true);
|
||||
(*variables)["tag"] =
|
||||
StrCat(static_cast<int32>(WireFormat::MakeTag(descriptor)));
|
||||
StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
|
||||
(*variables)["tag_size"] = StrCat(
|
||||
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
|
||||
if (IsReferenceType(GetJavaType(descriptor))) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user